Skip to content

Commit

Permalink
Pairs and other fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
midttuna committed Dec 11, 2024
1 parent 31f585e commit 28fe0b6
Show file tree
Hide file tree
Showing 12 changed files with 380 additions and 389 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void testRequirementR00290() throws NoTestData, IOException {
messageStorage, getInjector().getInstance(TestRunObserver.class));

final var presenceOnSeen = new AtomicInteger(0);
mdibHistorian.procesAllRemoteMdibAccess(mdibAccess -> {
mdibHistorian.processAllRemoteMdibAccess(mdibAccess -> {
final var alertConditionStates = mdibAccess.getStatesByType(AlertConditionState.class);
for (var alertConditionState : alertConditionStates) {
final var isPresence = ImpliedValueUtil.isPresence(alertConditionState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void testRequirementB128() throws NoTestData, IOException {

final var acceptableSequenceSeen = new AtomicInteger(0);

mdibHistorian.procesAllRemoteMdibAccess(first -> {
mdibHistorian.processAllRemoteMdibAccess(first -> {
final var alertSystemStates = first.getStatesByType(AlertSystemState.class);

for (var alertSystemState : alertSystemStates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void testRequirementR00250() throws NoTestData, IOException {

final var acceptableSequenceSeen = new AtomicInteger(0);

mdibHistorian.procesAllRemoteMdibAccess(remoteMdibAccess -> {
mdibHistorian.processAllRemoteMdibAccess(remoteMdibAccess -> {
final var entities = remoteMdibAccess.findEntitiesByType(AbstractDeviceComponentDescriptor.class);

for (var entity : entities) {
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.ConditionalPreconditions;
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 @@ -37,7 +35,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.somda.sdc.biceps.common.MdibEntity;
import org.somda.sdc.biceps.common.storage.PreprocessingException;
import org.somda.sdc.biceps.consumer.access.RemoteMdibAccess;
import org.somda.sdc.biceps.model.participant.AbstractContextDescriptor;
import org.somda.sdc.biceps.model.participant.AbstractContextState;
Expand All @@ -50,7 +47,6 @@
import org.somda.sdc.biceps.model.participant.OperatorContextDescriptor;
import org.somda.sdc.biceps.model.participant.PatientContextDescriptor;
import org.somda.sdc.biceps.model.participant.WorkflowContextDescriptor;
import org.somda.sdc.glue.consumer.report.ReportProcessingException;

/**
* BICEPS participant model multistate tests (ch. 5.4.3).
Expand Down Expand Up @@ -85,45 +81,42 @@ void setUp() {
simplePreconditions = {ConditionalPreconditions.AllKindsOfContextStatesAssociatedPrecondition.class})
void testRequirement0097() throws NoTestData, IOException {

final var descriptorHandles = new HashSet<String>();
final var multiStateHandles = new HashSet<String>();

final var mdibHistorian = mdibHistorianFactory.createMdibHistorian(
messageStorage, getInjector().getInstance(TestRunObserver.class));
final var seenAcceptableSequence = new AtomicBoolean(false);

try (final Stream<String> sequenceIds = mdibHistorian.getKnownSequenceIds()) {
sequenceIds.forEach(sequenceId -> {
try (final MdibHistorian.HistorianResult history =
mdibHistorian.episodicReportBasedHistory(sequenceId)) {
RemoteMdibAccess first = history.next();
final var seenMultiStatesMap = initMultiStateMap(first, CONTEXT_DESCRIPTOR_CLASSES);
while (first != null) {
final var entities = first.findEntitiesByType(AbstractDescriptor.class);
final var states = first.findContextStatesByType(AbstractContextState.class);
addAllDescriptorHandles(entities, descriptorHandles);
if (states.isEmpty()) {
first = history.next();
continue;
}
addAllMultiStateHandles(states, multiStateHandles, seenMultiStatesMap);
areMultiStatesHandlesUnique(states);
areHandlesDisjunctive(descriptorHandles, multiStateHandles, first.getMdibVersion());
first = history.next();
}
var acceptableSequence = true;
for (var value : seenMultiStatesMap.values()) {
acceptableSequence &= value.size() > 1;
}

if (acceptableSequence) {
seenAcceptableSequence.set(acceptableSequence);
}
} catch (PreprocessingException | ReportProcessingException e) {
fail(e);
final var descriptorHandles = new HashSet<String>();
final var multiStateHandles = new HashSet<String>();
final var seenMultiStatesMap = new HashMap<String, Set<String>>();
final var firstAccess = new AtomicBoolean(true);

mdibHistorian.processRemoteMdibAccessForSequence(
mdibAccess -> {
if (firstAccess.getAndSet(false)) {
seenMultiStatesMap.putAll(initMultiStateMap(mdibAccess, CONTEXT_DESCRIPTOR_CLASSES));
}
final var entities = mdibAccess.findEntitiesByType(AbstractDescriptor.class);
final var states = mdibAccess.findContextStatesByType(AbstractContextState.class);
addAllDescriptorHandles(entities, descriptorHandles);
if (!states.isEmpty()) {
addAllMultiStateHandles(states, multiStateHandles, seenMultiStatesMap);
areMultiStatesHandlesUnique(states);
areHandlesDisjunctive(
descriptorHandles, multiStateHandles, mdibAccess.getMdibVersion());
}
},
sequenceId);

var acceptableSequence = true;
for (var value : seenMultiStatesMap.values()) {
acceptableSequence &= value.size() > 1;
}

if (acceptableSequence) {
seenAcceptableSequence.set(true);
}
descriptorHandles.clear();
multiStateHandles.clear();
});
}
assertTestData(
Expand Down Expand Up @@ -161,7 +154,7 @@ private void addAllMultiStateHandles(
multiStateHandles.add(state.getHandle());
if (ImpliedValueUtil.getContextAssociation(state) == ContextAssociation.ASSOC) {
seenMultiStatesMap
.computeIfAbsent(state.getDescriptorHandle(), stateClass -> new HashSet<String>())
.computeIfAbsent(state.getDescriptorHandle(), stateClass -> new HashSet<>())
.add(state.getHandle());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void testRequirementB402() throws NoTestData, IOException {

final var acceptableSequenceSeen = new AtomicInteger(0);

mdibHistorian.procesAllRemoteMdibAccess(first -> {
mdibHistorian.processAllRemoteMdibAccess(first -> {
final var vmdEntities = first.findEntitiesByType(VmdDescriptor.class);
for (var vmd : vmdEntities) {
final var descriptor = vmd.getDescriptor(VmdDescriptor.class);
Expand Down
Loading

0 comments on commit 28fe0b6

Please sign in to comment.