aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
authorJulien Fontaine <julien.fontaine@bell.ca>2021-03-02 18:18:30 -0500
committerKAPIL SINGAL <ks220y@att.com>2021-03-09 18:20:18 +0000
commitdc8d648fa7b642ca88c7b101ceb8188b5c5ed3e3 (patch)
tree5c95def0affe180dd1bb78e99511b6f6bbb1de33 /ms/blueprintsprocessor/functions
parentae01a98c93de3303ef9f0e1e83d0505bb8a1d12b (diff)
Add delete endpoint for config snapshot API
Add delete endpoint to delete config-snapshots based on resource-type, resource-id and resources-status. Issue-ID: CCSDK-3205 Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca> Change-Id: Id7954694bc93beba08a79139834cb6477cb8e44b
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt12
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt13
2 files changed, 25 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
index 382a1312f..cf7de679b 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
@@ -115,4 +115,16 @@ open class ResourceConfigSnapshotService(private val resourceConfigSnapshotRepos
}
storedSnapshot
}
+
+ suspend fun deleteByResourceIdAndResourceTypeAndStatus(
+ resourceId: String,
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status
+ ) {
+ resourceConfigSnapshotRepository.deleteByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status)
+ log.info(
+ "Deleted configuration snapshot for resourceId=($resourceId), " +
+ "resourceType=($resourceType), status=($status)"
+ )
+ }
}
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt
index f25b6f9c7..403f92bc9 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt
@@ -78,4 +78,17 @@ class ResourceConfigSnapshotServiceTest {
assertEquals(tr, res)
}
}
+
+ @Test
+ fun deleteResourceConfigSnapshot() {
+ runBlocking {
+ every {
+ cfgRepository.deleteByResourceIdAndResourceTypeAndStatus(any(), any(), any())
+ } returns Unit
+ cfgService.deleteByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, resourceStatus)
+ verify {
+ cfgRepository.deleteByResourceIdAndResourceTypeAndStatus(eq(resourceId), eq(resourceType), eq(resourceStatus))
+ }
+ }
+ }
}