Skip to content

Commit

Permalink
Merge branch 'main' into add_min_collection_time_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jannast authored Jan 13, 2025
2 parents c1ff5a8 + 4a510e5 commit 6c8ebef
Show file tree
Hide file tree
Showing 17 changed files with 1,071 additions and 1,327 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- the SoapMarshalling is now configurable regarding packages to scan for JAXB classes and the schemas for validation
- 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.2.0-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,61 +76,45 @@ void testRequirementR00290() throws NoTestData, IOException {
messageStorage, getInjector().getInstance(TestRunObserver.class));

final var presenceOnSeen = new AtomicInteger(0);
try (final Stream<String> sequenceIds = mdibHistorian.getKnownSequenceIds()) {
sequenceIds.forEach(sequenceId -> {
try (final MdibHistorian.HistorianResult history =
mdibHistorian.episodicReportBasedHistory(sequenceId)) {

RemoteMdibAccess mdibAccess = history.next();

while (mdibAccess != null) {
final var alertConditionStates = mdibAccess.getStatesByType(AlertConditionState.class);
for (var alertConditionState : alertConditionStates) {
final var isPresence = ImpliedValueUtil.isPresence(alertConditionState);
if (isPresence) {
presenceOnSeen.incrementAndGet();
final var descriptorHandle = alertConditionState.getDescriptorHandle();
final var alertSystemStateHandle = mdibAccess
.getEntity(descriptorHandle)
.orElseThrow()
.getParent()
.orElseThrow();
final var alertSystemState = mdibAccess
.getState(alertSystemStateHandle, AlertSystemState.class)
.orElseThrow();

assertEquals(
AlertActivation.ON,
alertConditionState.getActivationState(),
String.format(
"AlertConditionState/@Presence is true, for AlertConditionState with handle %s."
+ "The AlertConditionState/@Activation state should be 'On' but is '%s'",
descriptorHandle,
alertConditionState
.getActivationState()
.value()));
assertEquals(
AlertActivation.ON,
alertSystemState.getActivationState(),
String.format(
"AlertConditionState/@Presence is true, for AlertConditionState with handle %s."
+ " The AlertSystemState/@Activation "
+ "state for AlertSystemState with handle %s"
+ " should be 'On' but is '%s'",
descriptorHandle,
alertSystemStateHandle,
alertSystemState
.getActivationState()
.value()));
}
}
mdibAccess = history.next();
}
} catch (PreprocessingException | ReportProcessingException e) {
fail(e);
mdibHistorian.processAllRemoteMdibAccess(mdibAccess -> {
final var alertConditionStates = mdibAccess.getStatesByType(AlertConditionState.class);
for (var alertConditionState : alertConditionStates) {
final var isPresence = ImpliedValueUtil.isPresence(alertConditionState);
if (isPresence) {
presenceOnSeen.incrementAndGet();
final var descriptorHandle = alertConditionState.getDescriptorHandle();
final var alertSystemStateHandle = mdibAccess
.getEntity(descriptorHandle)
.orElseThrow()
.getParent()
.orElseThrow();
final var alertSystemState = mdibAccess
.getState(alertSystemStateHandle, AlertSystemState.class)
.orElseThrow();

assertEquals(
AlertActivation.ON,
alertConditionState.getActivationState(),
String.format(
"AlertConditionState/@Presence is true, for AlertConditionState with handle %s."
+ "The AlertConditionState/@Activation state should be 'On' but is '%s'",
descriptorHandle,
alertConditionState.getActivationState().value()));
assertEquals(
AlertActivation.ON,
alertSystemState.getActivationState(),
String.format(
"AlertConditionState/@Presence is true, for AlertConditionState with handle %s."
+ " The AlertSystemState/@Activation "
+ "state for AlertSystemState with handle %s"
+ " should be 'On' but is '%s'",
descriptorHandle,
alertSystemStateHandle,
alertSystemState.getActivationState().value()));
}
});
}
}
});

assertTestData(presenceOnSeen.get(), NO_PRESENCE_TRUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import com.draeger.medical.sdccc.configuration.EnabledTestConfig;
import com.draeger.medical.sdccc.manipulation.precondition.impl.ManipulationPreconditions;
Expand All @@ -20,7 +19,6 @@
import com.draeger.medical.sdccc.tests.annotations.TestDescription;
import com.draeger.medical.sdccc.tests.annotations.TestIdentifier;
import com.draeger.medical.sdccc.tests.util.ImpliedValueUtil;
import com.draeger.medical.sdccc.tests.util.MdibHistorian;
import com.draeger.medical.sdccc.tests.util.NoTestData;
import com.draeger.medical.sdccc.tests.util.guice.MdibHistorianFactory;
import com.draeger.medical.sdccc.util.TestRunObserver;
Expand All @@ -32,10 +30,8 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.somda.sdc.biceps.common.storage.PreprocessingException;
import org.somda.sdc.biceps.consumer.access.RemoteMdibAccess;
import org.somda.sdc.biceps.model.participant.AlertActivation;
import org.somda.sdc.biceps.model.participant.AlertSignalDescriptor;
Expand All @@ -44,7 +40,6 @@
import org.somda.sdc.biceps.model.participant.AlertSignalState;
import org.somda.sdc.biceps.model.participant.AlertSystemState;
import org.somda.sdc.biceps.model.participant.SystemSignalActivation;
import org.somda.sdc.glue.consumer.report.ReportProcessingException;

/**
* BICEPS Annex B alert tests (B.88 - B.128).
Expand Down Expand Up @@ -76,64 +71,49 @@ void testRequirementB128() throws NoTestData, IOException {

final var acceptableSequenceSeen = new AtomicInteger(0);

try (final Stream<String> sequenceIds = mdibHistorian.getKnownSequenceIds()) {
sequenceIds.forEach(sequenceId -> {
try (final MdibHistorian.HistorianResult history =
mdibHistorian.episodicReportBasedHistory(sequenceId)) {
RemoteMdibAccess first = history.next();

while (first != null) {
final var alertSystemStates = first.getStatesByType(AlertSystemState.class);

for (var alertSystemState : alertSystemStates) {
final var manifestationAndAlertActivationsMap =
createSystemSignalActivationMap(alertSystemState.getSystemSignalActivation());

final var childAlertSignals =
getChildAlertSignals(first, alertSystemState.getDescriptorHandle());

for (var manifestationAndState : manifestationAndAlertActivationsMap.entrySet()) {
final var currentActivationStates = manifestationAndState.getValue();
final var onSeen = new AtomicBoolean(false);
final var allPsd = new AtomicInteger(0);
final var allOff = new AtomicInteger(0);
final var childrenWithSameManifestation = getChildrenWithSameManifestation(
childAlertSignals, manifestationAndState.getKey());
for (var entry : childrenWithSameManifestation) {
acceptableSequenceSeen.incrementAndGet();
final var alertSignalActivationState = entry.getActivationState();
for (var currentActivationState : currentActivationStates) {
verifyAlertSignalActivationState(
currentActivationState,
alertSignalActivationState,
entry.getDescriptorHandle());
}

switch (alertSignalActivationState) {
case ON -> onSeen.set(true);
case PSD -> allPsd.incrementAndGet();
case OFF -> allOff.incrementAndGet();
default -> {}
}
}
if (onSeen.get()) {
checkActivationState(manifestationAndState.getValue(), AlertActivation.ON);
} else if (!childrenWithSameManifestation.isEmpty()
&& allPsd.get() == childrenWithSameManifestation.size()) {
checkActivationState(manifestationAndState.getValue(), AlertActivation.PSD);
} else if (!childrenWithSameManifestation.isEmpty()
&& allOff.get() == childrenWithSameManifestation.size()) {
checkActivationState(manifestationAndState.getValue(), AlertActivation.OFF);
}
}
mdibHistorian.processAllRemoteMdibAccess(first -> {
final var alertSystemStates = first.getStatesByType(AlertSystemState.class);

for (var alertSystemState : alertSystemStates) {
final var manifestationAndAlertActivationsMap =
createSystemSignalActivationMap(alertSystemState.getSystemSignalActivation());

final var childAlertSignals = getChildAlertSignals(first, alertSystemState.getDescriptorHandle());

for (var manifestationAndState : manifestationAndAlertActivationsMap.entrySet()) {
final var currentActivationStates = manifestationAndState.getValue();
final var onSeen = new AtomicBoolean(false);
final var allPsd = new AtomicInteger(0);
final var allOff = new AtomicInteger(0);
final var childrenWithSameManifestation =
getChildrenWithSameManifestation(childAlertSignals, manifestationAndState.getKey());
for (var entry : childrenWithSameManifestation) {
acceptableSequenceSeen.incrementAndGet();
final var alertSignalActivationState = entry.getActivationState();
for (var currentActivationState : currentActivationStates) {
verifyAlertSignalActivationState(
currentActivationState, alertSignalActivationState, entry.getDescriptorHandle());
}
first = history.next();

switch (alertSignalActivationState) {
case ON -> onSeen.set(true);
case PSD -> allPsd.incrementAndGet();
case OFF -> allOff.incrementAndGet();
default -> {}
}
}
if (onSeen.get()) {
checkActivationState(manifestationAndState.getValue(), AlertActivation.ON);
} else if (!childrenWithSameManifestation.isEmpty()
&& allPsd.get() == childrenWithSameManifestation.size()) {
checkActivationState(manifestationAndState.getValue(), AlertActivation.PSD);
} else if (!childrenWithSameManifestation.isEmpty()
&& allOff.get() == childrenWithSameManifestation.size()) {
checkActivationState(manifestationAndState.getValue(), AlertActivation.OFF);
}
} catch (PreprocessingException | ReportProcessingException e) {
fail(e);
}
});
}
}
});

assertTestData(acceptableSequenceSeen.get(), "No acceptable sequence seen, test failed");
}
Expand Down
Loading

0 comments on commit 6c8ebef

Please sign in to comment.