Fixed the query parameter 'owner' 16/4816/1
authorPatrikBuhr <patrik.buhr@est.tech>
Fri, 2 Oct 2020 07:26:06 +0000 (09:26 +0200)
committerPatrikBuhr <patrik.buhr@est.tech>
Wed, 7 Oct 2020 07:49:27 +0000 (09:49 +0200)
Fixed the the query parameter 'owner' in GET EI Jobs

Change-Id: I702aa67cc3ac44cdd8d0a09e7d5551ea98a6f8df
Issue-ID: NONRTRIC-173
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
enrichment-coordinator-service/docs/api.json
enrichment-coordinator-service/docs/api.yaml [deleted file]
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java
enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java

index 76be3a4..65ff48d 100644 (file)
                     "required": true
                 },
                 {
-                    "schema": {"type": "string"},
-                    "in": "body",
+                    "in": "query",
+                    "allowEmptyValue": false,
                     "name": "owner",
                     "description": "identifies the owner of the job",
+                    "type": "string",
                     "required": false
                 }
             ],
             "consumes": ["application/json"]
         }}
     },
-    "host": "localhost:40973",
+    "host": "localhost:45709",
     "definitions": {
         "EiType": {
             "description": "Information for an EI type",
diff --git a/enrichment-coordinator-service/docs/api.yaml b/enrichment-coordinator-service/docs/api.yaml
deleted file mode 100644 (file)
index 48a65dd..0000000
+++ /dev/null
@@ -1,805 +0,0 @@
-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
-      produces:
-        - application/json
-      operationId: producerSupervisionUsingGET
-      responses:
-        '200':
-          schema:
-            type: string
-          description: OK
-        '401':
-          description: Unauthorized
-        '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
-        - schema:
-            type: string
-          in: body
-          name: owner
-          description: identifies the owner of the job
-          required: false
-      tags:
-        - A1-E Enrichment Data Consumer API
-  '/A1-EI/v1/eitypes/{eiTypeId}':
-    get:
-      summary: Individual EI type
-      deprecated: false
-      produces:
-        - application/json
-      operationId: getEiTypeUsingGET
-      responses:
-        '200':
-          schema:
-            $ref: '#/definitions/EiType'
-          description: EI type
-        '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
-      tags:
-        - A1-E Enrichment Data Consumer API
-  /ei-producer/v1/eitypes:
-    get:
-      summary: EI type identifiers
-      deprecated: false
-      produces:
-        - application/json
-      operationId: getEiTypeIdentifiersUsingGET_1
-      responses:
-        '200':
-          schema:
-            type: array
-            items:
-              type: string
-          description: EI type identifiers
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          description: Not Found
-      tags:
-        - Enrichment Data Producer API
-  /A1-EI/v1/eitypes:
-    get:
-      summary: EI type identifiers
-      deprecated: false
-      produces:
-        - application/json
-      operationId: getEiTypeIdentifiersUsingGET
-      responses:
-        '200':
-          schema:
-            type: array
-            items:
-              type: string
-          description: EI type identifiers
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          description: Not Found
-      tags:
-        - A1-E Enrichment Data Consumer API
-  /producer_simulator/job_deleted:
-    post:
-      summary: Callback for EI job deletion
-      deprecated: false
-      produces:
-        - application/json
-      operationId: jobDeletedCallbackUsingPOST
-      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}/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
-      produces:
-        - application/json
-      operationId: getEiProducerStatusUsingGET
-      responses:
-        '200':
-          schema:
-            $ref: '#/definitions/producer_status'
-          description: EI jobs
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          schema:
-            $ref: '#/definitions/error_information'
-          description: Enrichment Information producer is not found
-      parameters:
-        - in: path
-          name: eiProducerId
-          description: eiProducerId
-          type: string
-          required: true
-      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
-      produces:
-        - application/json
-      operationId: getEiProducerIdentifiersUsingGET
-      responses:
-        '200':
-          schema:
-            type: array
-            items:
-              type: string
-          description: EI producer identifiers
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          description: Not Found
-      tags:
-        - Enrichment Data Producer API
-  '/ei-producer/v1/eitypes/{eiTypeId}':
-    get:
-      summary: Individual EI Type
-      deprecated: false
-      produces:
-        - application/json
-      operationId: getEiTypeUsingGET_1
-      responses:
-        '200':
-          schema:
-            $ref: '#/definitions/producer_ei_type_info'
-          description: EI type
-        '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
-      tags:
-        - Enrichment Data Producer API
-  /status:
-    get:
-      summary: Returns status and statistics of this service
-      deprecated: false
-      produces:
-        - application/json
-      operationId: getStatusUsingGET
-      responses:
-        '200':
-          schema:
-            $ref: '#/definitions/status_info'
-          description: Service is living
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          description: Not Found
-      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}':
-    get:
-      summary: Individual EI Job
-      deprecated: false
-      produces:
-        - application/json
-      operationId: getIndividualEiJobUsingGET
-      responses:
-        '200':
-          schema:
-            $ref: '#/definitions/EiJob'
-          description: EI Job
-        '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
-    delete:
-      summary: Individual EI Job
-      deprecated: false
-      produces:
-        - application/json
-      operationId: deleteIndividualEiJobUsingDELETE
-      responses:
-        '200':
-          description: Not used
-        '204':
-          description: Job deleted
-        '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
-    put:
-      summary: Individual EI Job
-      deprecated: false
-      produces:
-        - application/json
-      operationId: putIndividualEiJobUsingPUT
-      responses:
-        '200':
-          description: Job updated
-        '201':
-          description: Job created
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          schema:
-            $ref: '#/definitions/error_information'
-          description: Enrichment Information type is not found
-      parameters:
-        - in: path
-          name: eiJobId
-          description: eiJobId
-          type: string
-          required: true
-        - schema:
-            $ref: '#/definitions/EiJob'
-          in: body
-          name: eiJobInfo
-          description: eiJobInfo
-          required: true
-        - in: path
-          name: eiTypeId
-          description: eiTypeId
-          type: string
-          required: true
-      tags:
-        - A1-E Enrichment Data Consumer API
-      consumes:
-        - application/json
-  '/ei-producer/v1/eiproducers/{eiProducerId}':
-    get:
-      summary: Individual EI producer
-      deprecated: false
-      produces:
-        - application/json
-      operationId: getEiProducerUsingGET
-      responses:
-        '200':
-          schema:
-            $ref: '#/definitions/producer_registration_info'
-          description: EI Jobs
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          schema:
-            $ref: '#/definitions/error_information'
-          description: Enrichment Information producer is not found
-      parameters:
-        - in: path
-          name: eiProducerId
-          description: eiProducerId
-          type: string
-          required: true
-      tags:
-        - Enrichment Data Producer API
-    delete:
-      summary: Individual EI producer
-      deprecated: false
-      produces:
-        - application/json
-      operationId: deleteEiProducerUsingDELETE
-      responses:
-        '200':
-          description: Not used
-        '204':
-          description: Producer deleted
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          schema:
-            $ref: '#/definitions/error_information'
-          description: Producer is not found
-      parameters:
-        - in: path
-          name: eiProducerId
-          description: eiProducerId
-          type: string
-          required: true
-      tags:
-        - Enrichment Data Producer API
-    put:
-      summary: Individual EI producer
-      deprecated: false
-      produces:
-        - application/json
-      operationId: putEiProducerUsingPUT
-      responses:
-        '200':
-          description: Producer updated
-        '201':
-          description: Producer created
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          description: Not Found
-      parameters:
-        - in: path
-          name: eiProducerId
-          description: eiProducerId
-          type: string
-          required: true
-        - schema:
-            $ref: '#/definitions/producer_registration_info'
-          in: body
-          name: registrationInfo
-          description: registrationInfo
-          required: true
-      tags:
-        - Enrichment Data Producer API
-      consumes:
-        - application/json
-  '/ei-producer/v1/eiproducers/{eiProducerId}/eijobs':
-    get:
-      summary: EI job definitions
-      deprecated: false
-      produces:
-        - application/json
-      description: EI job definitions for one EI producer
-      operationId: getEiProducerJobsUsingGET
-      responses:
-        '200':
-          schema:
-            type: array
-            items:
-              $ref: '#/definitions/producer_ei_job_request'
-          description: EI jobs
-        '401':
-          description: Unauthorized
-        '403':
-          description: Forbidden
-        '404':
-          schema:
-            $ref: '#/definitions/error_information'
-          description: Enrichment Information producer is not found
-      parameters:
-        - in: path
-          name: eiProducerId
-          description: eiProducerId
-          type: string
-          required: true
-      tags:
-        - Enrichment Data Producer API
-  /producer_simulator/job_created:
-    post:
-      summary: Callback for EI job creation
-      deprecated: false
-      produces:
-        - application/json
-      operationId: jobCreatedCallbackUsingPOST
-      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
-host: 'localhost:40973'
-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
-    title: producer_ei_job_request
-    required:
-      - ei_job_identity
-    properties:
-      ei_job_identity:
-        description: Idenitity of the EI job
-        type: string
-      ei_job_data:
-        description: Json for the job data
-        type: object
-      target_uri:
-        description: URI for the target of the EI
-        type: string
-      ei_type_identity:
-        description: Type idenitity for the job
-        type: string
-  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
-    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
-  producer_ei_type_registration_info:
-    description: Information for an EI type
-    type: object
-    title: producer_ei_type_registration_info
-    required:
-      - ei_type_identity
-    properties:
-      ei_type_identity:
-        description: EI type identity
-        type: string
-      ei_job_data_schema:
-        description: Json schema for the job data
-        type: object
-  status_info:
-    type: object
-    title: status_info
-    properties:
-      no_of_producers:
-        format: int32
-        description: Number of EI producers
-        type: integer
-      no_of_jobs:
-        format: int32
-        description: Number of EI jobs
-        type: integer
-      no_of_types:
-        format: int32
-        description: Number of EI types
-        type: integer
-      status:
-        description: status text
-        type: string
-  EiJobStatus:
-    description: Status for an EI Job
-    type: object
-    title: EiJobStatus
-    required:
-      - operationalState
-    properties:
-      operationalState:
-        description: |-
-          Operational state, values:
-          ENABLED: TBD
-          DISABLED: TBD.
-        type: string
-        enum:
-          - ENABLED
-          - DISABLED
-  Mono«ResponseEntity«object»»:
-    type: object
-    title: Mono«ResponseEntity«object»»
-  producer_ei_type_info:
-    description: Information for an EI type
-    type: object
-    title: producer_ei_type_info
-    properties:
-      ei_producer_ids:
-        description: Registered producers
-        type: array
-        items:
-          type: string
-      ei_job_data_schema:
-        description: Json schema for the job data
-        type: object
-  producer_registration_info:
-    description: Information for an EI producer
-    type: object
-    title: producer_registration_info
-    required:
-      - ei_job_creation_callback_url
-      - ei_job_deletion_callback_url
-      - ei_producer_supervision_callback_url
-      - supported_ei_types
-    properties:
-      supported_ei_types:
-        description: Supported EI types
-        type: array
-        items:
-          $ref: '#/definitions/producer_ei_type_registration_info'
-      ei_job_creation_callback_url:
-        description: callback for job creation
-        type: string
-      ei_job_deletion_callback_url:
-        description: callback for job deletion
-        type: string
-      ei_producer_supervision_callback_url:
-        description: callback for producer supervision
-        type: string
-  producer_status:
-    description: Status for an EI Producer
-    type: object
-    title: producer_status
-    required:
-      - operational_state
-    properties:
-      operational_state:
-        description: |-
-          Operational state, values:
-          ENABLED: TBD
-          DISABLED: TBD.
-        type: string
-        enum:
-          - ENABLED
-          - DISABLED
-swagger: '2.0'
-info:
-  description: This page lists all the rest apis for the service.
-  title: Enrichment Data service
-  version: '1.0'
-tags:
-  - name: A1-E Enrichment Data Consumer API
-    description: Consumer Controller
-  - name: Enrichment Data Producer API
-    description: Producer Controller
-  - name: Producer Simulator
-    description: Producer Simulator Controller
-  - name: Service status
-    description: Status Controller
-
index a210aa5..77439c5 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.oransc.enrichment.controllers;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.gson.annotations.SerializedName;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -31,16 +34,13 @@ import org.immutables.gson.Gson;
 import org.oransc.enrichment.repository.EiJobs;
 import org.oransc.enrichment.repository.EiProducers;
 import org.oransc.enrichment.repository.EiTypes;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
 import reactor.core.publisher.Mono;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.gson.annotations.SerializedName;
 
 @RestController("StatusController")
 @Api(tags = "Service status")
@@ -88,9 +88,10 @@ public class StatusController {
 
     @GetMapping(path = "/status", produces = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "Returns status and statistics of this service")
-    @ApiResponses(value = { //
+    @ApiResponses(
+        value = { //
             @ApiResponse(code = 200, message = "Service is living", response = StatusInfo.class) //
-    })
+        })
     public Mono<ResponseEntity<Object>> getStatus() {
         StatusInfo info = new StatusInfo("hunky dory", this.eiProducers, this.eiTypes, this.eiJobs);
         return Mono.just(new ResponseEntity<>(info, HttpStatus.OK));
index 288421a..a08d52b 100644 (file)
@@ -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.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import reactor.core.publisher.Mono;
 
@@ -140,12 +141,20 @@ public class ConsumerController {
             name = ConsumerConsts.OWNER_PARAM,
             required = false, //
             value = ConsumerConsts.OWNER_PARAM_DESCRIPTION) //
-        String owner) {
+        @RequestParam(name = ConsumerConsts.OWNER_PARAM, required = false) String owner) {
         try {
             this.eiTypes.getType(eiTypeId); // Just to check that the type exists
             List<String> result = new ArrayList<>();
-            for (EiJob job : this.eiJobs.getJobsForType(eiTypeId)) {
-                result.add(job.id());
+            if (owner != null) {
+                for (EiJob job : this.eiJobs.getJobsForOwner(owner)) {
+                    if (eiTypeId == null || job.type().getId().equals(eiTypeId)) {
+                        result.add(job.id());
+                    }
+                }
+            } else {
+                for (EiJob job : this.eiJobs.getJobsForType(eiTypeId)) {
+                    result.add(job.id());
+                }
             }
             return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
         } catch (Exception e) {
index 606ee41..7a0dcfd 100644 (file)
@@ -34,10 +34,12 @@ public class EiJobs {
     private Map<String, EiJob> allEiJobs = new HashMap<>();
 
     private MultiMap<EiJob> jobsByType = new MultiMap<>();
+    private MultiMap<EiJob> jobsByOwner = new MultiMap<>();
 
     public synchronized void put(EiJob job) {
         allEiJobs.put(job.id(), job);
         jobsByType.put(job.type().getId(), job.id(), job);
+        jobsByOwner.put(job.owner(), job.id(), job);
     }
 
     public synchronized Collection<EiJob> getJobs() {
@@ -60,6 +62,10 @@ public class EiJobs {
         return jobsByType.get(type.getId());
     }
 
+    public synchronized Collection<EiJob> getJobsForOwner(String owner) {
+        return jobsByOwner.get(owner);
+    }
+
     public synchronized EiJob get(String id) {
         return allEiJobs.get(id);
     }
@@ -75,6 +81,7 @@ public class EiJobs {
     public synchronized void remove(EiJob job) {
         this.allEiJobs.remove(job.id());
         jobsByType.remove(job.type().getId(), job.id());
+        jobsByOwner.remove(job.owner(), job.id());
     }
 
     public synchronized int size() {
@@ -84,6 +91,7 @@ public class EiJobs {
     public synchronized void clear() {
         this.allEiJobs.clear();
         this.jobsByType.clear();
+        jobsByOwner.clear();
     }
 
 }
index d8a0b32..8b8cb67 100644 (file)
@@ -82,9 +82,10 @@ import reactor.test.StepVerifier;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(properties = { //
+@TestPropertySource(
+    properties = { //
         "server.ssl.key-store=./config/keystore.jks", //
-        "app.webclient.trust-store=./config/truststore.jks" })
+        "app.webclient.trust-store=./config/truststore.jks"})
 class ApplicationTest {
     private final String EI_TYPE_ID = "typeId";
     private final String EI_PRODUCER_ID = "producerId";
@@ -112,8 +113,8 @@ class ApplicationTest {
     ProducerSupervision producerSupervision;
 
     private static Gson gson = new GsonBuilder() //
-            .serializeNulls() //
-            .create(); //
+        .serializeNulls() //
+        .create(); //
 
     /**
      * Overrides the BeanFactory.
@@ -162,6 +163,13 @@ class ApplicationTest {
         assertThat(rsp).isEqualTo("[\"test\"]");
     }
 
+    @Test
+    void testGetEiTypesEmpty() throws Exception {
+        String url = ConsumerConsts.API_ROOT + "/eitypes";
+        String rsp = restClient().get(url).block();
+        assertThat(rsp).isEqualTo("[]");
+    }
+
     @Test
     void testGetEiType() throws Exception {
         putEiProducerWithOneType(EI_PRODUCER_ID, "test");
@@ -184,6 +192,14 @@ class ApplicationTest {
         String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs";
         String rsp = restClient().get(url).block();
         assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+        url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=owner";
+        rsp = restClient().get(url).block();
+        assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+        url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=JUNK";
+        rsp = restClient().get(url).block();
+        assertThat(rsp).isEqualTo("[]");
     }
 
     @Test
@@ -283,8 +299,8 @@ class ApplicationTest {
 
         String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId";
         // The element with name "property1" is mandatory in the schema
-        ConsumerEiJobInfo jobInfo = new ConsumerEiJobInfo(jsonObject("{ \"XXstring\" : \"value\" }"), "owner",
-                "targetUri");
+        ConsumerEiJobInfo jobInfo =
+            new ConsumerEiJobInfo(jsonObject("{ \"XXstring\" : \"value\" }"), "owner", "targetUri");
         String body = gson.toJson(jobInfo);
 
         testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "Json validation failure");
@@ -328,7 +344,7 @@ class ApplicationTest {
         String url = ConsumerConsts.API_ROOT + "/eitypes/typeId2/eijobs/jobId";
         String body = gson.toJson(eiJobInfo());
         testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT,
-                "Not allowed to change type for existing EI job");
+            "Not allowed to change type for existing EI job");
     }
 
     @Test
@@ -447,7 +463,7 @@ class ApplicationTest {
     }
 
     private void assertProducerOpState(String producerId,
-            ProducerStatusInfo.OperationalState expectedOperationalState) {
+        ProducerStatusInfo.OperationalState expectedOperationalState) {
         String statusUrl = ProducerConsts.API_ROOT + "/eiproducers/" + producerId + "/status";
         ResponseEntity<String> resp = restClient().getForEntity(statusUrl).block();
         ProducerStatusInfo statusInfo = gson.fromJson(resp.getBody(), ProducerStatusInfo.class);
@@ -484,28 +500,28 @@ class ApplicationTest {
     }
 
     ProducerEiTypeRegistrationInfo producerEiTypeRegistrationInfo(String typeId)
-            throws JsonMappingException, JsonProcessingException {
+        throws JsonMappingException, JsonProcessingException {
         return new ProducerEiTypeRegistrationInfo(jsonSchemaObject(), typeId);
     }
 
     ProducerRegistrationInfo producerEiRegistratioInfoRejecting(String typeId)
-            throws JsonMappingException, JsonProcessingException {
+        throws JsonMappingException, JsonProcessingException {
         Collection<ProducerEiTypeRegistrationInfo> types = new ArrayList<>();
         types.add(producerEiTypeRegistrationInfo(typeId));
         return new ProducerRegistrationInfo(types, //
-                baseUrl() + ProducerSimulatorController.JOB_CREATED_ERROR_URL,
-                baseUrl() + ProducerSimulatorController.JOB_DELETED_ERROR_URL,
-                baseUrl() + ProducerSimulatorController.SUPERVISION_ERROR_URL);
+            baseUrl() + ProducerSimulatorController.JOB_CREATED_ERROR_URL,
+            baseUrl() + ProducerSimulatorController.JOB_DELETED_ERROR_URL,
+            baseUrl() + ProducerSimulatorController.SUPERVISION_ERROR_URL);
     }
 
     ProducerRegistrationInfo producerEiRegistratioInfo(String typeId)
-            throws JsonMappingException, JsonProcessingException {
+        throws JsonMappingException, JsonProcessingException {
         Collection<ProducerEiTypeRegistrationInfo> types = new ArrayList<>();
         types.add(producerEiTypeRegistrationInfo(typeId));
         return new ProducerRegistrationInfo(types, //
-                baseUrl() + ProducerSimulatorController.JOB_CREATED_URL,
-                baseUrl() + ProducerSimulatorController.JOB_DELETED_URL,
-                baseUrl() + ProducerSimulatorController.SUPERVISION_URL);
+            baseUrl() + ProducerSimulatorController.JOB_CREATED_URL,
+            baseUrl() + ProducerSimulatorController.JOB_DELETED_URL,
+            baseUrl() + ProducerSimulatorController.SUPERVISION_URL);
     }
 
     ConsumerEiJobInfo eiJobInfo() throws JsonMappingException, JsonProcessingException {
@@ -523,17 +539,17 @@ class ApplicationTest {
     Object jsonSchemaObject() {
         // a json schema with one mandatory property named "string"
         String schemaStr = "{" //
-                + "\"$schema\": \"http://json-schema.org/draft-04/schema#\"," //
-                + "\"type\": \"object\"," //
-                + "\"properties\": {" //
-                + EI_JOB_PROPERTY + " : {" //
-                + "    \"type\": \"string\"" //
-                + "  }" //
-                + "}," //
-                + "\"required\": [" //
-                + EI_JOB_PROPERTY //
-                + "]" //
-                + "}"; //
+            + "\"$schema\": \"http://json-schema.org/draft-04/schema#\"," //
+            + "\"type\": \"object\"," //
+            + "\"properties\": {" //
+            + EI_JOB_PROPERTY + " : {" //
+            + "    \"type\": \"string\"" //
+            + "  }" //
+            + "}," //
+            + "\"required\": [" //
+            + EI_JOB_PROPERTY //
+            + "]" //
+            + "}"; //
         return jsonObject(schemaStr);
     }
 
@@ -542,7 +558,7 @@ class ApplicationTest {
     }
 
     private EiJob putEiJob(String eiTypeId, String jobId)
-            throws JsonMappingException, JsonProcessingException, ServiceException {
+        throws JsonMappingException, JsonProcessingException, ServiceException {
 
         String url = ConsumerConsts.API_ROOT + "/eitypes/" + eiTypeId + "/eijobs/" + jobId;
         String body = gson.toJson(eiJobInfo());
@@ -552,7 +568,7 @@ class ApplicationTest {
     }
 
     private EiType putEiProducerWithOneTypeRejecting(String producerId, String eiTypeId)
-            throws JsonMappingException, JsonProcessingException, ServiceException {
+        throws JsonMappingException, JsonProcessingException, ServiceException {
         String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId;
         String body = gson.toJson(producerEiRegistratioInfoRejecting(eiTypeId));
 
@@ -561,7 +577,7 @@ class ApplicationTest {
     }
 
     private EiType putEiProducerWithOneType(String producerId, String eiTypeId)
-            throws JsonMappingException, JsonProcessingException, ServiceException {
+        throws JsonMappingException, JsonProcessingException, ServiceException {
         String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId;
         String body = gson.toJson(producerEiRegistratioInfo(eiTypeId));
 
@@ -576,14 +592,14 @@ class ApplicationTest {
     private AsyncRestClient restClient(boolean useTrustValidation) {
         WebClientConfig config = this.applicationConfig.getWebClientConfig();
         config = ImmutableWebClientConfig.builder() //
-                .keyStoreType(config.keyStoreType()) //
-                .keyStorePassword(config.keyStorePassword()) //
-                .keyStore(config.keyStore()) //
-                .keyPassword(config.keyPassword()) //
-                .isTrustStoreUsed(useTrustValidation) //
-                .trustStore(config.trustStore()) //
-                .trustStorePassword(config.trustStorePassword()) //
-                .build();
+            .keyStoreType(config.keyStoreType()) //
+            .keyStorePassword(config.keyStorePassword()) //
+            .keyStore(config.keyStore()) //
+            .keyPassword(config.keyPassword()) //
+            .isTrustStoreUsed(useTrustValidation) //
+            .trustStore(config.trustStore()) //
+            .trustStorePassword(config.trustStorePassword()) //
+            .build();
 
         return new AsyncRestClient(baseUrl(), config);
     }
@@ -597,16 +613,16 @@ class ApplicationTest {
     }
 
     private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains,
-            boolean expectApplicationProblemJsonMediaType) {
+        boolean expectApplicationProblemJsonMediaType) {
         StepVerifier.create(request) //
-                .expectSubscription() //
-                .expectErrorMatches(
-                        t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) //
-                .verify();
+            .expectSubscription() //
+            .expectErrorMatches(
+                t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) //
+            .verify();
     }
 
     private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains,
-            boolean expectApplicationProblemJsonMediaType) {
+        boolean expectApplicationProblemJsonMediaType) {
         assertTrue(throwable instanceof WebClientResponseException);
         WebClientResponseException responseException = (WebClientResponseException) throwable;
         assertThat(responseException.getStatusCode()).isEqualTo(expStatus);