From ef0a4a9a3db0047a3e55cd8eeecd4c79e2445eda Mon Sep 17 00:00:00 2001 From: SantoshNC68 Date: Wed, 1 Feb 2017 17:26:39 +0530 Subject: [PATCH] Added latest version for semantics in build.gradle (#54) * Added latest version for semantics in build.gradle * Changed test cases to match semantics version * changed the URI pattern --- CHANGELOG.md | 5 +++ build.gradle | 4 +- .../remrem/generate/EiffelSemanticsCli.java | 9 ++-- .../generate/EiffelSemanticsController.java | 10 ++--- .../resources/ActivityFinished.json | 44 +++++++++++++------ .../resources/ArtifactPublished.json | 43 ++++++++++++------ .../eiffel/remrem/generate/cli/CLI.java | 2 +- .../remrem/generate/cli/CliUnitTests.java | 10 ++--- 8 files changed, 83 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4d6a217..7ce0eaaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.7.5 +- upgraded semantics version in build.gradle to support all + EiffelEvents in the eiffel repo from topic-drop4 branch +- Changed json inputs for test cases + ## 0.7.4 - Fixed domain property injection in SecurityConfig diff --git a/build.gradle b/build.gradle index eaa7a1d9..93403420 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'war' war { baseName = 'remrem-generate' - version = '0.7.4' + version = '0.7.5' } @@ -140,7 +140,7 @@ dependencies { //Injectable Message Library and its Implementation compile ('com.github.Ericsson:eiffel-remrem-shared:0.3.0') - compile ('com.github.Ericsson:eiffel-remrem-semantics:0.1.9') + compile ('com.github.Ericsson:eiffel-remrem-semantics:0.2.0') compile ('com.github.Ericsson:eiffel-remrem-protocol-interface:0.0.1') //commons CLI diff --git a/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsCli.java b/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsCli.java index 2aa263a3..0d461778 100644 --- a/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsCli.java +++ b/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsCli.java @@ -18,6 +18,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.net.URL; import static org.junit.Assert.assertTrue; @@ -61,7 +62,9 @@ public void tearDown() { @Test public void testWrongMessageTypeFail() throws Exception { - File file = new File(getClass().getClassLoader().getResource(artifactPublishedFileName).getFile()); + URL url = getClass().getClassLoader().getResource(artifactPublishedFileName); + String path = url.getPath().replace("%20"," "); + File file = new File(path); String filePath = file.getAbsolutePath(); String[] args = {"-t", "artifactpublishednone", "-f", filePath}; @@ -75,7 +78,7 @@ public void testWrongMessageTypeFail() throws Exception { @Test public void testIncompleteMessageContentFail() throws Exception { String jsonContent = "{\"msgParams\": {\"meta\":{\"fakseContent\":\"yes\"}}, \"eventParams\": {\"falseKey\" : \"none\"}}"; - String[] args = {"-t", "eiffelartifactpublished", "-json", jsonContent}; + String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", jsonContent}; CLIOptions.parse(args); cli.run(args); String message = bytes.toString(); @@ -86,7 +89,7 @@ public void testIncompleteMessageContentFail() throws Exception { @Test public void testMalformedJsonFail() throws Exception { String jsonContent = "{\"someKey\":\"someValue\"}"; - String[] args = {"-t", "eiffelartifactpublished", "-json", jsonContent}; + String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", jsonContent}; CLIOptions.parse(args); cli.run(args); String message = bytes.toString(); diff --git a/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsController.java b/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsController.java index 62d573af..b7b03350 100644 --- a/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsController.java +++ b/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsController.java @@ -41,7 +41,7 @@ public class EiffelSemanticsController { static String activityFinishedFileName = "ActivityFinished.json"; static String activityFinishedBody; - static String version = null; + static String version = "1.0.0"; private String credentials = "Basic " + Base64.getEncoder().encodeToString("user:secret".getBytes()); @@ -111,10 +111,10 @@ public void testUnauthenticatedNotAllowed() throws Exception { .contentType("application/json") .body(artifactPublishedBody) .when() - .post("/eiffelsemantics?msgType=eiffelartifactpublished") + .post("/eiffelsemantics?msgType=EiffelArtifactPublishedEvent") .then() .statusCode(HttpStatus.SC_OK) - .body("meta.type", Matchers.is("eiffelartifactpublished")) + .body("meta.type", Matchers.is("EiffelArtifactPublishedEvent")) .body("meta.version", Matchers.is(version)); } @@ -124,10 +124,10 @@ public void testUnauthenticatedNotAllowed() throws Exception { .contentType("application/json") .body(activityFinishedBody) .when() - .post("/eiffelsemantics?msgType=eiffelactivityfinished") + .post("/eiffelsemantics?msgType=EiffelActivityFinishedEvent") .then() .statusCode(HttpStatus.SC_OK) - .body("meta.type", Matchers.is("eiffelactivityfinished")) + .body("meta.type", Matchers.is("EiffelActivityFinishedEvent")) .body("meta.version", Matchers.is(version)); } diff --git a/src/integration-test/resources/ActivityFinished.json b/src/integration-test/resources/ActivityFinished.json index c9ba2cde..54734806 100644 --- a/src/integration-test/resources/ActivityFinished.json +++ b/src/integration-test/resources/ActivityFinished.json @@ -1,12 +1,25 @@ -{"msgParams": { - "meta": { - "type": "EiffelActivityFinishedEvent", - "version": "1.0", - "time": 1234567890, - "domainId": "example.domain", - "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee0" - } -}, +{ + "msgParams": { + "meta": { + "type": "EiffelActivityFinishedEvent", + "version": "1.0.0", + "tags": [ + "tag1", + "tag2" + ], + "source": { + "domainId": "domainID", + "host": "host", + "name": "name", + "uri": "http://java.sun.com/j2se/1.3/", + "serializer": { + "groupId": "G", + "artifactId": "A", + "version": "V" + } + } + } + }, "eventParams": { "data": { "outcome": { @@ -20,12 +33,15 @@ }, { "name": "otherLog", - "uri": "isbn:0-486-27557-4" + "uri": "http://myHost.com/firstLog33" } ] }, - "links": { - "activityExecution": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee1" - } + "links": [ + { + "type": "LinkTargetType", + "target": "LinkTarget" + } + ] } -} +} \ No newline at end of file diff --git a/src/integration-test/resources/ArtifactPublished.json b/src/integration-test/resources/ArtifactPublished.json index ca10bac2..6aeff463 100644 --- a/src/integration-test/resources/ArtifactPublished.json +++ b/src/integration-test/resources/ArtifactPublished.json @@ -1,12 +1,25 @@ -{"msgParams": { - "meta": { - "type": "EiffelArtifactPublishedEvent", - "version": "1.0", - "time": 1234567890, - "domainId": "example.domain", - "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee0" - } -}, +{ + "msgParams": { + "meta": { + "type": "EiffelArtifactPublishedEvent", + "version": "1.0.0", + "tags": [ + "tag1", + "tag2" + ], + "source": { + "domainId": "example.domain", + "host": "host", + "name": "name", + "uri": "http://java.sun.com/j2se/1.3/", + "serializer": { + "groupId": "G", + "artifactId": "A", + "version": "V" + } + } + } + }, "eventParams": { "data": { "locations": [ @@ -20,9 +33,11 @@ } ] }, - "links": { - "context": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee1", - "artifact": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee2" - } + "links": [ + { + "type": "LinkTargetType", + "target": "LinkTarget" + } + ] } -} +} \ No newline at end of file diff --git a/src/main/java/com/ericsson/eiffel/remrem/generate/cli/CLI.java b/src/main/java/com/ericsson/eiffel/remrem/generate/cli/CLI.java index ec41e2eb..2adb0f6d 100644 --- a/src/main/java/com/ericsson/eiffel/remrem/generate/cli/CLI.java +++ b/src/main/java/com/ericsson/eiffel/remrem/generate/cli/CLI.java @@ -179,7 +179,7 @@ private void handleJsonString(String jsonString, CommandLine commandLine) { } private String handleMsgTypeArgs(CommandLine commandLine) { - String msgType = commandLine.getOptionValue("t").toLowerCase(Locale.ROOT); + String msgType = commandLine.getOptionValue("t"); Pattern p = Pattern.compile("(.*)event"); Matcher m = p.matcher(msgType); if (m.matches()) { diff --git a/src/test/java/com/ericsson/eiffel/remrem/generate/cli/CliUnitTests.java b/src/test/java/com/ericsson/eiffel/remrem/generate/cli/CliUnitTests.java index e4d6a21e..9849d0bb 100644 --- a/src/test/java/com/ericsson/eiffel/remrem/generate/cli/CliUnitTests.java +++ b/src/test/java/com/ericsson/eiffel/remrem/generate/cli/CliUnitTests.java @@ -60,7 +60,7 @@ public void tearDown() { @Test public void testHandleFileArgsFail() throws Exception { - String[] args = {"-t", "artifactpublished", "-f", "filename"}; + String[] args = {"-t", "EiffelArtifactPublishedEvent", "-f", "filename"}; CLIOptions.parse(args); cli.run(args); int code = CLIExitCodes.CLI_READ_FILE_FAILED; @@ -74,7 +74,7 @@ public void testHandleFileArgsPass() throws Exception { File file = new File(path); String filePath = file.getAbsolutePath(); - String[] args = {"-t", "artifactpublished", "-f", filePath}; + String[] args = {"-t", "EiffelArtifactPublishedEvent", "-f", filePath}; CLIOptions.parse(args); cli.run(args); assertTrue(CLIOptions.getErrorCodes().isEmpty()); @@ -82,7 +82,7 @@ public void testHandleFileArgsPass() throws Exception { @Test public void testHandleJsonArgsPass() throws Exception { - String[] args = {"-t", "artifactpublished", "-json", "{someKey:someValue}"}; + String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", "{someKey:someValue}"}; CLIOptions.parse(args); cli.run(args); assertTrue(CLIOptions.getErrorCodes().isEmpty()); @@ -90,7 +90,7 @@ public void testHandleJsonArgsPass() throws Exception { @Test public void testHandleJsonArgsFail() throws Exception { - String[] args = {"-t", "artifactpublished", "-json", "filename"}; + String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", "filename"}; CLIOptions.parse(args); cli.run(args); int code = CLIExitCodes.HANDLE_JSON_STRING_FAILED; @@ -99,7 +99,7 @@ public void testHandleJsonArgsFail() throws Exception { @Test public void testHandleMsgTypeEventArgsPass() throws Exception { - String[] args = {"-t", "artiFactPublishedevent", "-json", "{someKey:someValue}"}; + String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", "{someKey:someValue}"}; CLIOptions.parse(args); cli.run(args); assertTrue(CLIOptions.getErrorCodes().isEmpty());