From 4b8ae57149d157cfe8619f99dd8fb82e067f26ce Mon Sep 17 00:00:00 2001 From: Ruslan Kashapov Date: Mon, 5 Apr 2021 12:59:57 +0300 Subject: Delete anchor part 1: service and persistence layers Issue-ID: CPS-312 Change-Id: I10ab5a2d115ffdf8179a99b6ec712f3eccfb5f13 Signed-off-by: Ruslan Kashapov --- .../src/main/java/org/onap/cps/api/CpsAdminService.java | 11 ++++++++++- .../main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java | 6 ++++++ .../java/org/onap/cps/spi/CpsAdminPersistenceService.java | 9 +++++++++ .../org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy | 8 ++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) (limited to 'cps-service/src') diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java index 0379ac21d..1e4c9c735 100755 --- a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java +++ b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,9 +63,17 @@ public interface CpsAdminService { * Get an anchor in the given dataspace using the anchor name. * * @param dataspaceName dataspace name - * @param anchorName anchor name + * @param anchorName anchor name * @return an anchor */ @NonNull Anchor getAnchor(@NonNull String dataspaceName, @NonNull String anchorName); + + /** + * Delete anchor by name in given dataspace. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + */ + void deleteAnchor(@NonNull String dataspaceName, @NonNull String anchorName); } diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java index 09550f193..25185731b 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,4 +53,9 @@ public class CpsAdminServiceImpl implements CpsAdminService { public Anchor getAnchor(final String dataspaceName, final String anchorName) { return cpsAdminPersistenceService.getAnchor(dataspaceName, anchorName); } + + @Override + public void deleteAnchor(final String dataspaceName, final String anchorName) { + cpsAdminPersistenceService.deleteAnchor(dataspaceName, anchorName); + } } \ No newline at end of file diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java index f47af5f97..35e07f83b 100755 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,4 +68,12 @@ public interface CpsAdminPersistenceService { */ @NonNull Anchor getAnchor(@NonNull String dataspaceName, @NonNull String anchorName); + + /** + * Delete anchor by name in given dataspace. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + */ + void deleteAnchor(@NonNull String dataspaceName, @NonNull String anchorName); } \ No newline at end of file diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy index 6631a2013..b1fc4dc7d 100755 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,4 +62,11 @@ class CpsAdminServiceImplSpec extends Specification { expect: 'the anchor provided by persistence service is returned as result' objectUnderTest.getAnchor('someDataspace','someAnchor') == anchor } + + def 'Delete anchor.'() { + when: 'delete anchor is invoked' + objectUnderTest.deleteAnchor('someDataspace','someAnchor') + then: 'associated persistence service method is invoked with same parameters' + 1 * mockCpsAdminPersistenceService.deleteAnchor('someDataspace','someAnchor') + } } -- cgit 1.2.3-korg