Skip to content

Commit

Permalink
Merge branch 'FixForSequenceIdOrderingProblem' of https://github.com/…
Browse files Browse the repository at this point in the history
…ben-Draeger/SDCcc into FixForSequenceIdOrderingProblem
  • Loading branch information
ben-Draeger committed Nov 28, 2024
2 parents f257b7c + 91ef0e4 commit 3773d24
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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() {
Expand Down Expand Up @@ -98,7 +101,8 @@ protected void configure() {
bind(TestRunObserver.class).toInstance(testRunObserver);
bind(LocalAddressResolver.class).toInstance(localAddressResolver);
}
}));
},
configurationModule));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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<? extends ObservingPreconditionFactory<?>> mockPreconditionFactory = mock(KClass.class);

final var mockFactory = mock(ObservingPreconditionFactory.class);
Expand All @@ -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<? extends ObservingPreconditionFactory<?>> mockPreconditionFactory = mock(KClass.class);

final var mockFactory = mock(ObservingPreconditionFactory.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {}
});
}
}
}

0 comments on commit 3773d24

Please sign in to comment.