diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ae335c4..5b36a5b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + +## 0.9.3 +- Added endpoint to get event templates +- Uplifted remrem-semantics to 0.3.5 +- Uplifted remrem-protocol-interface to 0.0.7 + ## 0.9.2 - Uplifted remrem-semantics version to 0.3.2 to support continuous operation events diff --git a/build.gradle b/build.gradle index 0f2aaf85..4e0b5515 100644 --- a/build.gradle +++ b/build.gradle @@ -53,7 +53,7 @@ subprojects { targetCompatibility = 1.8 //Latest version for generate - version = "0.9.2" + version = "0.9.3" repositories { mavenCentral() @@ -64,8 +64,8 @@ subprojects { dependencies { //Injectable Message Library and its Implementation compile ('com.github.Ericsson:eiffel-remrem-shared:0.3.4') - compile ('com.github.Ericsson:eiffel-remrem-semantics:0.3.2') - compile ('com.github.Ericsson:eiffel-remrem-protocol-interface:0.0.5') + compile ('com.github.Ericsson:eiffel-remrem-semantics:0.3.5') + compile ('com.github.Ericsson:eiffel-remrem-protocol-interface:0.0.7') //Authentication compile("org.springframework.boot:spring-boot-starter-security:$sprintBootVersion") diff --git a/service/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelRemremControllerIntegrationTest.java b/service/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelRemremControllerIntegrationTest.java index d1d6d5dc..99c83e6b 100644 --- a/service/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelRemremControllerIntegrationTest.java +++ b/service/src/integration-test/java/com/ericsson/eiffel/remrem/generate/EiffelRemremControllerIntegrationTest.java @@ -162,5 +162,37 @@ public void testDuplicateKeyInBody() throws IOException { .then() .statusCode(HttpStatus.SC_BAD_REQUEST); } - + + @Test + public void testGetEventTypes() throws Exception { + given() + .header("Authorization", credentials) + .when() + .get("/event_types/eiffelsemantics") + .then() + .statusCode(HttpStatus.SC_OK) + .body(Matchers.containsString("EiffelArtifactPublishedEvent")) + .body(Matchers.containsString("EiffelActivityFinishedEvent")) + .body(Matchers.containsString("EiffelActivityStartedEvent")); + } + + @Test + public void testGetEventTypeTemplateFileExists() { + given() + .header("Authorization", credentials) + .when() + .get("/template/EiffelArtifactPublishedEvent/eiffelsemantics") + .then() + .statusCode(HttpStatus.SC_OK); + } + + @Test + public void testGetEventTypeTemplateNoFileExists() { + given() + .header("Authorization", credentials) + .when() + .get("/template/EiffelNotAnEvent/eiffelsemantics") + .then() + .statusCode(HttpStatus.SC_NOT_FOUND); + } } \ No newline at end of file diff --git a/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java b/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java index ea12e93b..bd16aaee 100644 --- a/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java +++ b/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java @@ -20,6 +20,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -30,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -87,7 +89,32 @@ public JsonElement getVersions() { Map> versions = new VersionService().getMessagingVersions(); return parser.parse(versions.toString()); } - + + /** + * this method returns available Eiffel event types as listed in EiffelEventType enum. + * + * @return string collection with event types. + */ + @RequestMapping(value = "/event_types/{mp}", method = RequestMethod.GET) + public ResponseEntity> getEventTypes(@PathVariable("mp") String mp) { + MsgService msgService = getMessageService(mp); + return new ResponseEntity>(msgService.getSupportedEventTypes(), HttpStatus.OK); + } + + /** + * Returns an eiffel event template matching the type specified in the path. + * + * @return json containing eiffel event template. + */ + @RequestMapping(value = "/template/{type}/{mp}", method = RequestMethod.GET) + public ResponseEntity getEventTypeTemplate(@PathVariable("type") String type, @PathVariable("mp") String mp) { + MsgService msgService = getMessageService(mp); + JsonElement template = msgService.getEventTemplate(type); + if(template != null) + return new ResponseEntity(template, HttpStatus.OK); + else + return new ResponseEntity(template, HttpStatus.NOT_FOUND); + } private MsgService getMessageService(String messageProtocol) { for (MsgService service : msgServices) {