Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove observing preconditions #231

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- support for Kotlin
- preconditions which observe mdib changes during the test run
- storing of IP addresses of inbound messages in the database
- a command line parameter to not create subdirectories in the test run directory
- a command line parameter to print the version of the sdccc test tool
Expand Down
12 changes: 0 additions & 12 deletions sdccc/src/main/java/com/draeger/medical/sdccc/TestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.draeger.medical.sdccc.configuration.TestRunConfig;
import com.draeger.medical.sdccc.configuration.TestSuiteConfig;
import com.draeger.medical.sdccc.guice.TomlConfigParser;
import com.draeger.medical.sdccc.manipulation.precondition.ObservingPreconditionMdibObserver;
import com.draeger.medical.sdccc.manipulation.precondition.PreconditionException;
import com.draeger.medical.sdccc.manipulation.precondition.PreconditionRegistry;
import com.draeger.medical.sdccc.messages.MessageStorage;
Expand Down Expand Up @@ -386,17 +385,6 @@ private void startClient() {
throw new RuntimeException(e);
}

// register observing preconditions in test client before connecting to the target
// this allows us to see the initial mdib as a change
final var preconditions = injector.getInstance(PreconditionRegistry.class);
final var observingPreconditions = preconditions.getObservingPreconditions();
for (final var precondition : observingPreconditions) {
LOG.info(
"Registering observing precondition in test client {}",
precondition.getClass().getSimpleName());
client.registerMdibObserver(new ObservingPreconditionMdibObserver(precondition));
}

try {
client.connect();
} catch (final InterceptorException | TransportException | IOException e) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.google.inject.Injector
import com.google.inject.Singleton
import org.apache.logging.log4j.kotlin.Logging
import java.lang.reflect.InvocationTargetException
import kotlin.reflect.KClass

/**
* Registry which allows executing preconditions during a test run.
Expand All @@ -22,12 +21,6 @@ class PreconditionRegistry @Inject internal constructor(private val injector: In

private val preconditions: MutableList<Precondition> = ArrayList()

/**
* Returns all registered preconditions which are of type [Observing].
*/
val observingPreconditions: Collection<Observing>
get() = preconditions.filterIsInstance<Observing>()

@Suppress("TooGenericExceptionThrown") // this is an error during startup and cannot be fixed
private fun handleRegisteringError(error: Throwable, text: String): Nothing {
logger.error(error) { text }
Expand Down Expand Up @@ -74,24 +67,6 @@ class PreconditionRegistry @Inject internal constructor(private val injector: In
registerPreconditionInternal(precondition)
}

/**
* Registers an observing precondition for running and observing before disconnecting from the DUT.
*
* Duplicate preconditions will be ignored.
*
* @param precondition precondition to run
*/
fun registerObservingPrecondition(precondition: KClass<out ObservingPreconditionFactory<*>>) {
val factoryInstance = checkNotNull(precondition.objectInstance) {
"Factory class ${precondition.simpleName ?: "without a simple name"} " +
"does not provide an object instance. Ensure it is a Companion."
}
val instance = factoryInstance.create(injector)
if (!preconditions.contains(instance)) {
preconditions.add(instance)
}
}

/**
* Runs all registered preconditions.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package com.draeger.medical.sdccc.tests.annotations

import com.draeger.medical.sdccc.manipulation.precondition.ManipulationPrecondition
import com.draeger.medical.sdccc.manipulation.precondition.ObservingPreconditionFactory
import com.draeger.medical.sdccc.manipulation.precondition.SimplePrecondition
import kotlin.reflect.KClass

Expand Down Expand Up @@ -39,10 +38,4 @@ annotation class RequirePrecondition(
* @return array of manipulation classes to trigger for the test
*/
val manipulationPreconditions: Array<KClass<out ManipulationPrecondition>> = [],
/**
* Observing preconditions to attach.
*
* @return array of manipulation classes to trigger for the test
*/
val observingPreconditions: Array<KClass<out ObservingPreconditionFactory<*>>> = []
)
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public FilterResult apply(final TestDescriptor object) {
preconditionRegistry.registerManipulationPrecondition(manipulationPrecondition);
}

for (final var observingPrecondition : requiredInteraction.observingPreconditions()) {
preconditionRegistry.registerObservingPrecondition(
kotlin.jvm.JvmClassMappingKt.getKotlinClass(observingPrecondition));
}

result = FilterResult.included("Filter only used for metadata collection");
}
}
Expand Down
Loading
Loading