Skip to content

Commit 59306e1

Browse files
vishnu-alapatiVishnu
andauthored
Test failures (#200)
* Fixed test failures Co-authored-by: Vishnu <vishnu.alapati@ericsson.com>
1 parent 808d848 commit 59306e1

File tree

6 files changed

+88
-14
lines changed

6 files changed

+88
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## 2.1.5
2+
- Made changes to fix the test-failures
23
- Updated eiffel-remrem-parent version from 2.0.6 to 2.0.7
34
- updated eiffel-remrem-semantics version from 2.2.1 to 2.2.2
45
- Introduced new (/message_protocols) Endpoint which returns the available message protocols list and their respective edition names.

service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ public ResponseEntity<?> generate(
120120
bodyJson = erLookup(bodyJson, failIfMultipleFound, failIfNoneFound, lookupInExternalERs, lookupLimit);
121121
MsgService msgService = getMessageService(msgProtocol);
122122
String response;
123-
if (bodyJson == null) {
124-
return new ResponseEntity<>(parser.parse(RemremGenerateServiceConstants.NO_ER),HttpStatus.SERVICE_UNAVAILABLE);
125-
}
126123
if (msgService != null) {
127124
response = msgService.generateMsg(msgType, bodyJson, isLenientEnabled(okToLeaveOutInvalidOptionalFields));
128125
JsonElement parsedResponse = parser.parse(response);
@@ -148,6 +145,11 @@ else if (e1.getMessage().contains(Integer.toString(HttpStatus.EXPECTATION_FAILED
148145
else if (e1.getMessage().contains(Integer.toString(HttpStatus.EXPECTATION_FAILED.value()))) {
149146
return new ResponseEntity<>(parser.parse(e1.getMessage()), HttpStatus.EXPECTATION_FAILED);
150147
}
148+
else if (e1.getMessage()
149+
.contains(Integer.toString(HttpStatus.SERVICE_UNAVAILABLE.value()))) {
150+
return new ResponseEntity<>(parser.parse(RemremGenerateServiceConstants.NO_ER),
151+
HttpStatus.SERVICE_UNAVAILABLE);
152+
}
151153
else {
152154
return new ResponseEntity<>(parser.parse(e1.getMessage()), HttpStatus.UNPROCESSABLE_ENTITY);
153155
}
@@ -184,7 +186,10 @@ private JsonObject erLookup(final JsonObject bodyJson, Boolean failIfMultipleFou
184186
}
185187
} catch (Exception e) {
186188
log.error("unable to connect configured Event Repository URL" + e.getMessage());
187-
return null;
189+
response = null;
190+
}
191+
if (response == null) {
192+
throw new REMGenerateException(RemremGenerateServiceConstants.NO_ER);
188193
}
189194
String responseBody = response.getBody();
190195
ids = ERLookupController.getIdsfromResponseBody(responseBody);

service/src/test/java/com/ericsson/eiffel/remrem/generate/integrationtest/EiffelRemremControllerIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public class EiffelRemremControllerIT {
5252

5353
@Value("${local.server.port}")
5454
private int port;
55-
private String artifactPublishedFileName = "ArtifactPublished.json";
56-
private String artifactPublishedBody;
55+
private String artifactCreatedFileName = "ArtifactCreated.json";
56+
private String artifactCreatedBody;
5757

5858
private String activityFinishedFileName = "ActivityFinished.json";
5959
private String activityFinishedBody;
@@ -73,8 +73,8 @@ public class EiffelRemremControllerIT {
7373
@Before
7474
public void setUp() throws IOException {
7575
RestAssured.port = port;
76-
artifactPublishedBody = loadEventBody(artifactPublishedFileName);
7776
activityFinishedBody = loadEventBody(activityFinishedFileName);
77+
artifactCreatedBody = loadEventBody(artifactCreatedFileName);
7878

7979
if (version == null) {
8080
version = getMessagingVersion();
@@ -123,24 +123,24 @@ public static String getMessagingVersion() {
123123
public void testUnauthenticatedNotAllowed() throws Exception {
124124
given()
125125
.contentType("application/json")
126-
.body(artifactPublishedBody)
126+
.body(artifactCreatedBody)
127127
.when()
128128
.post("/eiffelsemantics?msgType=eiffelartifactpublished")
129129
.then()
130130
.statusCode(HttpStatus.SC_UNAUTHORIZED);
131131
}
132132

133133
@Test
134-
public void testSendArtifactPublished() throws Exception {
134+
public void testSendArtifactCreated() throws Exception {
135135
given()
136136
.header("Authorization", credentials)
137137
.contentType("application/json")
138-
.body(artifactPublishedBody)
138+
.body(artifactCreatedBody)
139139
.when()
140-
.post("/eiffelsemantics?msgType=EiffelArtifactPublishedEvent")
140+
.post("/eiffelsemantics?msgType=EiffelArtifactCreatedEvent")
141141
.then()
142142
.statusCode(HttpStatus.SC_OK)
143-
.body("meta.type", Matchers.is("EiffelArtifactPublishedEvent"))
143+
.body("meta.type", Matchers.is("EiffelArtifactCreatedEvent"))
144144
.body("meta.version", Matchers.is(version));
145145
}
146146

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"msgParams": {
3+
"meta": {
4+
"type": "EiffelArtifactCreatedEvent",
5+
"version": "3.0.0",
6+
"tags": [
7+
"tag1",
8+
"tag2"
9+
],
10+
"source": {
11+
"domainId": "domainID",
12+
"host": "host",
13+
"name": "name",
14+
"uri": "http:\/\/java.sun.com\/j2se\/1.3\/",
15+
"serializer":"pkg:maven"
16+
},
17+
"security": {
18+
"authorIdentity": "test",
19+
"encryptedDigest": "sample"
20+
}
21+
}
22+
},
23+
"eventParams": {
24+
"data": {
25+
"gav": {
26+
"groupId": "G",
27+
"artifactId": "A",
28+
"version": "V"
29+
},
30+
"fileInformation": [{
31+
"name":"name"
32+
}],
33+
"buildCommand": "trigger",
34+
"requiresImplementation": "NONE",
35+
"name": "event",
36+
"dependsOn": [
37+
],
38+
"implement": [
39+
],
40+
"identity":"pkg:abc",
41+
"customData": [{
42+
"key": "firstLog",
43+
"value": "http:\/\/myHost.com\/firstLog"
44+
},
45+
{
46+
"key": "otherLog",
47+
"value": "http:\/\/myHost.com\/firstLog33"
48+
}
49+
]
50+
},
51+
"links": [{
52+
"type": "CAUSE",
53+
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee1"
54+
},
55+
{
56+
"type": "PREVIOUS_VERSION",
57+
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee2"
58+
},
59+
{
60+
"type": "COMPOSITION",
61+
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee1"
62+
},
63+
{
64+
"type": "ENVIRONMENT",
65+
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee3"
66+
}]
67+
}
68+
}

service/src/test/resources/ArtifactPublished.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
}
3636
]
3737
}
38-
}
38+
}

service/src/test/resources/ErlookupArtifactPublishedInput.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
}
4040
]
4141
}
42-
}
42+
}

0 commit comments

Comments
 (0)