Merge " ECS, deleting jobs when the type is deleted"
authorJohn Keeney <john.keeney@est.tech>
Thu, 2 Sep 2021 09:26:50 +0000 (09:26 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 2 Sep 2021 09:26:50 +0000 (09:26 +0000)
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java
enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java

index 29426ab..6c3c05d 100644 (file)
@@ -190,6 +190,7 @@ public class ProducerController {
             return ErrorResponse.create("The type has active producers: " + firstProducerId, HttpStatus.NOT_ACCEPTABLE);
         }
         this.infoTypes.remove(type);
+        infoJobs.getJobsForType(type).forEach(job -> infoJobs.remove(job, infoProducers)); // Delete jobs for the type
         this.typeSubscriptions.notifyTypeRemoved(type);
         return new ResponseEntity<>(HttpStatus.NO_CONTENT);
     }
index df938ad..12d4e47 100644 (file)
@@ -555,9 +555,12 @@ class ApplicationTest {
     @Test
     void producerDeleteEiType() throws Exception {
         putInfoType(TYPE_ID);
+        this.putEiJob(TYPE_ID, "job1");
+        this.putEiJob(TYPE_ID, "job2");
         deleteInfoType(TYPE_ID);
 
         assertThat(this.infoTypes.size()).isZero();
+        assertThat(this.infoJobs.size()).isZero(); // Test that also the job is deleted
 
         testErrorCode(restClient().delete(deleteInfoTypeUrl(TYPE_ID)), HttpStatus.NOT_FOUND,
             "Information type not found");