From 327c5996e5095ed30a8163f5c0b4e678fc0b3ca2 Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Wed, 1 Sep 2021 13:53:52 +0200 Subject: [PATCH] ECS, deleting jobs when the type is deleted Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-576 Change-Id: I2c2f071528f3b2ec939375d24cbd3a537b41b4c9 --- .../oransc/enrichment/controllers/r1producer/ProducerController.java | 1 + .../src/test/java/org/oransc/enrichment/ApplicationTest.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java index 29426ab0..6c3c05dd 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java @@ -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); } 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 df938adf..12d4e472 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 @@ -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"); -- 2.16.6