Skip to content

Commit

Permalink
Test failures (#200)
Browse files Browse the repository at this point in the history
* Fixed test failures

Co-authored-by: Vishnu <[email protected]>
  • Loading branch information
vishnu-alapati and Vishnu authored Jun 23, 2022
1 parent 808d848 commit 59306e1
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 2.1.5
- Made changes to fix the test-failures
- Updated eiffel-remrem-parent version from 2.0.6 to 2.0.7
- updated eiffel-remrem-semantics version from 2.2.1 to 2.2.2
- Introduced new (/message_protocols) Endpoint which returns the available message protocols list and their respective edition names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ public ResponseEntity<?> generate(
bodyJson = erLookup(bodyJson, failIfMultipleFound, failIfNoneFound, lookupInExternalERs, lookupLimit);
MsgService msgService = getMessageService(msgProtocol);
String response;
if (bodyJson == null) {
return new ResponseEntity<>(parser.parse(RemremGenerateServiceConstants.NO_ER),HttpStatus.SERVICE_UNAVAILABLE);
}
if (msgService != null) {
response = msgService.generateMsg(msgType, bodyJson, isLenientEnabled(okToLeaveOutInvalidOptionalFields));
JsonElement parsedResponse = parser.parse(response);
Expand All @@ -148,6 +145,11 @@ else if (e1.getMessage().contains(Integer.toString(HttpStatus.EXPECTATION_FAILED
else if (e1.getMessage().contains(Integer.toString(HttpStatus.EXPECTATION_FAILED.value()))) {
return new ResponseEntity<>(parser.parse(e1.getMessage()), HttpStatus.EXPECTATION_FAILED);
}
else if (e1.getMessage()
.contains(Integer.toString(HttpStatus.SERVICE_UNAVAILABLE.value()))) {
return new ResponseEntity<>(parser.parse(RemremGenerateServiceConstants.NO_ER),
HttpStatus.SERVICE_UNAVAILABLE);
}
else {
return new ResponseEntity<>(parser.parse(e1.getMessage()), HttpStatus.UNPROCESSABLE_ENTITY);
}
Expand Down Expand Up @@ -184,7 +186,10 @@ private JsonObject erLookup(final JsonObject bodyJson, Boolean failIfMultipleFou
}
} catch (Exception e) {
log.error("unable to connect configured Event Repository URL" + e.getMessage());
return null;
response = null;
}
if (response == null) {
throw new REMGenerateException(RemremGenerateServiceConstants.NO_ER);
}
String responseBody = response.getBody();
ids = ERLookupController.getIdsfromResponseBody(responseBody);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class EiffelRemremControllerIT {

@Value("${local.server.port}")
private int port;
private String artifactPublishedFileName = "ArtifactPublished.json";
private String artifactPublishedBody;
private String artifactCreatedFileName = "ArtifactCreated.json";
private String artifactCreatedBody;

private String activityFinishedFileName = "ActivityFinished.json";
private String activityFinishedBody;
Expand All @@ -73,8 +73,8 @@ public class EiffelRemremControllerIT {
@Before
public void setUp() throws IOException {
RestAssured.port = port;
artifactPublishedBody = loadEventBody(artifactPublishedFileName);
activityFinishedBody = loadEventBody(activityFinishedFileName);
artifactCreatedBody = loadEventBody(artifactCreatedFileName);

if (version == null) {
version = getMessagingVersion();
Expand Down Expand Up @@ -123,24 +123,24 @@ public static String getMessagingVersion() {
public void testUnauthenticatedNotAllowed() throws Exception {
given()
.contentType("application/json")
.body(artifactPublishedBody)
.body(artifactCreatedBody)
.when()
.post("/eiffelsemantics?msgType=eiffelartifactpublished")
.then()
.statusCode(HttpStatus.SC_UNAUTHORIZED);
}

@Test
public void testSendArtifactPublished() throws Exception {
public void testSendArtifactCreated() throws Exception {
given()
.header("Authorization", credentials)
.contentType("application/json")
.body(artifactPublishedBody)
.body(artifactCreatedBody)
.when()
.post("/eiffelsemantics?msgType=EiffelArtifactPublishedEvent")
.post("/eiffelsemantics?msgType=EiffelArtifactCreatedEvent")
.then()
.statusCode(HttpStatus.SC_OK)
.body("meta.type", Matchers.is("EiffelArtifactPublishedEvent"))
.body("meta.type", Matchers.is("EiffelArtifactCreatedEvent"))
.body("meta.version", Matchers.is(version));
}

Expand Down
68 changes: 68 additions & 0 deletions service/src/test/resources/ArtifactCreated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"msgParams": {
"meta": {
"type": "EiffelArtifactCreatedEvent",
"version": "3.0.0",
"tags": [
"tag1",
"tag2"
],
"source": {
"domainId": "domainID",
"host": "host",
"name": "name",
"uri": "http:\/\/java.sun.com\/j2se\/1.3\/",
"serializer":"pkg:maven"
},
"security": {
"authorIdentity": "test",
"encryptedDigest": "sample"
}
}
},
"eventParams": {
"data": {
"gav": {
"groupId": "G",
"artifactId": "A",
"version": "V"
},
"fileInformation": [{
"name":"name"
}],
"buildCommand": "trigger",
"requiresImplementation": "NONE",
"name": "event",
"dependsOn": [
],
"implement": [
],
"identity":"pkg:abc",
"customData": [{
"key": "firstLog",
"value": "http:\/\/myHost.com\/firstLog"
},
{
"key": "otherLog",
"value": "http:\/\/myHost.com\/firstLog33"
}
]
},
"links": [{
"type": "CAUSE",
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee1"
},
{
"type": "PREVIOUS_VERSION",
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee2"
},
{
"type": "COMPOSITION",
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee1"
},
{
"type": "ENVIRONMENT",
"target": "aaaaaaaa-bbbb-5ccc-8ddd-eeeeeeeeeee3"
}]
}
}
2 changes: 1 addition & 1 deletion service/src/test/resources/ArtifactPublished.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
}
]
}
}
}

0 comments on commit 59306e1

Please sign in to comment.