From 653ef632c6925625759e43b225220a24abc0c798 Mon Sep 17 00:00:00 2001 From: zvsddrg <48016013+zvsddrg@users.noreply.github.com> Date: Thu, 16 Apr 2020 19:14:42 +0530 Subject: [PATCH] REMReM should accept both a CONTEXT and a CAUSE links in the same event. (#126) * REMReM should accept both a CONTEXT and a CAUSE links in the same event. * changed discription message in CHANGELOG.md file. * Add testcase for the changes. --- CHANGELOG.md | 3 ++ pom.xml | 2 +- .../semantics/validator/EiffelValidator.java | 6 --- .../remrem/semantics/ValidationTest.java | 18 ++++++- .../output/TriggeredwithCauseAndContext.json | 52 +++++++++++++++++++ 5 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/output/TriggeredwithCauseAndContext.json diff --git a/CHANGELOG.md b/CHANGELOG.md index d18ce1a9..77c40608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.0.13 +- Removed the validation of REMReM should not accept both a CAUSE and a CONTEXT link types in the same event. + ## 2.0.12 - Added link types PARTIALLY_RESOLVED_ISSUE, RESOLVED_ISSUE and DERESOLVED_ISSUE in EiffelSourceChangeCreatedEvent. diff --git a/pom.xml b/pom.xml index 380ba2a8..19ac1a7a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 2.0.4 eiffel-remrem-semantics - 2.0.12 + 2.0.13 jar 5.0.1.201806211838-r diff --git a/src/main/java/com/ericsson/eiffel/remrem/semantics/validator/EiffelValidator.java b/src/main/java/com/ericsson/eiffel/remrem/semantics/validator/EiffelValidator.java index 701501ff..664ac4c3 100644 --- a/src/main/java/com/ericsson/eiffel/remrem/semantics/validator/EiffelValidator.java +++ b/src/main/java/com/ericsson/eiffel/remrem/semantics/validator/EiffelValidator.java @@ -116,8 +116,6 @@ private String getErrorsList(ProcessingReport report) { public void customValidation(JsonObject jsonObjectInput) throws EiffelValidationException { // Links validation Map linksCountMapForEvent = new HashMap(); - String CAUSE_LINK = "CAUSE"; - String CONTEXT_LINK = "CONTEXT"; try { JsonArray links = jsonObjectInput.get("links").getAsJsonArray(); for (JsonElement link : links) { @@ -141,10 +139,6 @@ public void customValidation(JsonObject jsonObjectInput) throws EiffelValidation } linksSet.remove(requiredLinkType); } - if (linksCountMapForEvent.containsKey(CAUSE_LINK) && linksCountMapForEvent.containsKey(CONTEXT_LINK)) { - throw new EiffelValidationException( - "Link types " + CAUSE_LINK + " and " + CONTEXT_LINK + " should not be in one event"); - } for (String optionalLinkType : optionalLinkTypes) { Integer count = linksCountMapForEvent.get(optionalLinkType); if (count != null && (count > 1 && !LinkType.valueOf(optionalLinkType).isMultipleAllowed())) { diff --git a/src/test/java/com/ericsson/eiffel/remrem/semantics/ValidationTest.java b/src/test/java/com/ericsson/eiffel/remrem/semantics/ValidationTest.java index c77264cd..d952cf62 100644 --- a/src/test/java/com/ericsson/eiffel/remrem/semantics/ValidationTest.java +++ b/src/test/java/com/ericsson/eiffel/remrem/semantics/ValidationTest.java @@ -63,5 +63,21 @@ public void TestInvalidActivityFinishedOutput() throws Exception { } - + @Test + public void TestEventwithCauseAndContextLinkTypes() throws Exception { + try { + File file = new File("output/TriggeredwithCauseAndContext.json"); + if (file.exists()) { + JsonObject object = parser.parse(new FileReader(file)).getAsJsonObject(); + String msgType = object.get("meta").getAsJsonObject().get("type").getAsString(); + EiffelValidator validator = EiffelOutputValidatorFactory + .getEiffelValidator(EiffelEventType.fromString(msgType)); + validator.validate(object); + validator.customValidation(object); + } + } catch (Exception e) { + e.printStackTrace(); + Assert.assertFalse(true); + } + } } \ No newline at end of file diff --git a/src/test/resources/output/TriggeredwithCauseAndContext.json b/src/test/resources/output/TriggeredwithCauseAndContext.json new file mode 100644 index 00000000..7a2448ea --- /dev/null +++ b/src/test/resources/output/TriggeredwithCauseAndContext.json @@ -0,0 +1,52 @@ +{ + "meta": { + "id": "2dd2d13f-e3e5-4fac-80e3-ef4537985009", + "type": "EiffelActivityTriggeredEvent", + "version": "4.0.0", + "time": 1554389013770, + "tags": ["product_development","product_feature1"], + "source": { + "domainId": "eiffeltest", + "host": "localhost", + "name": "LOCALHOST", + "serializer": "pkg:maven/com.github.eiffel-community/eiffel-remrem-semantics@2.0.2", + "uri": "https://localhost:8080/jenkins/job" + } + }, + "data": { + "name": "ActivityTrigger", + "categories": [ + "First", + "second" + ], + "triggers": [ + { + "type": "MANUAL", + "description": "Started by user anonymous" + }, + { + "type": "SOURCE_CHANGE", + "description": "Change" + } + ], + "customData": [ + { + "key": "EIFFERVERSION", + "value": "eiffel2.0" + }, + { + "key": "FLOWCONTEXT", + "value": "master" + } + ] + }, + "links": [ + { + "type": "CAUSE", + "target": "e269b37d-17a1-4a10-aafb-c108735ee51f" + }, { + "type": "CONTEXT", + "target": "e269b37d-17a1-4a10-aafb-c108735ee52e" + } + ] +} \ No newline at end of file