Skip to content

Commit

Permalink
REMReM should accept both a CONTEXT and a CAUSE links in the same eve…
Browse files Browse the repository at this point in the history
…nt. (#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.
  • Loading branch information
durga-vasaadi authored Apr 16, 2020
1 parent 3e72c6b commit 653ef63
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>2.0.4</version>
</parent>
<artifactId>eiffel-remrem-semantics</artifactId>
<version>2.0.12</version>
<version>2.0.13</version>
<packaging>jar</packaging>
<properties>
<eclipse.jgit.version>5.0.1.201806211838-r</eclipse.jgit.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ private String getErrorsList(ProcessingReport report) {
public void customValidation(JsonObject jsonObjectInput) throws EiffelValidationException {
// Links validation
Map<String, Integer> linksCountMapForEvent = new HashMap<String, Integer>();
String CAUSE_LINK = "CAUSE";
String CONTEXT_LINK = "CONTEXT";
try {
JsonArray links = jsonObjectInput.get("links").getAsJsonArray();
for (JsonElement link : links) {
Expand All @@ -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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
52 changes: 52 additions & 0 deletions src/test/resources/output/TriggeredwithCauseAndContext.json
Original file line number Diff line number Diff line change
@@ -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/[email protected]",
"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"
}
]
}

0 comments on commit 653ef63

Please sign in to comment.