diff options
author | 2022-04-13 14:50:12 +0100 | |
---|---|---|
committer | 2022-04-21 09:48:22 +0000 | |
commit | 117fb0e50d4b83f2f3faa7c372458ef539c63664 (patch) | |
tree | ecc7f6cbbeebeb2cb4b933a6afc891812aacbddf /openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test | |
parent | 30ff812c65389f5ca4c91d9774d425e81ef62049 (diff) |
Support deletion of archived VLMs in onboarding
Issue-ID: SDC-3968
Signed-off-by: stasys10 <stasys.jurgaitis@est.tech>
Change-Id: I3f8a77e2ab40f7607920a781ac7ad2bb3c56741d
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test')
1 files changed, 39 insertions, 15 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImplTest.java index 48cb42d160..1728823888 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImplTest.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImplTest.java @@ -22,19 +22,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; @@ -55,8 +42,23 @@ import org.openecomp.sdc.versioning.AsdcItemManager; import org.openecomp.sdc.versioning.VersioningManager; import org.openecomp.sdc.versioning.dao.types.VersionStatus; import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.types.ItemStatus; import org.openecomp.sdcrests.vendorlicense.rest.exception.VendorLicenseModelExceptionSupplier; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.never; + class VendorLicenseModelsImplTest { @Mock @@ -151,7 +153,7 @@ class VendorLicenseModelsImplTest { } @Test - void deleteLicenseModel_cantDeleteCertifiedTest() { + void deleteLicenseModel_cantDeleteCertifiedAndNotArchivedTest() { //given final String vlmId = "vlmId"; final String vlmName = "vlmName"; @@ -162,13 +164,14 @@ class VendorLicenseModelsImplTest { vlmItem.setType(ItemType.vlm.getName()); vlmItem.setName(vlmName); vlmItem.setVersionStatusCounters(Map.of(VersionStatus.Certified, 1)); + vlmItem.setStatus(ItemStatus.ACTIVE); when(asdcItemManager.get(vlmId)).thenReturn(vlmItem); when(vendorSoftwareProductInfoDao.list(null)).thenReturn(Collections.emptyList()); //when final CoreException actualException = assertThrows(CoreException.class, () -> vendorLicenseModels.deleteLicenseModel(vlmId, userId)); //then - final CoreException expectedException = VendorLicenseModelExceptionSupplier.cantDeleteCertifiedVlm(vlmId).get(); + final CoreException expectedException = VendorLicenseModelExceptionSupplier.cantDeleteCertifiedAndNotArchivedVlm(vlmId).get(); assertEquals(expectedException.code().id(), actualException.code().id()); assertEquals(expectedException.code().message(), actualException.code().message()); assertEquals(expectedException.code().category(), actualException.code().category()); @@ -196,4 +199,25 @@ class VendorLicenseModelsImplTest { assertEquals(expectedException.code().message(), actualException.code().message()); } + @Test + void deleteLicenseModel_CertifiedAndArchivedTest() { + //given + final String vlmId = "vlmId"; + final String userId = "userId"; + final Item vlmItem = new Item(); + vlmItem.setId(vlmId); + vlmItem.setType(ItemType.vlm.getName()); + vlmItem.setStatus(ItemStatus.ARCHIVED); + vlmItem.addVersionStatus(VersionStatus.Certified); + when(asdcItemManager.get(vlmId)).thenReturn(vlmItem); + + //when + final Response response = vendorLicenseModels.deleteLicenseModel(vlmId, userId); + //then + assertEquals(Status.OK.getStatusCode(), response.getStatus()); + verify(asdcItemManager).delete(vlmItem); + verify(permissionsManager).deleteItemPermissions(vlmItem.getId()); + verify(uniqueValueUtil).deleteUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, vlmItem.getName()); + verify(notifier).notifySubscribers(any(Event.class), eq(userId)); + } }
\ No newline at end of file |