From 8a782f62ec996be8ac8e1807fbe7276192fdc02d Mon Sep 17 00:00:00 2001 From: Julien Fontaine Date: Wed, 4 Mar 2020 16:09:26 -0500 Subject: add a rest endpoint to remove resources Issue-ID: CCSDK-2159 Signed-off-by: Julien Fontaine Change-Id: I504fa0aad6f4e7105a53e793d08d08d92bbb8df4 --- .../resolution/db/ResourceResolutionDBService.kt | 23 ++++++++++++++++++++++ .../resolution/db/ResourceResolutionRepository.kt | 9 +++++++++ .../db/ResourceResolutionDBServiceTest.kt | 12 +++++++++++ 3 files changed, 44 insertions(+) (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt index f8bf7bd09..dc1553747 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt @@ -198,4 +198,27 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso throw BluePrintException("Failed to store resource resolution result.", ex) } } + + /** + * This is a deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey method to delete resources + * associated to a specific resolution-key + * + * @param blueprintName name of the CBA + * @param blueprintVersion version of the CBA + * @param artifactName name of the artifact + * @param resolutionKey value of the resolution-key + */ + suspend fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey( + blueprintName: String, + blueprintVersion: String, + artifactName: String, + resolutionKey: String + ) { + resourceResolutionRepository.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey( + blueprintName, + blueprintVersion, + artifactName, + resolutionKey + ) + } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt index a2a3a753b..c2d630e5e 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository +import javax.transaction.Transactional @Repository interface ResourceResolutionRepository : JpaRepository { @@ -59,4 +60,12 @@ interface ResourceResolutionRepository : JpaRepository + + @Transactional + fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey( + blueprintName: String?, + blueprintVersion: String?, + artifactName: String, + resolutionKey: String + ) } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt index 4f864a49c..e667cd16f 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt @@ -223,4 +223,16 @@ open class ResourceResolutionDBServiceTest { assertEquals(resourceResolution, res) } } + + @Test + fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyTest() { + every { + resourceResolutionRepository.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(any(), any(), any(), any()) + } returns Unit + runBlocking { + val res = resourceResolutionDBService.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey( + blueprintName, blueprintVersion, artifactPrefix, resolutionKey) + assertEquals(Unit, res) + } + } } -- cgit 1.2.3-korg