From 94b51c73b499978aaddbb115de2b0f16f2d4db96 Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Thu, 31 Oct 2019 11:59:25 +0200 Subject: assert that InvocationId is unique in API tests Issue-ID: VID-253 Change-Id: I8bb4c752a9609d5b5a4c649befb7344a800b00b5 Signed-off-by: Eylon Malin --- .../src/test/java/org/onap/vid/more/LoggerFormatTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vid-automation/src/test/java/org/onap') diff --git a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java index 597851086..7f2d48469 100644 --- a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java +++ b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java @@ -7,6 +7,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsInRelativeOrder; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThanOrEqualTo; @@ -18,6 +19,8 @@ import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; @@ -143,12 +146,16 @@ public class LoggerFormatTest extends BaseApiTest { assertThat("X-ONAP-PartnerName", request.headers.get("X-ONAP-PartnerName"), contains("VID.VID")); }); + List allInvocationIds = new LinkedList<>(); + underTestRequests.forEach(request->{ List invocationIds = request.headers.get("X-InvocationID"); assertThat(invocationIds, hasSize(1)); String invocationId = invocationIds.get(0); + allInvocationIds.add(invocationId); + assertThat("request id and invocation id must be found in exactly two rows", logLines, containsInRelativeOrder( @@ -162,6 +169,9 @@ public class LoggerFormatTest extends BaseApiTest { containsString("InvokeReturn")) )); }); + //make sure no InvocationId is repeated twice + assertThat("expect all InvocationIds to be unique", + allInvocationIds, containsInAnyOrder(new HashSet<>(allInvocationIds).toArray())); } private JsonNode getCheckerResults(String logtype, String logLines) { -- cgit 1.2.3-korg