From: PatrikBuhr Date: Wed, 21 Oct 2020 13:39:33 +0000 (+0200) Subject: New EI Consumer API, aligned to ORAN WG2 X-Git-Tag: 2.1.0~25^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=dddded37b9b321d041a1dc66a3a86112e37b918e;p=nonrtric.git New EI Consumer API, aligned to ORAN WG2 Change-Id: Ib7d72215caff54af54f1dc01eb3dccd1471a37dd Issue-ID: NONRTRIC-172 Signed-off-by: PatrikBuhr --- diff --git a/enrichment-coordinator-service/docs/api.json b/enrichment-coordinator-service/docs/api.json index 65ff48d1..71f64db5 100644 --- a/enrichment-coordinator-service/docs/api.json +++ b/enrichment-coordinator-service/docs/api.json @@ -1,28 +1,6 @@ { "basePath": "/", "paths": { - "/producer_simulator/job_deleted_error": {"post": { - "summary": "Callback for EI job creation, returns error", - "deprecated": false, - "produces": ["application/json"], - "operationId": "jobDeletedCallbackReturnErrorUsingPOST", - "responses": { - "200": {"description": "OK"}, - "201": {"description": "Created"}, - "401": {"description": "Unauthorized"}, - "403": {"description": "Forbidden"}, - "404": {"description": "Not Found"} - }, - "parameters": [{ - "schema": {"$ref": "#/definitions/producer_ei_job_request"}, - "in": "body", - "name": "request", - "description": "request", - "required": true - }], - "tags": ["Producer Simulator"], - "consumes": ["application/json"] - }}, "/producer_simulator/supervision": {"get": { "summary": "Producer supervision", "deprecated": false, @@ -37,46 +15,7 @@ "403": {"description": "Forbidden"}, "404": {"description": "Not Found"} }, - "tags": ["Producer Simulator"] - }}, - "/A1-EI/v1/eitypes/{eiTypeId}/eijobs": {"get": { - "summary": "EI job identifiers", - "deprecated": false, - "produces": ["application/json"], - "operationId": "getEiJobIdsUsingGET", - "responses": { - "200": { - "schema": { - "type": "array", - "items": {"type": "string"} - }, - "description": "EI job identifiers" - }, - "401": {"description": "Unauthorized"}, - "403": {"description": "Forbidden"}, - "404": { - "schema": {"$ref": "#/definitions/error_information"}, - "description": "Enrichment Information type is not found" - } - }, - "parameters": [ - { - "in": "path", - "name": "eiTypeId", - "description": "eiTypeId", - "type": "string", - "required": true - }, - { - "in": "query", - "allowEmptyValue": false, - "name": "owner", - "description": "identifies the owner of the job", - "type": "string", - "required": false - } - ], - "tags": ["A1-E Enrichment Data Consumer API"] + "tags": ["Producer Callbacks"] }}, "/A1-EI/v1/eitypes/{eiTypeId}": {"get": { "summary": "Individual EI type", @@ -85,13 +24,13 @@ "operationId": "getEiTypeUsingGET", "responses": { "200": { - "schema": {"$ref": "#/definitions/EiType"}, + "schema": {"$ref": "#/definitions/EiTypeObject"}, "description": "EI type" }, "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, + "schema": {"$ref": "#/definitions/ProblemDetails"}, "description": "Enrichment Information type is not found" } }, @@ -102,7 +41,7 @@ "type": "string", "required": true }], - "tags": ["A1-E Enrichment Data Consumer API"] + "tags": ["A1-EI (enrichment information)"] }}, "/ei-producer/v1/eitypes": {"get": { "summary": "EI type identifiers", @@ -140,7 +79,7 @@ "403": {"description": "Forbidden"}, "404": {"description": "Not Found"} }, - "tags": ["A1-E Enrichment Data Consumer API"] + "tags": ["A1-EI (enrichment information)"] }}, "/producer_simulator/job_deleted": {"post": { "summary": "Callback for EI job deletion", @@ -161,44 +100,9 @@ "description": "request", "required": true }], - "tags": ["Producer Simulator"], + "tags": ["Producer Callbacks"], "consumes": ["application/json"] }}, - "/A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}/status": {"get": { - "summary": "EI Job status", - "deprecated": false, - "produces": ["application/json"], - "operationId": "getEiJobStatusUsingGET", - "responses": { - "200": { - "schema": {"$ref": "#/definitions/EiJobStatus"}, - "description": "EI Job status" - }, - "401": {"description": "Unauthorized"}, - "403": {"description": "Forbidden"}, - "404": { - "schema": {"$ref": "#/definitions/error_information"}, - "description": "Enrichment Information type or job is not found" - } - }, - "parameters": [ - { - "in": "path", - "name": "eiJobId", - "description": "eiJobId", - "type": "string", - "required": true - }, - { - "in": "path", - "name": "eiTypeId", - "description": "eiTypeId", - "type": "string", - "required": true - } - ], - "tags": ["A1-E Enrichment Data Consumer API"] - }}, "/ei-producer/v1/eiproducers/{eiProducerId}/status": {"get": { "summary": "EI producer status", "deprecated": false, @@ -212,7 +116,7 @@ "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, + "schema": {"$ref": "#/definitions/ProblemDetails"}, "description": "Enrichment Information producer is not found" } }, @@ -225,22 +129,6 @@ }], "tags": ["Enrichment Data Producer API"] }}, - "/producer_simulator/supervision_error": {"get": { - "summary": "Producer supervision error", - "deprecated": false, - "produces": ["application/json"], - "operationId": "producerSupervisionErrorUsingGET", - "responses": { - "200": { - "schema": {"type": "string"}, - "description": "OK" - }, - "401": {"description": "Unauthorized"}, - "403": {"description": "Forbidden"}, - "404": {"description": "Not Found"} - }, - "tags": ["Producer Simulator"] - }}, "/ei-producer/v1/eiproducers": {"get": { "summary": "EI producer identifiers", "deprecated": false, @@ -261,7 +149,7 @@ "tags": ["Enrichment Data Producer API"] }}, "/ei-producer/v1/eitypes/{eiTypeId}": {"get": { - "summary": "Individual EI Type", + "summary": "Individual EI type", "deprecated": false, "produces": ["application/json"], "operationId": "getEiTypeUsingGET_1", @@ -273,7 +161,7 @@ "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, + "schema": {"$ref": "#/definitions/ProblemDetails"}, "description": "Enrichment Information type is not found" } }, @@ -302,66 +190,35 @@ }, "tags": ["Service status"] }}, - "/producer_simulator/job_created_error": {"post": { - "summary": "Callback for EI job creation, returns error", - "deprecated": false, - "produces": ["application/json"], - "operationId": "jobCreatedCallbackReturnErrorUsingPOST", - "responses": { - "200": {"description": "OK"}, - "201": {"description": "Created"}, - "401": {"description": "Unauthorized"}, - "403": {"description": "Forbidden"}, - "404": {"description": "Not Found"} - }, - "parameters": [{ - "schema": {"$ref": "#/definitions/producer_ei_job_request"}, - "in": "body", - "name": "request", - "description": "request", - "required": true - }], - "tags": ["Producer Simulator"], - "consumes": ["application/json"] - }}, - "/A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}": { + "/A1-EI/v1/eijobs/{eiJobId}": { "get": { - "summary": "Individual EI Job", + "summary": "Individual EI job", "deprecated": false, "produces": ["application/json"], "operationId": "getIndividualEiJobUsingGET", "responses": { "200": { - "schema": {"$ref": "#/definitions/EiJob"}, - "description": "EI Job" + "schema": {"$ref": "#/definitions/EiJobObject"}, + "description": "EI job" }, "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, - "description": "Enrichment Information type or job is not found" + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "Enrichment Information job is not found" } }, - "parameters": [ - { - "in": "path", - "name": "eiJobId", - "description": "eiJobId", - "type": "string", - "required": true - }, - { - "in": "path", - "name": "eiTypeId", - "description": "eiTypeId", - "type": "string", - "required": true - } - ], - "tags": ["A1-E Enrichment Data Consumer API"] + "parameters": [{ + "in": "path", + "name": "eiJobId", + "description": "eiJobId", + "type": "string", + "required": true + }], + "tags": ["A1-EI (enrichment information)"] }, "delete": { - "summary": "Individual EI Job", + "summary": "Individual EI job", "deprecated": false, "produces": ["application/json"], "operationId": "deleteIndividualEiJobUsingDELETE", @@ -371,30 +228,21 @@ "204": {"description": "Job deleted"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, - "description": "Enrichment Information type or job is not found" + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "Enrichment Information job is not found" } }, - "parameters": [ - { - "in": "path", - "name": "eiJobId", - "description": "eiJobId", - "type": "string", - "required": true - }, - { - "in": "path", - "name": "eiTypeId", - "description": "eiTypeId", - "type": "string", - "required": true - } - ], - "tags": ["A1-E Enrichment Data Consumer API"] + "parameters": [{ + "in": "path", + "name": "eiJobId", + "description": "eiJobId", + "type": "string", + "required": true + }], + "tags": ["A1-EI (enrichment information)"] }, "put": { - "summary": "Individual EI Job", + "summary": "Individual EI job", "deprecated": false, "produces": ["application/json"], "operationId": "putIndividualEiJobUsingPUT", @@ -404,7 +252,7 @@ "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, + "schema": {"$ref": "#/definitions/ProblemDetails"}, "description": "Enrichment Information type is not found" } }, @@ -417,21 +265,14 @@ "required": true }, { - "schema": {"$ref": "#/definitions/EiJob"}, + "schema": {"$ref": "#/definitions/EiJobObject"}, "in": "body", - "name": "eiJobInfo", - "description": "eiJobInfo", - "required": true - }, - { - "in": "path", - "name": "eiTypeId", - "description": "eiTypeId", - "type": "string", + "name": "eiJobObject", + "description": "eiJobObject", "required": true } ], - "tags": ["A1-E Enrichment Data Consumer API"], + "tags": ["A1-EI (enrichment information)"], "consumes": ["application/json"] } }, @@ -444,12 +285,12 @@ "responses": { "200": { "schema": {"$ref": "#/definitions/producer_registration_info"}, - "description": "EI Jobs" + "description": "EI jobs" }, "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, + "schema": {"$ref": "#/definitions/ProblemDetails"}, "description": "Enrichment Information producer is not found" } }, @@ -473,7 +314,7 @@ "204": {"description": "Producer deleted"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, + "schema": {"$ref": "#/definitions/ProblemDetails"}, "description": "Producer is not found" } }, @@ -535,7 +376,7 @@ "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, "404": { - "schema": {"$ref": "#/definitions/error_information"}, + "schema": {"$ref": "#/definitions/ProblemDetails"}, "description": "Enrichment Information producer is not found" } }, @@ -548,6 +389,73 @@ }], "tags": ["Enrichment Data Producer API"] }}, + "/A1-EI/v1/eijobs": {"get": { + "summary": "EI job identifiers", + "deprecated": false, + "produces": ["application/json"], + "description": "query for EI job identifiers", + "operationId": "getEiJobIdsUsingGET", + "responses": { + "200": { + "schema": { + "type": "array", + "items": {"type": "string"} + }, + "description": "EI job identifiers" + }, + "401": {"description": "Unauthorized"}, + "403": {"description": "Forbidden"}, + "404": { + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "Enrichment Information type is not found" + } + }, + "parameters": [ + { + "in": "query", + "allowEmptyValue": false, + "name": "eiTypeId", + "description": "selects EI jobs of matching EI type", + "type": "string", + "required": false + }, + { + "in": "query", + "allowEmptyValue": false, + "name": "owner", + "description": "selects EI jobs for one EI job owner", + "type": "string", + "required": false + } + ], + "tags": ["A1-EI (enrichment information)"] + }}, + "/A1-EI/v1/eijobs/{eiJobId}/status": {"get": { + "summary": "EI job status", + "deprecated": false, + "produces": ["application/json"], + "operationId": "getEiJobStatusUsingGET", + "responses": { + "200": { + "schema": {"$ref": "#/definitions/EiJobStatusObject"}, + "description": "EI job status" + }, + "401": {"description": "Unauthorized"}, + "403": {"description": "Forbidden"}, + "404": { + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "Enrichment Information job is not found" + } + }, + "parameters": [{ + "in": "path", + "name": "eiJobId", + "description": "eiJobId", + "type": "string", + "required": true + }], + "tags": ["A1-EI (enrichment information)"] + }}, "/producer_simulator/job_created": {"post": { "summary": "Callback for EI job creation", "deprecated": false, @@ -567,21 +475,12 @@ "description": "request", "required": true }], - "tags": ["Producer Simulator"], + "tags": ["Producer Callbacks"], "consumes": ["application/json"] }} }, - "host": "localhost:45709", + "host": "localhost:42127", "definitions": { - "EiType": { - "description": "Information for an EI type", - "type": "object", - "title": "EiType", - "properties": {"eiJobParametersSchema": { - "description": "Json schema for the job data", - "type": "object" - }} - }, "producer_ei_job_request": { "description": "The body of the EI producer callbacks for EI job creation and deletion", "type": "object", @@ -606,52 +505,10 @@ } } }, - "error_information": { - "description": "Problem as defined in https://tools.ietf.org/html/rfc7807", - "type": "object", - "title": "error_information", - "properties": { - "detail": { - "description": "A human-readable explanation specific to this occurrence of the problem.", - "type": "string", - "example": "EI job type not found" - }, - "status": { - "format": "int32", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "type": "integer", - "example": 404 - } - } - }, - "void": { - "description": "Void/empty", - "type": "object", - "title": "void" - }, - "EiJob": { - "description": "Information for an Enrichment Information Job", + "EiTypeObject": { + "description": "Information for an EI type", "type": "object", - "title": "EiJob", - "required": [ - "jobOwner", - "jobParameters", - "targetUri" - ], - "properties": { - "targetUri": { - "description": "The target of the EI data", - "type": "string" - }, - "jobOwner": { - "description": "Identity of the owner of the job", - "type": "string" - }, - "jobParameters": { - "description": "EI Type specific job data", - "type": "object" - } - } + "title": "EiTypeObject" }, "producer_ei_type_registration_info": { "description": "Information for an EI type", @@ -694,20 +551,6 @@ } } }, - "EiJobStatus": { - "description": "Status for an EI Job", - "type": "object", - "title": "EiJobStatus", - "required": ["operationalState"], - "properties": {"operationalState": { - "description": "Operational state, values:\nENABLED: TBD\nDISABLED: TBD.", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - }} - }, "Mono«ResponseEntity«object»»": { "type": "object", "title": "Mono«ResponseEntity«object»»" @@ -771,6 +614,76 @@ "DISABLED" ] }} + }, + "ProblemDetails": { + "description": "A problem detail to carry details in a HTTP response according to RFC 7807", + "type": "object", + "title": "ProblemDetails", + "properties": { + "detail": { + "description": "A human-readable explanation specific to this occurrence of the problem.", + "type": "string", + "example": "EI job type not found" + }, + "status": { + "format": "int32", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "type": "integer", + "example": 404 + } + } + }, + "Void": { + "description": "Void/empty", + "type": "object", + "title": "Void" + }, + "EiJobStatusObject": { + "description": "Status for an EI job", + "type": "object", + "title": "EiJobStatusObject", + "required": ["eiJobStatus"], + "properties": {"eiJobStatus": { + "description": "values:\nENABLED: the A1-EI producer is able to deliver EI result for the EI job\nDISABLED: the A1-EI producer is unable to deliver EI result for the EI job", + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + }} + }, + "EiJobObject": { + "description": "Information for an Enrichment Information Job", + "type": "object", + "title": "EiJobObject", + "required": [ + "eiTypeId", + "jobDefinition", + "jobOwner", + "jobResultUri" + ], + "properties": { + "eiTypeId": { + "description": "EI type Idenitifier of the EI job", + "type": "string" + }, + "jobResultUri": { + "description": "The target URI of the EI data", + "type": "string" + }, + "jobOwner": { + "description": "Identity of the owner of the job", + "type": "string" + }, + "jobStatusNotificationUri": { + "description": "The target of EI job status notifications", + "type": "string" + }, + "jobDefinition": { + "description": "EI type specific job data", + "type": "object" + } + } } }, "swagger": "2.0", @@ -781,7 +694,7 @@ }, "tags": [ { - "name": "A1-E Enrichment Data Consumer API", + "name": "A1-EI (enrichment information)", "description": "Consumer Controller" }, { @@ -789,7 +702,7 @@ "description": "Producer Controller" }, { - "name": "Producer Simulator", + "name": "Producer Callbacks", "description": "Producer Simulator Controller" }, { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java index 9b238654..87d1dba1 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java @@ -41,9 +41,7 @@ import reactor.core.publisher.Mono; public class ProducerCallbacks { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + private static Gson gson = new GsonBuilder().create(); private final AsyncRestClient restClient; diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java index 28c40bf6..921b8073 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java @@ -35,11 +35,12 @@ import org.springframework.http.ResponseEntity; import reactor.core.publisher.Mono; public class ErrorResponse { - private static Gson gson = new GsonBuilder() // - .create(); // + private static Gson gson = new GsonBuilder().create(); // Returned as body for all failed REST calls - @ApiModel(value = "error_information", description = "Problem as defined in https://tools.ietf.org/html/rfc7807") + @ApiModel( + value = "ProblemDetails", + description = "A problem detail to carry details in a HTTP response according to RFC 7807") public static class ErrorInfo { @SerializedName("type") private String type = "about:blank"; diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java index 80b6a80b..b28da8d2 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java @@ -25,7 +25,7 @@ import io.swagger.annotations.ApiModel; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "void", description = "Void/empty") +@ApiModel(value = "Void", description = "Void/empty") public class VoidResponse { private VoidResponse() { } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java index a8e88d8b..8603142b 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java @@ -23,9 +23,12 @@ package org.oransc.enrichment.controllers.consumer; public class ConsumerConsts { public static final String API_ROOT = "/A1-EI/v1"; - public static final String CONSUMER_API_NAME = "A1-E Enrichment Data Consumer API"; + public static final String CONSUMER_API_NAME = "A1-EI (enrichment information)"; public static final String OWNER_PARAM = "owner"; - public static final String OWNER_PARAM_DESCRIPTION = "identifies the owner of the job"; + public static final String OWNER_PARAM_DESCRIPTION = "selects EI jobs for one EI job owner"; + + public static final String EI_TYPE_ID_PARAM = "eiTypeId"; + public static final String EI_TYPE_ID_PARAM_DESCRIPTION = "selects EI jobs of matching EI type"; private ConsumerConsts() { } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java index 39796ee1..bead8265 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java @@ -55,6 +55,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono; @@ -62,6 +63,7 @@ import reactor.core.publisher.Mono; @SuppressWarnings("java:S3457") // No need to call "toString()" method as formatting and string .. @RestController("ConsumerController") @Api(tags = {ConsumerConsts.CONSUMER_API_NAME}) +@RequestMapping(path = ConsumerConsts.API_ROOT, produces = MediaType.APPLICATION_JSON_VALUE) public class ConsumerController { @Autowired @@ -77,10 +79,9 @@ public class ConsumerController { ProducerCallbacks producerCallbacks; private static Gson gson = new GsonBuilder() // - .serializeNulls() // .create(); // - @GetMapping(path = ConsumerConsts.API_ROOT + "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "EI type identifiers", notes = "") @ApiResponses( value = { // @@ -100,7 +101,7 @@ public class ConsumerController { return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); } - @GetMapping(path = ConsumerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Individual EI type", notes = "") @ApiResponses( value = { // @@ -112,18 +113,16 @@ public class ConsumerController { public ResponseEntity getEiType( // @PathVariable("eiTypeId") String eiTypeId) { try { - EiType t = this.eiTypes.getType(eiTypeId); - ConsumerEiTypeInfo info = toEiTypeInfo(t); + this.eiTypes.getType(eiTypeId); // Make sure that the type exists + ConsumerEiTypeInfo info = toEiTypeInfo(); return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - @GetMapping( - path = ConsumerConsts.API_ROOT + "/eitypes/{eiTypeId}/eijobs", - produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "EI job identifiers", notes = "") + @GetMapping(path = "/eijobs", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "EI job identifiers", notes = "query for EI job identifiers") @ApiResponses( value = { // @ApiResponse( @@ -136,14 +135,17 @@ public class ConsumerController { message = "Enrichment Information type is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity getEiJobIds( // - @PathVariable("eiTypeId") String eiTypeId, // + @ApiParam( + name = ConsumerConsts.EI_TYPE_ID_PARAM, + required = false, // + value = ConsumerConsts.EI_TYPE_ID_PARAM_DESCRIPTION) // + @RequestParam(name = ConsumerConsts.EI_TYPE_ID_PARAM, required = false) String eiTypeId, @ApiParam( name = ConsumerConsts.OWNER_PARAM, required = false, // value = ConsumerConsts.OWNER_PARAM_DESCRIPTION) // @RequestParam(name = ConsumerConsts.OWNER_PARAM, required = false) String owner) { try { - this.eiTypes.getType(eiTypeId); // Just to check that the type exists List result = new ArrayList<>(); if (owner != null) { for (EiJob job : this.eiJobs.getJobsForOwner(owner)) { @@ -151,33 +153,31 @@ public class ConsumerController { result.add(job.id()); } } + } else if (eiTypeId != null) { + this.eiJobs.getJobsForType(eiTypeId).forEach(job -> result.add(job.id())); } else { - for (EiJob job : this.eiJobs.getJobsForType(eiTypeId)) { - result.add(job.id()); - } + this.eiJobs.getJobs().forEach(job -> result.add(job.id())); } return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); - } catch (Exception e) { + } catch ( + + Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - @GetMapping( - path = ConsumerConsts.API_ROOT + "/eitypes/{eiTypeId}/eijobs/{eiJobId}", - produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Individual EI Job", notes = "") + @GetMapping(path = "/eijobs/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Individual EI job", notes = "") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "EI Job", response = ConsumerEiJobInfo.class), // + @ApiResponse(code = 200, message = "EI job", response = ConsumerEiJobInfo.class), // @ApiResponse( code = 404, - message = "Enrichment Information type or job is not found", + message = "Enrichment Information job is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity getIndividualEiJob( // - @PathVariable("eiTypeId") String eiTypeId, // @PathVariable("eiJobId") String eiJobId) { try { - this.eiTypes.getType(eiTypeId); // Just to check that the type exists EiJob job = this.eiJobs.getJob(eiJobId); return new ResponseEntity<>(gson.toJson(toEiJobInfo(job)), HttpStatus.OK); } catch (Exception e) { @@ -185,22 +185,18 @@ public class ConsumerController { } } - @GetMapping( - path = ConsumerConsts.API_ROOT + "/eitypes/{eiTypeId}/eijobs/{eiJobId}/status", - produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "EI Job status", notes = "") + @GetMapping(path = "/eijobs/{eiJobId}/status", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "EI job status", notes = "") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "EI Job status", response = ConsumerEiJobStatus.class), // + @ApiResponse(code = 200, message = "EI job status", response = ConsumerEiJobStatus.class), // @ApiResponse( code = 404, - message = "Enrichment Information type or job is not found", + message = "Enrichment Information job is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity getEiJobStatus( // - @PathVariable("eiTypeId") String eiTypeId, // @PathVariable("eiJobId") String eiJobId) { try { - this.eiTypes.getType(eiTypeId); // Just to check that the type exists EiJob job = this.eiJobs.getJob(eiJobId); return new ResponseEntity<>(gson.toJson(toEiJobStatus(job)), HttpStatus.OK); } catch (Exception e) { @@ -210,23 +206,20 @@ public class ConsumerController { private ConsumerEiJobStatus toEiJobStatus(EiJob job) { // TODO - return new ConsumerEiJobStatus(ConsumerEiJobStatus.OperationalState.ENABLED); + return new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED); } - @DeleteMapping( - path = ConsumerConsts.API_ROOT + "/eitypes/{eiTypeId}/eijobs/{eiJobId}", - produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Individual EI Job", notes = "") + @DeleteMapping(path = "/eijobs/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Individual EI job", notes = "") @ApiResponses( value = { // @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class), @ApiResponse(code = 204, message = "Job deleted", response = VoidResponse.class), @ApiResponse( code = 404, - message = "Enrichment Information type or job is not found", + message = "Enrichment Information job is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity deleteIndividualEiJob( // - @PathVariable("eiTypeId") String eiTypeId, // @PathVariable("eiJobId") String eiJobId) { try { EiJob job = this.eiJobs.getJob(eiJobId); @@ -239,10 +232,10 @@ public class ConsumerController { } @PutMapping( - path = ConsumerConsts.API_ROOT + "/eitypes/{eiTypeId}/eijobs/{eiJobId}", // + path = "/eijobs/{eiJobId}", // produces = MediaType.APPLICATION_JSON_VALUE, // consumes = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Individual EI Job", notes = "") + @ApiOperation(value = "Individual EI job", notes = "") @ApiResponses( value = { // @ApiResponse(code = 201, message = "Job created", response = VoidResponse.class), // @@ -252,13 +245,12 @@ public class ConsumerController { message = "Enrichment Information type is not found", response = ErrorResponse.ErrorInfo.class)}) public Mono> putIndividualEiJob( // - @PathVariable("eiTypeId") String eiTypeId, // @PathVariable("eiJobId") String eiJobId, // - @RequestBody ConsumerEiJobInfo eiJobInfo) { + @RequestBody ConsumerEiJobInfo eiJobObject) { final boolean isNewJob = this.eiJobs.get(eiJobId) == null; - return validatePutEiJob(eiTypeId, eiJobId, eiJobInfo) // + return validatePutEiJob(eiJobId, eiJobObject) // .flatMap(this::notifyProducersNewJob) // .doOnNext(newEiJob -> this.eiJobs.put(newEiJob)) // .flatMap(newEiJob -> Mono.just(new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK))) @@ -276,13 +268,13 @@ public class ConsumerController { }); } - private Mono validatePutEiJob(String eiTypeId, String eiJobId, ConsumerEiJobInfo eiJobInfo) { + private Mono validatePutEiJob(String eiJobId, ConsumerEiJobInfo eiJobInfo) { try { - EiType eiType = this.eiTypes.getType(eiTypeId); + EiType eiType = this.eiTypes.getType(eiJobInfo.eiTypeId); validateJsonObjectAgainstSchema(eiType.getJobDataSchema(), eiJobInfo.jobData); EiJob existingEiJob = this.eiJobs.get(eiJobId); - if (existingEiJob != null && !existingEiJob.type().getId().equals(eiTypeId)) { + if (existingEiJob != null && !existingEiJob.type().getId().equals(eiJobInfo.eiTypeId)) { throw new ServiceException("Not allowed to change type for existing EI job", HttpStatus.CONFLICT); } return Mono.just(toEiJob(eiJobInfo, eiJobId, eiType)); @@ -321,11 +313,11 @@ public class ConsumerController { .build(); } - private ConsumerEiTypeInfo toEiTypeInfo(EiType t) { - return new ConsumerEiTypeInfo(t.getJobDataSchema()); + private ConsumerEiTypeInfo toEiTypeInfo() { + return new ConsumerEiTypeInfo(); } private ConsumerEiJobInfo toEiJobInfo(EiJob s) { - return new ConsumerEiJobInfo(s.jobData(), s.owner(), s.targetUri()); + return new ConsumerEiJobInfo(s.type().getId(), s.jobData(), s.owner(), s.targetUri()); } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java index 47abcbb7..d6996ce5 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java @@ -29,28 +29,39 @@ import io.swagger.annotations.ApiModelProperty; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "EiJob", description = "Information for an Enrichment Information Job") +@ApiModel(value = "EiJobObject", description = "Information for an Enrichment Information Job") public class ConsumerEiJobInfo { + @ApiModelProperty(value = "EI type Idenitifier of the EI job", required = true) + @SerializedName("eiTypeId") + @JsonProperty(value = "eiTypeId", required = true) + public String eiTypeId; + @ApiModelProperty(value = "Identity of the owner of the job", required = true) @SerializedName("jobOwner") @JsonProperty(value = "jobOwner", required = true) public String owner; - @ApiModelProperty(value = "EI Type specific job data", required = true) - @SerializedName("jobParameters") - @JsonProperty(value = "jobParameters", required = true) + @ApiModelProperty(value = "EI type specific job data", required = true) + @SerializedName("jobDefinition") + @JsonProperty(value = "jobDefinition", required = true) public Object jobData; - @ApiModelProperty(value = "The target of the EI data", required = true) - @SerializedName("targetUri") - @JsonProperty(value = "targetUri", required = true) + @ApiModelProperty(value = "The target URI of the EI data", required = true) + @SerializedName("jobResultUri") + @JsonProperty(value = "jobResultUri", required = true) public String targetUri; + @ApiModelProperty(value = "The target of EI job status notifications", required = false) + @SerializedName("jobStatusNotificationUri") + @JsonProperty(value = "jobStatusNotificationUri", required = false) + public String statusNotificationUri; + public ConsumerEiJobInfo() { } - public ConsumerEiJobInfo(Object jobData, String owner, String targetUri) { + public ConsumerEiJobInfo(String eiTypeId, Object jobData, String owner, String targetUri) { + this.eiTypeId = eiTypeId; this.jobData = jobData; this.owner = owner; this.targetUri = targetUri; diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobStatus.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobStatus.java index 43643abc..b2f657f9 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobStatus.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobStatus.java @@ -29,25 +29,25 @@ import io.swagger.annotations.ApiModelProperty; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "EiJobStatus", description = "Status for an EI Job") +@ApiModel(value = "EiJobStatusObject", description = "Status for an EI job") public class ConsumerEiJobStatus { @Gson.TypeAdapters - @ApiModel(value = "OperationalState", description = "Represents the operational states for a EI Job") - public enum OperationalState { + @ApiModel(value = "EiJobStatusValues", description = "Allowed values for EI job status") + public enum EiJobStatusValues { ENABLED, DISABLED } - private static final String OPERATIONAL_STATE_DESCRIPTION = "Operational state, values:\n" // - + "ENABLED: TBD\n" // - + "DISABLED: TBD."; + private static final String OPERATIONAL_STATE_DESCRIPTION = "values:\n" // + + "ENABLED: the A1-EI producer is able to deliver EI result for the EI job\n" // + + "DISABLED: the A1-EI producer is unable to deliver EI result for the EI job"; - @ApiModelProperty(value = OPERATIONAL_STATE_DESCRIPTION, name = "operational_state", required = true) - @SerializedName("operationalState") - @JsonProperty(value = "operationalState", required = true) - public final OperationalState state; + @ApiModelProperty(value = OPERATIONAL_STATE_DESCRIPTION, name = "eiJobStatus", required = true) + @SerializedName("eiJobStatus") + @JsonProperty(value = "eiJobStatus", required = true) + public final EiJobStatusValues state; - public ConsumerEiJobStatus(OperationalState state) { + public ConsumerEiJobStatus(EiJobStatusValues state) { this.state = state; } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java index 3a2ab41c..b5d664bf 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java @@ -20,24 +20,12 @@ package org.oransc.enrichment.controllers.consumer; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.gson.annotations.SerializedName; - import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "EiType", description = "Information for an EI type") +@ApiModel(value = "EiTypeObject", description = "Information for an EI type") public class ConsumerEiTypeInfo { - @ApiModelProperty(value = "Json schema for the job data") - @SerializedName("eiJobParametersSchema") - @JsonProperty("eiJobParametersSchema") - public final Object jobParametersSchema; - - ConsumerEiTypeInfo(Object jobParametersSchema) { - this.jobParametersSchema = jobParametersSchema; - } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java index d67b8ed4..306e3a91 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java @@ -64,9 +64,7 @@ public class ProducerController { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + private static Gson gson = new GsonBuilder().create(); @Autowired private EiJobs eiJobs; @@ -101,7 +99,7 @@ public class ProducerController { } @GetMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Individual EI Type", notes = "") + @ApiOperation(value = "Individual EI type", notes = "") @ApiResponses( value = { // @ApiResponse(code = 200, message = "EI type", response = ProducerEiTypeInfo.class), // @@ -146,7 +144,7 @@ public class ProducerController { @ApiOperation(value = "Individual EI producer", notes = "") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "EI Jobs", response = ProducerRegistrationInfo.class), // + @ApiResponse(code = 200, message = "EI jobs", response = ProducerRegistrationInfo.class), // @ApiResponse( code = 404, message = "Enrichment Information producer is not found", diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java index bb880e7f..8c1206f4 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java @@ -24,7 +24,7 @@ import org.immutables.gson.Gson; import org.immutables.value.Value; /** - * Represents the dynamic information about a EI Job + * Represents the dynamic information about a EI job */ @Value.Immutable @Gson.TypeAdapters diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java index 7a0dcfd1..f0e4051c 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java @@ -28,7 +28,7 @@ import java.util.Vector; import org.oransc.enrichment.exceptions.ServiceException; /** - * Dynamic representation of all EI Jobs in the system. + * Dynamic representation of all existing EI jobs. */ public class EiJobs { private Map allEiJobs = new HashMap<>(); diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java index 9b7b6405..6397c2f0 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java @@ -31,7 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Dynamic representation of all EI Types in the system. + * Dynamic representation of all EI types in the system. */ @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally public class EiTypes { diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java index e564fef1..e272faa5 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java @@ -113,9 +113,7 @@ class ApplicationTest { @Autowired ProducerSupervision producerSupervision; - private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + private static Gson gson = new GsonBuilder().create(); /** * Overrides the BeanFactory. @@ -177,7 +175,7 @@ class ApplicationTest { String url = ConsumerConsts.API_ROOT + "/eitypes/test"; String rsp = restClient().get(url).block(); ConsumerEiTypeInfo info = gson.fromJson(rsp, ConsumerEiTypeInfo.class); - assertThat(info.jobParametersSchema).isNotNull(); + assertThat(info).isNotNull(); } @Test @@ -190,39 +188,47 @@ class ApplicationTest { void testGetEiJobsIds() throws Exception { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); putEiJob(EI_TYPE_ID, "jobId"); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs"; + final String JOB_ID_JSON = "[\"jobId\"]"; + String url = ConsumerConsts.API_ROOT + "/eijobs?eiTypeId=typeId"; String rsp = restClient().get(url).block(); - assertThat(rsp).isEqualTo("[\"jobId\"]"); + assertThat(rsp).isEqualTo(JOB_ID_JSON); - url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=owner"; + url = ConsumerConsts.API_ROOT + "/eijobs?owner=owner"; rsp = restClient().get(url).block(); - assertThat(rsp).isEqualTo("[\"jobId\"]"); + assertThat(rsp).isEqualTo(JOB_ID_JSON); - url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=JUNK"; + url = ConsumerConsts.API_ROOT + "/eijobs?owner=JUNK"; rsp = restClient().get(url).block(); assertThat(rsp).isEqualTo("[]"); - } - @Test - void testGetEiJobTypeNotFound() throws Exception { - String url = ConsumerConsts.API_ROOT + "/eitypes/junk/eijobs"; - testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find EI type: junk"); + url = ConsumerConsts.API_ROOT + "/eijobs"; + rsp = restClient().get(url).block(); + assertThat(rsp).isEqualTo(JOB_ID_JSON); + + url = ConsumerConsts.API_ROOT + "/eijobs?eiTypeId=typeId&&owner=owner"; + rsp = restClient().get(url).block(); + assertThat(rsp).isEqualTo(JOB_ID_JSON); + + url = ConsumerConsts.API_ROOT + "/eijobs?eiTypeId=JUNK"; + rsp = restClient().get(url).block(); + assertThat(rsp).isEqualTo("[]"); } @Test void testGetEiJob() throws Exception { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); putEiJob(EI_TYPE_ID, "jobId"); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId"; + String url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; String rsp = restClient().get(url).block(); ConsumerEiJobInfo info = gson.fromJson(rsp, ConsumerEiJobInfo.class); assertThat(info.owner).isEqualTo("owner"); + assertThat(info.eiTypeId).isEqualTo(EI_TYPE_ID); } @Test void testGetEiJobNotFound() throws Exception { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/junk"; + String url = ConsumerConsts.API_ROOT + "/eijobs/junk"; testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find EI job: junk"); } @@ -230,7 +236,7 @@ class ApplicationTest { void testGetEiJobStatus() throws Exception { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); putEiJob(EI_TYPE_ID, "jobId"); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId/status"; + String url = ConsumerConsts.API_ROOT + "/eijobs/jobId/status"; String rsp = restClient().get(url).block(); assertThat(rsp).contains("ENABLED"); } @@ -242,7 +248,7 @@ class ApplicationTest { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); putEiJob(EI_TYPE_ID, "jobId"); assertThat(this.eiJobs.size()).isEqualTo(1); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId"; + String url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; restClient().delete(url).block(); assertThat(this.eiJobs.size()).isZero(); @@ -254,7 +260,7 @@ class ApplicationTest { @Test void testDeleteEiJobNotFound() throws Exception { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/junk"; + String url = ConsumerConsts.API_ROOT + "/eijobs/junk"; testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find EI job: junk"); } @@ -264,7 +270,7 @@ class ApplicationTest { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); putEiProducerWithOneTypeRejecting("simulateProducerError", EI_TYPE_ID); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId"; + String url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; String body = gson.toJson(eiJobInfo()); ResponseEntity resp = restClient().putForEntity(url, body).block(); assertThat(this.eiJobs.size()).isEqualTo(1); @@ -286,7 +292,7 @@ class ApplicationTest { @Test void putEiProducerWithOneType_rejecting() throws JsonMappingException, JsonProcessingException, ServiceException { putEiProducerWithOneTypeRejecting("simulateProducerError", EI_TYPE_ID); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId"; + String url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; String body = gson.toJson(eiJobInfo()); testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "Job not accepted by any producers"); @@ -298,10 +304,10 @@ class ApplicationTest { void testPutEiJob_jsonSchemavalidationError() throws Exception { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId"; + String url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; // The element with name "property1" is mandatory in the schema ConsumerEiJobInfo jobInfo = - new ConsumerEiJobInfo(jsonObject("{ \"XXstring\" : \"value\" }"), "owner", "targetUri"); + new ConsumerEiJobInfo("typeId", jsonObject("{ \"XXstring\" : \"value\" }"), "owner", "targetUri"); String body = gson.toJson(jobInfo); testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "Json validation failure"); @@ -342,8 +348,8 @@ class ApplicationTest { putEiProducerWithOneType("producer2", "typeId2"); putEiJob("typeId1", "jobId"); - String url = ConsumerConsts.API_ROOT + "/eitypes/typeId2/eijobs/jobId"; - String body = gson.toJson(eiJobInfo()); + String url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; + String body = gson.toJson(eiJobInfo("typeId2")); testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "Not allowed to change type for existing EI job"); } @@ -392,7 +398,7 @@ class ApplicationTest { assertThat(this.eiTypes.size()).isEqualTo(1); this.eiTypes.getType(EI_TYPE_ID); - url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId"; + url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; body = gson.toJson(eiJobInfo()); restClient().putForEntity(url, body).block(); @@ -526,7 +532,11 @@ class ApplicationTest { } ConsumerEiJobInfo eiJobInfo() throws JsonMappingException, JsonProcessingException { - return new ConsumerEiJobInfo(jsonObject(), "owner", "targetUri"); + return eiJobInfo(EI_TYPE_ID); + } + + ConsumerEiJobInfo eiJobInfo(String typeId) throws JsonMappingException, JsonProcessingException { + return new ConsumerEiJobInfo(typeId, jsonObject(), "owner", "targetUri"); } Object jsonObject(String json) { @@ -561,8 +571,8 @@ class ApplicationTest { private EiJob putEiJob(String eiTypeId, String jobId) throws JsonMappingException, JsonProcessingException, ServiceException { - String url = ConsumerConsts.API_ROOT + "/eitypes/" + eiTypeId + "/eijobs/" + jobId; - String body = gson.toJson(eiJobInfo()); + String url = ConsumerConsts.API_ROOT + "/eijobs/" + jobId; + String body = gson.toJson(eiJobInfo(eiTypeId)); restClient().putForEntity(url, body).block(); return this.eiJobs.getJob(jobId); diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java index c4651961..4c57abdd 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java @@ -46,7 +46,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController("ProducerSimulatorController") -@Api(tags = {"Producer Simulator"}) +@Api(tags = {"Producer Callbacks"}) public class ProducerSimulatorController { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -121,7 +121,7 @@ public class ProducerSimulatorController { } @PostMapping(path = JOB_CREATED_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Callback for EI job creation, returns error", notes = "") + @ApiOperation(value = "Callback for EI job creation, returns error", notes = "", hidden = true) @ApiResponses( value = { // @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}// @@ -134,7 +134,7 @@ public class ProducerSimulatorController { } @PostMapping(path = JOB_DELETED_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Callback for EI job creation, returns error", notes = "") + @ApiOperation(value = "Callback for EI job creation, returns error", notes = "", hidden = true) @ApiResponses( value = { // @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}// @@ -158,7 +158,7 @@ public class ProducerSimulatorController { } @GetMapping(path = SUPERVISION_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Producer supervision error", notes = "") + @ApiOperation(value = "Producer supervision error", notes = "", hidden = true) @ApiResponses( value = { // @ApiResponse(code = 200, message = "OK", response = String.class)}//