ECS, deleting jobs when the type is deleted 44/6644/1
authorPatrikBuhr <patrik.buhr@est.tech>
Wed, 1 Sep 2021 11:53:52 +0000 (13:53 +0200)
committerPatrikBuhr <patrik.buhr@est.tech>
Wed, 1 Sep 2021 11:55:38 +0000 (13:55 +0200)
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-576
Change-Id: I2c2f071528f3b2ec939375d24cbd3a537b41b4c9

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");