diff --git a/CHANGELOG.md b/CHANGELOG.md index 201a99c3..6fd7192d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - inconsistent messaging in SDCcc logs ("No problems were found" and "Test run was invalid" one after another.) - incorrect behavior of the configuration option SDCcc.SummarizeMessageEncodingErrors - SequenceIds are now ordered by the timestamp of the first message that used them +- test for BICEPS.R5003 does not check MdDescriptionVersion and MdStateVersion anymore (see [PR 232](https://github.com/Draegerwerk/SDCcc/pull/232)) ### Removed diff --git a/sdccc/src/main/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTest.java b/sdccc/src/main/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTest.java index d8a03712..2d8af171 100644 --- a/sdccc/src/main/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTest.java +++ b/sdccc/src/main/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTest.java @@ -337,8 +337,6 @@ void testRequirementR5003() throws IOException, NoTestData { final var impliedValueMap = new InitialImpliedValue(); final var previousDescriptorVersionMap = new HashMap(); final var previousStateVersionMap = new HashMap(); - var previousMdDescriptionVersion = BigInteger.valueOf(-1); - var previousMdStateVersion = BigInteger.valueOf(-1); var previousMdibVersion = BigInteger.valueOf(-1); try (final MdibHistorian.HistorianResult history = @@ -388,32 +386,11 @@ void testRequirementR5003() throws IOException, NoTestData { previousStateVersionMap.put(stateHandle, currentStateVersion); stateVersionsSeen.incrementAndGet(); } - final var currentMdDescriptionVersion = - ImpliedValueUtil.getMdibAccessDescriptionVersion(current); - final var currentMdStateVersion = ImpliedValueUtil.getMdibAccessMdStateVersion(current); - assertTrue( - isNotDecrementedVersion(previousMdDescriptionVersion, currentMdDescriptionVersion), - String.format( - DECREMENTED_VERSION_ERROR_MESSAGE, - "MdDescription", - currentMdibVersion, - previousMdDescriptionVersion, - currentMdDescriptionVersion)); - assertTrue( - isNotDecrementedVersion(previousMdStateVersion, currentMdStateVersion), - String.format( - DECREMENTED_VERSION_ERROR_MESSAGE, - "MdState", - currentMdibVersion, - previousMdStateVersion, - currentMdStateVersion)); assertTrue( isNotDecrementedVersion(previousMdibVersion, currentMdibVersion), String.format( "The mdib version has been decremented. It was %s and is now %s.", previousMdibVersion, currentMdibVersion)); - previousMdDescriptionVersion = currentMdDescriptionVersion; - previousMdStateVersion = currentMdStateVersion; previousMdibVersion = currentMdibVersion; current = history.next(); } diff --git a/sdccc/src/main/java/com/draeger/medical/sdccc/tests/util/ImpliedValueUtil.java b/sdccc/src/main/java/com/draeger/medical/sdccc/tests/util/ImpliedValueUtil.java index 03164811..0cde48ce 100644 --- a/sdccc/src/main/java/com/draeger/medical/sdccc/tests/util/ImpliedValueUtil.java +++ b/sdccc/src/main/java/com/draeger/medical/sdccc/tests/util/ImpliedValueUtil.java @@ -11,7 +11,6 @@ import java.math.BigInteger; import java.time.Duration; import javax.annotation.Nullable; -import org.somda.sdc.biceps.common.access.MdibAccess; import org.somda.sdc.biceps.model.message.AbstractReport; import org.somda.sdc.biceps.model.message.DescriptionModificationReport; import org.somda.sdc.biceps.model.message.DescriptionModificationType; @@ -373,17 +372,6 @@ public static BigInteger getDescriptionVersion(final @Nullable MdDescription mdD return BigInteger.ZERO; } - /** - * Retrieves the description version of mdib access or the implied value. - * - * @param mdibAccess to retrieve the description version from - * @return the description version - */ - public static BigInteger getMdibAccessDescriptionVersion(final MdibAccess mdibAccess) { - final var descriptionVersion = mdibAccess.getMdDescriptionVersion(); - return descriptionVersion != null ? descriptionVersion : BigInteger.ZERO; - } - /** * Retrieves the language of an mds state or the implied value. * @@ -420,17 +408,6 @@ public static BigInteger getMdStateStateVersion(final @Nullable MdState mdState) return BigInteger.ZERO; } - /** - * Retrieves the md state version of mdib access or the implied value. - * - * @param mdibAccess to retrieve the state version from - * @return the state version - */ - public static BigInteger getMdibAccessMdStateVersion(final MdibAccess mdibAccess) { - final var stateVersion = mdibAccess.getMdStateVersion(); - return stateVersion != null ? stateVersion : BigInteger.ZERO; - } - /** * Retrieves the version of a mdib version or the implied value. * diff --git a/sdccc/src/test/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTestTest.java b/sdccc/src/test/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTestTest.java index 901271d1..c21f9c02 100644 --- a/sdccc/src/test/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTestTest.java +++ b/sdccc/src/test/java/com/draeger/medical/sdccc/tests/biceps/invariant/InvariantParticipantModelVersioningTestTest.java @@ -55,12 +55,16 @@ import java.util.List; import java.util.Objects; import java.util.concurrent.TimeoutException; +import java.util.stream.Stream; import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.opentest4j.AssertionFailedError; import org.somda.sdc.biceps.model.participant.ActivateOperationDescriptor; import org.somda.sdc.biceps.model.participant.AlertConditionDescriptor; @@ -1193,6 +1197,43 @@ public void testRequirementR5003NoTestData() { assertThrows(NoTestData.class, testClass::testRequirementR5003); } + /** + * In the mdib representation on the consumer side in sdc-ri, when processing description modifications, the values + * for the MdDescriptionVersion and MdStateVersion are set to the implied value if the description modification + * does not contain any values for them. This is the case if the versions are missing in the GetMdibResponse, + * or generally for DescriptionModificationReports. If the MdDescriptionVersion or MdStateVersion in the + * GetMdibResponse is set to a value other than the implied value, they would be set to the implied value again in the next + * DescriptionModificationReport, which would cause the test to fail. As the actual values are not communicated via + * reports, the check of the MdDescriptionVersion and MdStateVersion has been removed from the test implementation. + *

+ * This unit test ensures that a decrement of the MdDescriptionVersion or MdStateVersion does not cause the test to + * fail. + *

+ * + * @param mdDescriptionVersion the MdDescriptionVersion to set + * @param mdStateVersion the MdStateVersion to set + * @throws Exception on any exception + */ + @ParameterizedTest + @MethodSource("provideMdDescriptionVersionAndMdStateVersion") + public void testRequirementR5003TestMdDescriptionVersionAndMdStateVersion( + final @Nullable BigInteger mdDescriptionVersion, final @Nullable BigInteger mdStateVersion) + throws Exception { + final var initial = + buildMdibWithMdDescriptionAndStateVersion(SEQUENCE_ID, mdDescriptionVersion, mdStateVersion); + final var firstUpdate = buildDescriptionModificationReportWithParts( + SEQUENCE_ID, + BigInteger.valueOf(74), + buildDescriptionModificationReportPart( + DescriptionModificationType.UPT, + buildVmd(VMD_HANDLE, BigInteger.ONE, BigInteger.ONE), + buildChannel(CHANNEL_HANDLE, BigInteger.ONE, BigInteger.ONE))); + + messageStorageUtil.addInboundSecureHttpMessage(storage, initial); + messageStorageUtil.addInboundSecureHttpMessage(storage, firstUpdate); + assertDoesNotThrow(testClass::testRequirementR5003); + } + /** * Tests whether versions which are only incremented causes the test to pass. * @@ -1591,7 +1632,7 @@ public void testRequirementR5003BadDecrementStateVersion() throws Exception { } Envelope buildMdib(final @Nullable BigInteger vmdVersion, final @Nullable BigInteger mdsVersion) { - return buildMdib(MdibBuilder.DEFAULT_SEQUENCE_ID, vmdVersion, mdsVersion); + return buildMdib(SEQUENCE_ID, vmdVersion, mdsVersion); } /* @@ -1638,6 +1679,39 @@ Envelope buildMdib( ActionConstants.getResponseAction(ActionConstants.ACTION_GET_MDIB), getMdibResponse); } + private static Stream provideMdDescriptionVersionAndMdStateVersion() { + return Stream.of( + Arguments.of(BigInteger.TWO, null), + Arguments.of(null, BigInteger.TWO), + Arguments.of(BigInteger.TWO, BigInteger.TWO)); + } + + private Envelope buildMdibWithMdDescriptionAndStateVersion( + final String sequenceId, + final @Nullable BigInteger mdDescriptionVersion, + final @Nullable BigInteger mdStateVersion) { + final var mdib = mdibBuilder.buildMinimalMdib(sequenceId); + mdib.getMdDescription().setDescriptionVersion(mdDescriptionVersion); + + final var mdState = mdib.getMdState(); + mdState.setStateVersion(mdStateVersion); + + final var mdsDescriptor = mdib.getMdDescription().getMds().get(0); + mdsDescriptor.setDescriptorVersion(BigInteger.ZERO); + + final var vmd = mdibBuilder.buildVmd(VMD_HANDLE); + vmd.getLeft().setDescriptorVersion(BigInteger.ZERO); + vmd.getRight().setDescriptorVersion(BigInteger.ZERO); + mdsDescriptor.getVmd().add(vmd.getLeft()); + mdState.getState().add(vmd.getRight()); + + final var getMdibResponse = messageBuilder.buildGetMdibResponse(mdib.getSequenceId()); + getMdibResponse.setMdib(mdib); + + return messageBuilder.createSoapMessageWithBody( + ActionConstants.getResponseAction(ActionConstants.ACTION_GET_MDIB), getMdibResponse); + } + Pair buildMds( final String handle, @Nullable final BigInteger descriptorVersion,