Skip to content

Commit 3e4f983

Browse files
author
SantoshNC68
authored
Added status codes to the output in Remrem generate service (#60)
* Added status codes to the output in Remrem generate service * Added changes for code review * Added changes for Review comments * Added changes for Remrem-Semantics latest version
1 parent 59e6e25 commit 3e4f983

File tree

14 files changed

+122
-64
lines changed

14 files changed

+122
-64
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.7.8
2+
- Added HttpStatus codes for generated ouput
3+
14
## 0.7.7
25
- Changed the project structure to build seperate
36
binaries for CLI and Service.

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ repositories {
1818
maven { url "https://jitpack.io" }
1919
}
2020

21+
22+
//Adding dependencies and sub projects common build script
2123
subprojects {
2224
buildscript {
2325
repositories {
@@ -38,7 +40,7 @@ subprojects {
3840
targetCompatibility = 1.8
3941

4042
//Latest version for generate
41-
version = "0.7.7"
43+
version = "0.7.8"
4244

4345
repositories {
4446
mavenCentral()
@@ -48,7 +50,7 @@ subprojects {
4850
dependencies {
4951
//Injectable Message Library and its Implementation
5052
compile ('com.github.Ericsson:eiffel-remrem-shared:0.3.0')
51-
compile ('com.github.Ericsson:eiffel-remrem-semantics:0.2.0')
53+
compile ('com.github.Ericsson:eiffel-remrem-semantics:0.2.3')
5254
compile ('com.github.Ericsson:eiffel-remrem-protocol-interface:0.0.1')
5355

5456
//Authentication

cli/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//Plugins used for CLI
12
plugins{
23
id 'java'
34
id 'maven'
@@ -63,6 +64,7 @@ apply plugin: 'spring-boot'
6364
apply plugin: 'java'
6465
apply plugin: 'eclipse'
6566

67+
//this is used to build the generate-cli binary
6668
jar{
6769
baseName = 'generate-cli'
6870
manifest {
@@ -92,15 +94,13 @@ repositories {
9294
mavenCentral()
9395
}
9496

97+
//Dependencies for remrem-generate-cli
9598
dependencies {
9699
compile 'org.slf4j:slf4j-api:1.7.13'
97100

98101
//commons CLI
99102
compile 'commons-cli:commons-cli:1.3.1'
100-
101-
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
102103
compile 'javax.servlet:javax.servlet-api:3.0.1'
103-
104104
// Will be used to package contents of third party libs
105105
runtime fileTree(dir: 'libs', include: '*.jar')
106106
}

cli/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsCli.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testWrongMessageTypeFail() throws Exception {
7474
@Test
7575
public void testIncompleteMessageContentFail() throws Exception {
7676
String jsonContent = "{\"msgParams\": {\"meta\":{\"fakseContent\":\"yes\"}}, \"eventParams\": {\"falseKey\" : \"none\"}}";
77-
String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", jsonContent};
77+
String[] args = {"-t", "eiffelartifactpublished", "-json", jsonContent};
7878
CLIOptions.parse(args);
7979
cli.main(args);
8080
String message = bytes.toString();
@@ -85,7 +85,7 @@ public void testIncompleteMessageContentFail() throws Exception {
8585
@Test
8686
public void testMalformedJsonFail() throws Exception {
8787
String jsonContent = "{\"someKey\":\"someValue\"}";
88-
String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", jsonContent};
88+
String[] args = {"-t", "eiffelactivityfinished", "-json", jsonContent};
8989
CLIOptions.parse(args);
9090
cli.main(args);
9191
String message = bytes.toString();

cli/src/main/java/com/ericsson/eiffel/remrem/generate/cli/CLI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.nio.file.Files;
88
import java.nio.file.Paths;
99
import java.util.List;
10+
import java.util.Locale;
1011
import java.util.regex.Matcher;
1112
import java.util.regex.Pattern;
1213

@@ -178,7 +179,7 @@ private void handleJsonString(String jsonString, CommandLine commandLine) {
178179
}
179180

180181
private String handleMsgTypeArgs(CommandLine commandLine) {
181-
String msgType = commandLine.getOptionValue("t");
182+
String msgType = commandLine.getOptionValue("t").toLowerCase(Locale.ROOT);
182183
Pattern p = Pattern.compile("(.*)event");
183184
Matcher m = p.matcher(msgType);
184185
if (m.matches()) {

cli/src/test/java/com/ericsson/eiffel/remrem/generate/cli/CliUnitTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void tearDown() {
5757

5858
@Test
5959
public void testHandleFileArgsFail() throws Exception {
60-
String[] args = {"-t", "EiffelArtifactPublishedEvent", "-f", "filename"};
60+
String[] args = {"-t", "eiffelactivityfinished", "-f", "filename"};
6161
CLIOptions.parse(args);
6262
cli.run(args);
6363
int code = CLIExitCodes.CLI_READ_FILE_FAILED;
@@ -71,23 +71,23 @@ public void testHandleFileArgsPass() throws Exception {
7171
File file = new File(path);
7272
String filePath = file.getAbsolutePath();
7373

74-
String[] args = {"-t", "EiffelArtifactPublishedEvent", "-f", filePath};
74+
String[] args = {"-t", "eiffelactivityfinished", "-f", filePath};
7575
CLIOptions.parse(args);
7676
cli.run(args);
7777
assertTrue(CLIOptions.getErrorCodes().isEmpty());
7878
}
7979

8080
@Test
8181
public void testHandleJsonArgsPass() throws Exception {
82-
String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", "{someKey:someValue}"};
82+
String[] args = {"-t", "eiffelactivityfinished", "-json", "{someKey:someValue}"};
8383
CLIOptions.parse(args);
8484
cli.run(args);
8585
assertTrue(CLIOptions.getErrorCodes().isEmpty());
8686
}
8787

8888
@Test
8989
public void testHandleJsonArgsFail() throws Exception {
90-
String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", "filename"};
90+
String[] args = {"-t", "eiffelactivityfinished", "-json", "filename"};
9191
CLIOptions.parse(args);
9292
cli.run(args);
9393
int code = CLIExitCodes.HANDLE_JSON_STRING_FAILED;
@@ -96,7 +96,7 @@ public void testHandleJsonArgsFail() throws Exception {
9696

9797
@Test
9898
public void testHandleMsgTypeEventArgsPass() throws Exception {
99-
String[] args = {"-t", "EiffelArtifactPublishedEvent", "-json", "{someKey:someValue}"};
99+
String[] args = {"-t", "eiffelactivityfinished", "-json", "{someKey:someValue}"};
100100
CLIOptions.parse(args);
101101
cli.run(args);
102102
assertTrue(CLIOptions.getErrorCodes().isEmpty());

service/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelSemanticsController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public void testUnauthenticatedNotAllowed() throws Exception {
111111
.contentType("application/json")
112112
.body(artifactPublishedBody)
113113
.when()
114-
.post("/eiffelsemantics?msgType=EiffelArtifactPublishedEvent")
114+
.post("/eiffelsemantics?msgType=eiffelartifactpublished")
115115
.then()
116116
.statusCode(HttpStatus.SC_OK)
117-
.body("meta.type", Matchers.is("EiffelArtifactPublishedEvent"))
117+
.body("meta.type", Matchers.is("eiffelartifactpublished"))
118118
.body("meta.version", Matchers.is(version));
119119
}
120120

@@ -124,10 +124,10 @@ public void testUnauthenticatedNotAllowed() throws Exception {
124124
.contentType("application/json")
125125
.body(activityFinishedBody)
126126
.when()
127-
.post("/eiffelsemantics?msgType=EiffelActivityFinishedEvent")
127+
.post("/eiffelsemantics?msgType=eiffelactivityfinished")
128128
.then()
129129
.statusCode(HttpStatus.SC_OK)
130-
.body("meta.type", Matchers.is("EiffelActivityFinishedEvent"))
130+
.body("meta.type", Matchers.is("eiffelactivityfinished"))
131131
.body("meta.version", Matchers.is(version));
132132
}
133133

service/src/integration-test/resources/ActivityFinished.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"msgParams": {
33
"meta": {
4-
"type": "EiffelActivityFinishedEvent",
4+
"type": "eiffelactivityfinished",
55
"version": "1.0.0",
66
"tags": [
77
"tag1",
@@ -11,7 +11,7 @@
1111
"domainId": "domainID",
1212
"host": "host",
1313
"name": "name",
14-
"uri": "http://java.sun.com/j2se/1.3/",
14+
"uri": "http:\/\/java.sun.com\/j2se\/1.3\/",
1515
"serializer": {
1616
"groupId": "G",
1717
"artifactId": "A",
@@ -22,18 +22,28 @@
2222
},
2323
"eventParams": {
2424
"data": {
25+
"customData": [
26+
{
27+
"key": "firstLog",
28+
"value": "http:\/\/myHost.com\/firstLog"
29+
},
30+
{
31+
"key": "otherLog",
32+
"value": "http:\/\/myHost.com\/firstLog33"
33+
}
34+
],
2535
"outcome": {
2636
"conclusion": "TIMED_OUT",
2737
"description": "Compilation timed out."
2838
},
2939
"persistentLogs": [
3040
{
3141
"name": "firstLog",
32-
"uri": "http://myHost.com/firstLog"
42+
"uri": "http:\/\/myHost.com\/firstLog"
3343
},
3444
{
3545
"name": "otherLog",
36-
"uri": "http://myHost.com/firstLog33"
46+
"uri": "http:\/\/myHost.com\/firstLog33"
3747
}
3848
]
3949
},

service/src/integration-test/resources/ArtifactPublished.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"msgParams": {
33
"meta": {
4-
"type": "EiffelArtifactPublishedEvent",
4+
"type": "eiffelartifactpublished",
55
"version": "1.0.0",
66
"tags": [
77
"tag1",
@@ -11,7 +11,7 @@
1111
"domainId": "example.domain",
1212
"host": "host",
1313
"name": "name",
14-
"uri": "http://java.sun.com/j2se/1.3/",
14+
"uri": "http:\/\/java.sun.com\/j2se\/1.3\/",
1515
"serializer": {
1616
"groupId": "G",
1717
"artifactId": "A",
@@ -25,11 +25,11 @@
2525
"locations": [
2626
{
2727
"type": "ARTIFACTORY",
28-
"uri": "https://one.place"
28+
"uri": "https:\/\/one.place"
2929
},
3030
{
3131
"type": "PLAIN",
32-
"uri": "http://another.com"
32+
"uri": "http:\/\/another.com"
3333
}
3434
]
3535
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.ericsson.eiffel.remrem.generate.constants;
2+
3+
public final class RemremGenerateServiceConstants {
4+
5+
public static final String NO_SERVICE_ERROR = "{\"message\":\"No protocol service has been found registered.\"}";
6+
public static final String JSON_ERROR_MESSAGE_FIELD = "message";
7+
8+
}

0 commit comments

Comments
 (0)