Skip to content

Commit 653ef63

Browse files
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.
1 parent 3e72c6b commit 653ef63

File tree

5 files changed

+73
-8
lines changed

5 files changed

+73
-8
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.13
2+
- Removed the validation of REMReM should not accept both a CAUSE and a CONTEXT link types in the same event.
3+
14
## 2.0.12
25
- Added link types PARTIALLY_RESOLVED_ISSUE, RESOLVED_ISSUE and DERESOLVED_ISSUE in EiffelSourceChangeCreatedEvent.
36

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<version>2.0.4</version>
88
</parent>
99
<artifactId>eiffel-remrem-semantics</artifactId>
10-
<version>2.0.12</version>
10+
<version>2.0.13</version>
1111
<packaging>jar</packaging>
1212
<properties>
1313
<eclipse.jgit.version>5.0.1.201806211838-r</eclipse.jgit.version>

src/main/java/com/ericsson/eiffel/remrem/semantics/validator/EiffelValidator.java

-6
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ private String getErrorsList(ProcessingReport report) {
116116
public void customValidation(JsonObject jsonObjectInput) throws EiffelValidationException {
117117
// Links validation
118118
Map<String, Integer> linksCountMapForEvent = new HashMap<String, Integer>();
119-
String CAUSE_LINK = "CAUSE";
120-
String CONTEXT_LINK = "CONTEXT";
121119
try {
122120
JsonArray links = jsonObjectInput.get("links").getAsJsonArray();
123121
for (JsonElement link : links) {
@@ -141,10 +139,6 @@ public void customValidation(JsonObject jsonObjectInput) throws EiffelValidation
141139
}
142140
linksSet.remove(requiredLinkType);
143141
}
144-
if (linksCountMapForEvent.containsKey(CAUSE_LINK) && linksCountMapForEvent.containsKey(CONTEXT_LINK)) {
145-
throw new EiffelValidationException(
146-
"Link types " + CAUSE_LINK + " and " + CONTEXT_LINK + " should not be in one event");
147-
}
148142
for (String optionalLinkType : optionalLinkTypes) {
149143
Integer count = linksCountMapForEvent.get(optionalLinkType);
150144
if (count != null && (count > 1 && !LinkType.valueOf(optionalLinkType).isMultipleAllowed())) {

src/test/java/com/ericsson/eiffel/remrem/semantics/ValidationTest.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,21 @@ public void TestInvalidActivityFinishedOutput() throws Exception {
6363

6464
}
6565

66-
66+
@Test
67+
public void TestEventwithCauseAndContextLinkTypes() throws Exception {
68+
try {
69+
File file = new File("output/TriggeredwithCauseAndContext.json");
70+
if (file.exists()) {
71+
JsonObject object = parser.parse(new FileReader(file)).getAsJsonObject();
72+
String msgType = object.get("meta").getAsJsonObject().get("type").getAsString();
73+
EiffelValidator validator = EiffelOutputValidatorFactory
74+
.getEiffelValidator(EiffelEventType.fromString(msgType));
75+
validator.validate(object);
76+
validator.customValidation(object);
77+
}
78+
} catch (Exception e) {
79+
e.printStackTrace();
80+
Assert.assertFalse(true);
81+
}
82+
}
6783
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"meta": {
3+
"id": "2dd2d13f-e3e5-4fac-80e3-ef4537985009",
4+
"type": "EiffelActivityTriggeredEvent",
5+
"version": "4.0.0",
6+
"time": 1554389013770,
7+
"tags": ["product_development","product_feature1"],
8+
"source": {
9+
"domainId": "eiffeltest",
10+
"host": "localhost",
11+
"name": "LOCALHOST",
12+
"serializer": "pkg:maven/com.github.eiffel-community/[email protected]",
13+
"uri": "https://localhost:8080/jenkins/job"
14+
}
15+
},
16+
"data": {
17+
"name": "ActivityTrigger",
18+
"categories": [
19+
"First",
20+
"second"
21+
],
22+
"triggers": [
23+
{
24+
"type": "MANUAL",
25+
"description": "Started by user anonymous"
26+
},
27+
{
28+
"type": "SOURCE_CHANGE",
29+
"description": "Change"
30+
}
31+
],
32+
"customData": [
33+
{
34+
"key": "EIFFERVERSION",
35+
"value": "eiffel2.0"
36+
},
37+
{
38+
"key": "FLOWCONTEXT",
39+
"value": "master"
40+
}
41+
]
42+
},
43+
"links": [
44+
{
45+
"type": "CAUSE",
46+
"target": "e269b37d-17a1-4a10-aafb-c108735ee51f"
47+
}, {
48+
"type": "CONTEXT",
49+
"target": "e269b37d-17a1-4a10-aafb-c108735ee52e"
50+
}
51+
]
52+
}

0 commit comments

Comments
 (0)