diff --git a/CHANGELOG.md b/CHANGELOG.md index f5d475ad..94e7f1ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- the collected data is now flushed after each precondition - moved test case specific parameter into separate file test_parameter.toml - sdc-ri version to 6.0.0-SNAPSHOT diff --git a/sdccc/src/main/java/com/draeger/medical/sdccc/configuration/DefaultTestSuiteConfig.java b/sdccc/src/main/java/com/draeger/medical/sdccc/configuration/DefaultTestSuiteConfig.java index 71d0a76a..d76084e6 100644 --- a/sdccc/src/main/java/com/draeger/medical/sdccc/configuration/DefaultTestSuiteConfig.java +++ b/sdccc/src/main/java/com/draeger/medical/sdccc/configuration/DefaultTestSuiteConfig.java @@ -7,6 +7,7 @@ package com.draeger.medical.sdccc.configuration; +import com.draeger.medical.sdccc.util.Constants; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.somda.sdc.common.guice.AbstractConfigurationModule; @@ -49,6 +50,10 @@ void configureTestSuite() { bind(TestSuiteConfig.ENABLE_MESSAGE_ENCODING_CHECK, Boolean.class, true); bind(TestSuiteConfig.SUMMARIZE_MESSAGE_ENCODING_ERRORS, Boolean.class, true); + bind(Constants.CONFIGURATION_MODULE, AbstractConfigurationModule.class, new AbstractConfigurationModule() { + @Override + protected void defaultConfigure() {} + }); } void configureTLS() { diff --git a/sdccc/src/main/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistry.kt b/sdccc/src/main/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistry.kt index f60e3751..bd8b245b 100644 --- a/sdccc/src/main/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistry.kt +++ b/sdccc/src/main/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistry.kt @@ -6,6 +6,7 @@ */ package com.draeger.medical.sdccc.manipulation.precondition +import com.draeger.medical.sdccc.messages.MessageStorage import com.google.inject.Inject import com.google.inject.Injector import com.google.inject.Singleton @@ -101,6 +102,8 @@ class PreconditionRegistry @Inject internal constructor(private val injector: In for (precondition in preconditions) { logger.info { "Running precondition ${precondition.javaClass.simpleName}" } precondition.verifyPrecondition(injector) + // flush data after each precondition to ensure that each precondition has most current data + injector.getInstance(MessageStorage::class.java).flush() } } diff --git a/sdccc/src/main/java/com/draeger/medical/sdccc/sdcri/testclient/TestClientUtil.java b/sdccc/src/main/java/com/draeger/medical/sdccc/sdcri/testclient/TestClientUtil.java index a7b2c241..2ce9a989 100644 --- a/sdccc/src/main/java/com/draeger/medical/sdccc/sdcri/testclient/TestClientUtil.java +++ b/sdccc/src/main/java/com/draeger/medical/sdccc/sdcri/testclient/TestClientUtil.java @@ -12,6 +12,7 @@ import com.draeger.medical.sdccc.sdcri.CommunicationLogMessageStorage; import com.draeger.medical.sdccc.tests.util.MdibHistorian; import com.draeger.medical.sdccc.tests.util.guice.MdibHistorianFactory; +import com.draeger.medical.sdccc.util.Constants; import com.draeger.medical.sdccc.util.TestRunObserver; import com.google.inject.AbstractModule; import com.google.inject.Guice; @@ -61,6 +62,7 @@ public class TestClientUtil { * Values from 1 to 255 are valid. * @param enabledTlsProtocols TLS protocol versions to be enabled * @param enabledCiphers ciphers to be enabled + * @param configurationModule configuration for AbstractConfigurationModule */ @Inject public TestClientUtil( @@ -70,7 +72,8 @@ public TestClientUtil( final LocalAddressResolver localAddressResolver, @Named(TestSuiteConfig.NETWORK_MULTICAST_TTL) final Long multicastTTL, @Named(TestSuiteConfig.TLS_ENABLED_PROTOCOLS) final String[] enabledTlsProtocols, - @Named(TestSuiteConfig.TLS_ENABLED_CIPHERS) final String[] enabledCiphers) { + @Named(TestSuiteConfig.TLS_ENABLED_CIPHERS) final String[] enabledCiphers, + @Named(Constants.CONFIGURATION_MODULE) final AbstractConfigurationModule configurationModule) { injector = createClientInjector(List.of( new AbstractConfigurationModule() { @@ -98,7 +101,8 @@ protected void configure() { bind(TestRunObserver.class).toInstance(testRunObserver); bind(LocalAddressResolver.class).toInstance(localAddressResolver); } - })); + }, + configurationModule)); } /** diff --git a/sdccc/src/main/java/com/draeger/medical/sdccc/util/Constants.java b/sdccc/src/main/java/com/draeger/medical/sdccc/util/Constants.java index a29b84ac..f0641819 100644 --- a/sdccc/src/main/java/com/draeger/medical/sdccc/util/Constants.java +++ b/sdccc/src/main/java/com/draeger/medical/sdccc/util/Constants.java @@ -30,6 +30,7 @@ public final class Constants { public static final String ENABLE_SETTING_POSTFIX = "Enable"; public static final String DEVICE_EPR_POSTFIX = "DeviceEpr"; public static final String FIELD_ACCESS_ERROR_BASE_MESSAGE = "Error while accessing field {}"; + public static final String CONFIGURATION_MODULE = "ConfigurationModule"; /* MDPWS constants diff --git a/sdccc/src/test/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistryTest.java b/sdccc/src/test/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistryTest.java index 26a16fb2..3160bdb0 100644 --- a/sdccc/src/test/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistryTest.java +++ b/sdccc/src/test/java/com/draeger/medical/sdccc/manipulation/precondition/PreconditionRegistryTest.java @@ -15,7 +15,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import com.draeger.medical.sdccc.messages.MessageStorage; import com.google.inject.Injector; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -29,8 +31,16 @@ */ public class PreconditionRegistryTest { + private PreconditionRegistry registry; + @BeforeEach void setUp() { + final var mockInjector = mock(Injector.class); + final var messageStorageMock = mock(MessageStorage.class); + when(mockInjector.getInstance(MessageStorage.class)).thenReturn(messageStorageMock); + + registry = new PreconditionRegistry(mockInjector); + PreconditionUtil.MockPrecondition.reset(); PreconditionUtil.MockManipulation.reset(); } @@ -43,9 +53,6 @@ void setUp() { @Test @DisplayName("Tests registering a complex interaction and whether it's prompted for") public void testPreconditionInteractionRegistrationAndPrompt() throws Exception { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final var preconditionWasCalled = new AtomicBoolean(false); PreconditionUtil.MockPrecondition.setIsPreconditionMet(injector -> { preconditionWasCalled.set(true); @@ -74,9 +81,6 @@ public void testPreconditionInteractionRegistrationAndPrompt() throws Exception @Test @DisplayName("Tests whether registering the same complex interaction thrice only prompts for it once") public void testPreconditionInteractionRegisteredOnlyOnce() throws Exception { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final var preconditionWasCalled = new AtomicInteger(0); PreconditionUtil.MockPrecondition.setIsPreconditionMet(injector -> { preconditionWasCalled.incrementAndGet(); @@ -98,9 +102,6 @@ public void testPreconditionInteractionRegisteredOnlyOnce() throws Exception { @Test @DisplayName("Tests whether an exception during registration causes a RuntimeException and stops the test run") public void testPreconditionInteractionRegistrationException() { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final var mockInteractionWasCalled = new AtomicInteger(0); PreconditionUtil.MockPrecondition.setAfterConstructorCall(() -> { mockInteractionWasCalled.incrementAndGet(); @@ -121,9 +122,6 @@ public void testPreconditionInteractionRegistrationException() { @Test @DisplayName("Tests registering a manipulation and whether it's prompted for") public void testManipulationInteractionRegistrationAndPrompt() throws Exception { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final var manipulationWasCalled = new AtomicBoolean(false); PreconditionUtil.MockManipulation.setManipulationCall(injector -> { manipulationWasCalled.set(true); @@ -144,9 +142,6 @@ public void testManipulationInteractionRegistrationAndPrompt() throws Exception @Test @DisplayName("Tests whether registering the same manipulation thrice only prompts for it once") public void testManipulationInteractionRegisteredOnlyOnce() throws Exception { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final var manipulationWasCalled = new AtomicInteger(0); PreconditionUtil.MockManipulation.setManipulationCall(injector -> { manipulationWasCalled.incrementAndGet(); @@ -167,9 +162,6 @@ public void testManipulationInteractionRegisteredOnlyOnce() throws Exception { @Test @DisplayName("Tests whether an exception during registration causes a RuntimeException and stops the test run") public void testManipulationInteractionRegistrationException() { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final var mockInteractionWasCalled = new AtomicInteger(0); PreconditionUtil.MockManipulation.setAfterConstructorCall(() -> { mockInteractionWasCalled.incrementAndGet(); @@ -184,9 +176,6 @@ public void testManipulationInteractionRegistrationException() { @Test void testRegisteringObservingPreconditions() throws Exception { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final KClass> mockPreconditionFactory = mock(KClass.class); final var mockFactory = mock(ObservingPreconditionFactory.class); @@ -211,9 +200,6 @@ void testRegisteringObservingPreconditions() throws Exception { @Test void testRegisteringObservingPreconditionsFailsWhenNoObjectInstanceAvailable() { - final var mockInjector = mock(Injector.class); - final var registry = new PreconditionRegistry(mockInjector); - final KClass> mockPreconditionFactory = mock(KClass.class); final var mockFactory = mock(ObservingPreconditionFactory.class); diff --git a/sdccc/src/test/java/it/com/draeger/medical/sdccc/TestSuiteIT.java b/sdccc/src/test/java/it/com/draeger/medical/sdccc/TestSuiteIT.java index e1c6b084..ff460005 100644 --- a/sdccc/src/test/java/it/com/draeger/medical/sdccc/TestSuiteIT.java +++ b/sdccc/src/test/java/it/com/draeger/medical/sdccc/TestSuiteIT.java @@ -30,6 +30,7 @@ import com.draeger.medical.sdccc.messages.HibernateConfig; import com.draeger.medical.sdccc.sdcri.testclient.TestClient; import com.draeger.medical.sdccc.tests.InjectorTestBase; +import com.draeger.medical.sdccc.util.Constants; import com.draeger.medical.sdccc.util.HibernateConfigInMemoryImpl; import com.draeger.medical.sdccc.util.TestRunObserver; import com.google.inject.AbstractModule; @@ -632,6 +633,10 @@ protected void defaultConfigure() { bind(Identifiers.DIRECT_TEST_IDENTIFIER_FAILING, Boolean.class, failingTests); bind(Identifiers.INVARIANT_TEST_IDENTIFIER_FAILING, Boolean.class, failingTests); + bind(Constants.CONFIGURATION_MODULE, AbstractConfigurationModule.class, new AbstractConfigurationModule() { + @Override + protected void defaultConfigure() {} + }); } } }