diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org')
3 files changed, 209 insertions, 171 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java index afd797573a..5dcb7f9b62 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java @@ -1,32 +1,70 @@ package org.openecomp.sdc.vendorsoftwareproduct; -import org.openecomp.core.utilities.CommonMethods; -import org.openecomp.core.utilities.json.JsonUtil; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; -import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder; -import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes; -import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; -import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails; +import org.openecomp.sdc.vendorsoftwareproduct.impl.ImageManagerImpl; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; -import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.Collection; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; public class ImagesTest { + private static String VSP_ID = "VSP_ID"; + private static String COMP_ID = "COMP_ID"; + private static String ID = "ID"; + private static String USER = "USER"; + public static final Version VERSION01 = new Version(0, 1); + + @Mock + private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao; + + @Mock + private CompositionEntityDataManager compositionEntityDataManager; + + @InjectMocks + @Spy + private ImageManagerImpl imageManager; + + @BeforeMethod + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void createImage() + { + ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID); + doReturn(true).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject()); + + imageManager.createImage(imageEntity, USER); + verify(compositionEntityDataManager).createImage(imageEntity); + } + + @Test + public void createImageHeat() + { + ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID); + doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject()); + + try { + imageManager.createImage(imageEntity, USER); + Assert.fail(); + } catch (CoreException exception) { + Assert.assertEquals(exception.code().id(), VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING); + } + } /*private static final String USER1 = "imageTestUser1"; private static final String USER2 = "imageTestUser2"; private static final Version VERSION01 = new Version(0, 1); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java index d617bf9a47..741b1bf2ea 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java @@ -37,9 +37,9 @@ import static org.mockito.Mockito.verify; public class ImageManagerImplTest { private static final String IMAGE_NOT_EXIST_MSG = - "Vendor Software Product Image with Id image1 does not exist for Vendor Software Product with" + - " " + - "id VSP_ID and version 0.1"; + "Vendor Software Product Image with Id image1 does not exist for Vendor Software Product with" + + " " + + "id VSP_ID and version 0.1"; private static final String USER = "imageTestUser"; private static final String VSP_ID = "VSP_ID"; @@ -66,7 +66,7 @@ public class ImageManagerImplTest { @Test public void testListWhenNone() { final Collection<ImageEntity> imageEntities = - imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER); + imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER); Assert.assertEquals(imageEntities.size(), 0); } @@ -74,17 +74,17 @@ public class ImageManagerImplTest { public void testList() { doReturn(Arrays.asList( - createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID), - createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE2_ID))) - .when(imageDao).list(anyObject()); + createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID), + createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE2_ID))) + .when(imageDao).list(anyObject()); final Collection<ImageEntity> images = - imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER); + imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER); Assert.assertEquals(images.size(), 2); for (ImageEntity image : images) { Assert.assertEquals(image.getImageCompositionData().getFileName(), - IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID+"_name" : IMAGE2_ID+"_name" ); + IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID+"_name" : IMAGE2_ID+"_name" ); } } @@ -92,7 +92,7 @@ public class ImageManagerImplTest { public void testCreateOnNotManualImage_negative() { testCreate_negative(new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER, - VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING); + VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING); } @Test @@ -104,7 +104,7 @@ public class ImageManagerImplTest { verify(compositionEntityDataManagerMock).createImage(expected); } - @Test + /*@Test public void testCreateManualImageWithDuplicateName() { ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID); doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject()); @@ -124,22 +124,22 @@ public class ImageManagerImplTest { Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED, ex.code().id()); } - } + }*/ @Test public void testUpdateNonExistingImageId_negative() { testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER, - VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND); + VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND); } @Test public void testUpdateImage() { doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID)) - .when(imageDao).get(anyObject()); + .when(imageDao).get(anyObject()); doReturn(new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID)) - .when(compositionEntityDataManagerMock) - .validateEntity(anyObject(), anyObject(), anyObject()); + .when(compositionEntityDataManagerMock) + .validateEntity(anyObject(), anyObject(), anyObject()); ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID); Image imageData = new Image(); @@ -148,7 +148,7 @@ public class ImageManagerImplTest { imageEntity.setImageCompositionData(imageData); CompositionEntityValidationData validationData = - imageManager.updateImage(imageEntity, USER); + imageManager.updateImage(imageEntity, USER); Assert.assertTrue(validationData == null || validationData.getErrors() == null); verify(imageDao).update(imageEntity); } @@ -156,16 +156,16 @@ public class ImageManagerImplTest { @Test public void testIllegalImageUpdate() { doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID)) - .when(imageDao).get(anyObject()); + .when(imageDao).get(anyObject()); doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject()); CompositionEntityValidationData toBeReturned = - new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID); + new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID); toBeReturned.setErrors(Arrays.asList("error1", "error2")); doReturn(toBeReturned) - .when(compositionEntityDataManagerMock) - .validateEntity(anyObject(), anyObject(), anyObject()); + .when(compositionEntityDataManagerMock) + .validateEntity(anyObject(), anyObject(), anyObject()); ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID); Image imageData = new Image(); @@ -183,7 +183,7 @@ public class ImageManagerImplTest { @Test public void testUpdateHEATImageFileName() throws Exception { doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID)) - .when(imageDao).get(anyObject()); + .when(imageDao).get(anyObject()); ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID); Image imageData = new Image(); imageData.setFileName(IMAGE1_ID + " name updated"); @@ -202,7 +202,7 @@ public class ImageManagerImplTest { @Test public void testGetNonExistingImageId_negative() { testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing image id", USER, - VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND); + VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND); } @Test @@ -213,12 +213,12 @@ public class ImageManagerImplTest { doReturn(compositionSchema).when(imageManager).getImageCompositionSchema(anyObject()); CompositionEntityResponse<Image> response = - imageManager.getImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER); + imageManager.getImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER); Assert.assertEquals(response.getId(), expected.getId()); Assert.assertEquals(response.getData().getFileName(), expected.getImageCompositionData(). - getFileName()); + getFileName()); Assert.assertEquals(response.getData().getDescription(), expected.getImageCompositionData(). - getDescription()); + getDescription()); Assert.assertEquals(response.getSchema(), compositionSchema); } @@ -227,13 +227,13 @@ public class ImageManagerImplTest { ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID); doReturn(expected).when(imageDao).get(anyObject()); testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER, - VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED); + VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED); } @Test public void testDeleteOnNotExistImage() { testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER, - VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND); + VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND); } @Test @@ -255,7 +255,7 @@ public class ImageManagerImplTest { doReturn(schema).when(imageManager).getImageQuestionnaireSchema(anyObject()); QuestionnaireResponse questionnaire = - imageManager.getImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER); + imageManager.getImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER); Assert.assertNotNull(questionnaire); Assert.assertEquals(questionnaire.getData(), image.getQuestionnaireData()); Assert.assertEquals(questionnaire.getSchema(), schema); @@ -334,7 +334,7 @@ public class ImageManagerImplTest { String updJson = "{\"format\" :\"a22\"}"; try { imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson, - USER); + USER); Assert.fail(); } catch(CoreException ex) { @@ -383,7 +383,7 @@ public class ImageManagerImplTest { } private void testUpdate_negative(String vspId, Version version, String componentId, String - imageId, String user, String expectedErrorCode) { + imageId, String user, String expectedErrorCode) { try { imageManager.updateImage(new ImageEntity(vspId, version, componentId, imageId), user); Assert.fail(); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java index 2fc4385563..4ead8a57d2 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java @@ -169,10 +169,10 @@ public class VendorSoftwareProductManagerImplTest { @Test public void testListWhenNone() { doReturn(new HashMap<>()).when(versioningManagerMock).listEntitiesVersionInfo - (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, - VersionableEntityAction.Read); + (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, + VersionableEntityAction.Read); List<VersionedVendorSoftwareProductInfo> vsps = - vendorSoftwareProductManager.listVsps(null, USER1); + vendorSoftwareProductManager.listVsps(null, USER1); Assert.assertEquals(vsps.size(), 0); } @@ -191,16 +191,16 @@ public class VendorSoftwareProductManagerImplTest { vspsTobeReturned.put(vsp2id, versionInfo2); doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo - (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, - VersionableEntityAction.Read); + (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, + VersionableEntityAction.Read); VspDetails vsp1 = new VspDetails(vsp1id, VERSION01); vsp1.setWritetimeMicroSeconds(8L); doReturn(vsp1).when(vspInfoDaoMock) - .get(any(VspDetails.class)); + .get(any(VspDetails.class)); List<VersionedVendorSoftwareProductInfo> vsps = - vendorSoftwareProductManager.listVsps(null, USER1); + vendorSoftwareProductManager.listVsps(null, USER1); Assert.assertEquals(vsps.size(), 2); } @@ -219,11 +219,11 @@ public class VendorSoftwareProductManagerImplTest { vspsTobeReturned.put(vsp2id, versionInfo2); doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo - (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, - VersionableEntityAction.Read); + (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, + VersionableEntityAction.Read); List<VersionedVendorSoftwareProductInfo> vsps = - vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1); + vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1); Assert.assertEquals(vsps.size(), 0); } @@ -243,27 +243,27 @@ public class VendorSoftwareProductManagerImplTest { vspsTobeReturned.put(vsp2id, versionInfo2); doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo - (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, - VersionableEntityAction.Read); + (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1, + VersionableEntityAction.Read); VspDetails vsp2 = new VspDetails(vsp2id, VERSION10); vsp2.setWritetimeMicroSeconds(8L); doReturn(vsp2).when(vspInfoDaoMock) - .get(any(VspDetails.class)); + .get(any(VspDetails.class)); List<VersionedVendorSoftwareProductInfo> vsps = - vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1); + vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1); Assert.assertEquals(vsps.size(), 1); } @Test(expectedExceptions = CoreException.class) public void testCreateWithExistingName_negative() { doThrow(new CoreException( - new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build())) - .when(vendorSoftwareProductManager).validateUniqueName("Vsp1"); + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build())) + .when(vendorSoftwareProductManager).validateUniqueName("Vsp1"); VspDetails expectedVsp = - createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", - "category", "subCategory", "123", null); + createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", + "category", "subCategory", "123", null); vendorSoftwareProductManager.createVsp(expectedVsp, USER1); } @@ -274,11 +274,11 @@ public class VendorSoftwareProductManagerImplTest { doNothing().when(vendorSoftwareProductManager).createUniqueName("Vsp1"); doReturn(VERSION01).when(versioningManagerMock).create(anyObject(), anyObject(), anyObject()); doReturn("{}") - .when(vendorSoftwareProductManager).getVspQuestionnaireSchema(anyObject()); + .when(vendorSoftwareProductManager).getVspQuestionnaireSchema(anyObject()); VspDetails vspToCreate = - createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", - "category", "subCategory", "123", null); + createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", + "category", "subCategory", "123", null); VspDetails vsp = vendorSoftwareProductManager.createVsp(vspToCreate, USER1); @@ -297,21 +297,21 @@ public class VendorSoftwareProductManagerImplTest { VersionInfo versionInfo = new VersionInfo(); versionInfo.setActiveVersion(VERSION01); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, - VersionableEntityAction.Write); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, + VersionableEntityAction.Write); VspDetails existingVsp = - createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-existingVsp", "vendorName", "vlm1Id", - "icon", "category", "subCategory", "123", null); + createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-existingVsp", "vendorName", "vlm1Id", + "icon", "category", "subCategory", "123", null); VspDetails updatedVsp = - createVspDetails(VSP_ID, VERSION01, "Vsp1_updated", "Test-existingVsp", "vendorName", - "vlm1Id", "icon", "category", "subCategory", "123", null); + createVspDetails(VSP_ID, VERSION01, "Vsp1_updated", "Test-existingVsp", "vendorName", + "vlm1Id", "icon", "category", "subCategory", "123", null); doReturn(existingVsp).when(vspInfoDaoMock) - .get(any(VspDetails.class)); + .get(any(VspDetails.class)); doThrow(new CoreException( - new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build())) - .when(vendorSoftwareProductManager) - .updateUniqueName(existingVsp.getName(), updatedVsp.getName()); + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build())) + .when(vendorSoftwareProductManager) + .updateUniqueName(existingVsp.getName(), updatedVsp.getName()); vendorSoftwareProductManager.updateVsp(updatedVsp, USER1); } @@ -321,21 +321,21 @@ public class VendorSoftwareProductManagerImplTest { VersionInfo versionInfo = new VersionInfo(); versionInfo.setActiveVersion(VERSION01); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, - VersionableEntityAction.Write); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, + VersionableEntityAction.Write); VspDetails existingVsp = - createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", - "category", - "subCategory", "456", null); + createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", + "category", + "subCategory", "456", null); VspDetails updatedVsp = - createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon", - "category_updated", - "subCategory", "456", null); + createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon", + "category_updated", + "subCategory", "456", null); existingVsp.setWritetimeMicroSeconds(8L); doReturn(existingVsp).when(vspInfoDaoMock) - .get(any(VspDetails.class)); + .get(any(VspDetails.class)); doNothing().when(vendorSoftwareProductManager) - .updateUniqueName(existingVsp.getName(), updatedVsp.getName()); + .updateUniqueName(existingVsp.getName(), updatedVsp.getName()); vendorSoftwareProductManager.updateVsp(updatedVsp, USER1); @@ -347,26 +347,26 @@ public class VendorSoftwareProductManagerImplTest { VersionInfo versionInfo = new VersionInfo(); versionInfo.setActiveVersion(VERSION01); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, - VersionableEntityAction.Write); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, + VersionableEntityAction.Write); List<String> fgs = new ArrayList<String>(); fgs.add("fg1"); fgs.add("fg2"); VspDetails existingVsp = - createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", - "category", - "subCategory", "456", fgs); + createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", + "category", + "subCategory", "456", fgs); List<String> updFgs = new ArrayList<String>(); - updFgs.add("fg2"); + //updFgs.add("fg2"); VspDetails updatedVsp = - createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon", - "category_updated", - "subCategory", "456", updFgs); + createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon", + "category_updated", + "subCategory", "456", updFgs); existingVsp.setWritetimeMicroSeconds(8L); doReturn(existingVsp).when(vspInfoDaoMock) - .get(any(VspDetails.class)); + .get(any(VspDetails.class)); doNothing().when(vendorSoftwareProductManager) - .updateUniqueName(existingVsp.getName(), updatedVsp.getName()); + .updateUniqueName(existingVsp.getName(), updatedVsp.getName()); DeploymentFlavorEntity dfEntity = new DeploymentFlavorEntity(VSP_ID,VERSION01,"DF_ID"); DeploymentFlavor flavor = new DeploymentFlavor(); @@ -400,18 +400,18 @@ public class VendorSoftwareProductManagerImplTest { versionInfo.setStatus(VersionStatus.Locked); versionInfo.setLockingUser(USER1); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, - VersionableEntityAction.Read); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, + VersionableEntityAction.Read); VspDetails existingVsp = - createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", - "category", - "subCategory", "456", null); + createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", + "category", + "subCategory", "456", null); existingVsp.setWritetimeMicroSeconds(8L); doReturn(existingVsp).when(vspInfoDaoMock).get(any(VspDetails.class)); VspDetails actualVsp = - vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1); + vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1); assertVspsEquals(actualVsp, existingVsp); } @@ -424,37 +424,37 @@ public class VendorSoftwareProductManagerImplTest { versionInfo.setStatus(VersionStatus.Locked); versionInfo.setLockingUser(USER2); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, - VersionableEntityAction.Read); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, + VersionableEntityAction.Read); VspDetails existingVsp = - createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", - "category", - "subCategory", "456", null); + createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon", + "category", + "subCategory", "456", null); existingVsp.setWritetimeMicroSeconds(8L); doReturn(existingVsp) - .when(vspInfoDaoMock).get(any(VspDetails.class)); + .when(vspInfoDaoMock).get(any(VspDetails.class)); VspDetails actualVsp = - vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1); + vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1); VspDetails expectedVsp = - vspInfoDaoMock - .get(new VspDetails(VSP_ID, VERSION01)); + vspInfoDaoMock + .get(new VspDetails(VSP_ID, VERSION01)); assertVspsEquals(actualVsp, expectedVsp); } @Test public void testCheckin() { doReturn(VERSION01).when(versioningManagerMock) - .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, - USER1, null); + .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1, null); Version version = vendorSoftwareProductManager.checkin(VSP_ID, USER1); Assert.assertEquals(version, VERSION01); verify(versioningManagerMock) - .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, - USER1, null); + .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1, null); verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1)); ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue(); Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1)); @@ -464,14 +464,14 @@ public class VendorSoftwareProductManagerImplTest { @Test public void testCheckout() { doReturn(VERSION01).when(versioningManagerMock) - .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, - USER1); + .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1); Version version = vendorSoftwareProductManager.checkout(VSP_ID, USER1); Assert.assertEquals(version, VERSION01); verify(versioningManagerMock) - .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, - USER1); + .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1); verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1)); ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue(); @@ -486,11 +486,11 @@ public class VendorSoftwareProductManagerImplTest { VersionInfo versionInfo = new VersionInfo(); versionInfo.setActiveVersion(existingVersion); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, - VSP_ID, USER1, VersionableEntityAction.Read); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, + VSP_ID, USER1, VersionableEntityAction.Read); doReturn(VERSION01).when(versioningManagerMock).undoCheckout(VendorSoftwareProductConstants - .VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1); + .VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1); VspDetails vsp = new VspDetails(VSP_ID, existingVersion); vsp.setName("ExistingName"); @@ -552,22 +552,22 @@ public class VendorSoftwareProductManagerImplTest { VersionInfo versionInfo = new VersionInfo(); versionInfo.setActiveVersion(VERSION01); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, - VSP_ID, USER1, VersionableEntityAction.Read); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, + VSP_ID, USER1, VersionableEntityAction.Read); VspDetails vsp = - createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", - "category", "subCategory", "licenseAgreementId", - Collections.singletonList("featureGroupId")); + createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", + "category", "subCategory", "licenseAgreementId", + Collections.singletonList("featureGroupId")); doReturn(vsp).when(vspInfoDaoMock).get(anyObject()); UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01); uploadData.setContentData( - ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition")))); + ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition")))); doReturn(uploadData).when(orchestrationTemplateDataDaoMock) - .getOrchestrationTemplate(anyObject(), anyObject()); + .getOrchestrationTemplate(anyObject(), anyObject()); doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(), - "MainServiceTemplate.yaml")) - .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01); + "MainServiceTemplate.yaml")) + .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01); ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1); Assert.assertNotNull(validationResponse); @@ -576,8 +576,8 @@ public class VendorSoftwareProductManagerImplTest { Assert.assertEquals(validationResponse.getLicensingDataErrors(), 1); verify(versioningManagerMock, never()) - .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, - USER1, null); + .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1, null); //TODO - check.. verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1)); @@ -590,20 +590,20 @@ public class VendorSoftwareProductManagerImplTest { EnrichmentManagerFactory.getInstance(); AbstractFactoryBase - .registerFactory(EnrichmentManagerFactory.class, EnrichmentManagerFactoryImpl.class); + .registerFactory(EnrichmentManagerFactory.class, EnrichmentManagerFactoryImpl.class); VspDetails vsp = - createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", - "category", "subCategory", "123", Collections.singletonList("fg1")); + createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", + "category", "subCategory", "123", Collections.singletonList("fg1")); doReturn(vsp).when(vspInfoDaoMock).get(anyObject()); UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01); uploadData.setContentData( - ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition")))); + ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition")))); doReturn(uploadData).when(orchestrationTemplateDataDaoMock) - .getOrchestrationTemplate(anyObject(), anyObject()); + .getOrchestrationTemplate(anyObject(), anyObject()); doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(), - "MainServiceTemplate.yaml")) - .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01); + "MainServiceTemplate.yaml")) + .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01); ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1); Assert.assertTrue(validationResponse.isValid()); @@ -613,8 +613,8 @@ public class VendorSoftwareProductManagerImplTest { Assert.assertNull(vsp2.getVersionInfo().getLockingUser());*/ verify(versioningManagerMock) - .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, - USER1, null); + .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1, null); verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1)); ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue(); Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor())); @@ -633,11 +633,11 @@ public class VendorSoftwareProductManagerImplTest { VersionInfo versionInfo = new VersionInfo(); versionInfo.setActiveVersion(VERSION10); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, - VersionableEntityAction.Read); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, + VersionableEntityAction.Read); doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(), "")).when - (enrichedServiceModelDaoMock).getServiceModel(VSP_ID, VERSION10); + (enrichedServiceModelDaoMock).getServiceModel(VSP_ID, VERSION10); VspDetails vsp = new VspDetails(VSP_ID, VERSION10); vsp.setVendorId("vendorId"); @@ -646,8 +646,8 @@ public class VendorSoftwareProductManagerImplTest { doReturn(vsp).when(vspInfoDaoMock).get(any(VspDetails.class)); doReturn(new FileContentHandler()).when(licenseArtifactsServiceMock) - .createLicenseArtifacts(VSP_ID, vsp.getVendorId(), VERSION10, vsp.getFeatureGroups(), - USER1); + .createLicenseArtifacts(VSP_ID, vsp.getVendorId(), VERSION10, vsp.getFeatureGroups(), + USER1); PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(VSP_ID, VERSION10, USER1); Assert.assertNotNull(packageInfo.getVspId()); @@ -659,7 +659,7 @@ public class VendorSoftwareProductManagerImplTest { InputStream zis = getFileInputStream("/vspmanager/zips/missingYml.zip"); UploadFileResponse uploadFileResponse = - candidateManager.upload(VSP_ID, VERSION01, zis, USER1); + candidateManager.upload(VSP_ID, VERSION01, zis, USER1); Assert.assertEquals(uploadFileResponse.getErrors().size(), 0); } @@ -671,8 +671,8 @@ public class VendorSoftwareProductManagerImplTest { try { candidateManager - .upload(VSP_ID, VERSION01, - url.openStream(), USER1); + .upload(VSP_ID, VERSION01, + url.openStream(), USER1); candidateManager.process(VSP_ID, VERSION01, USER1); } catch (Exception ce) { Assert.assertEquals(ce.getMessage(), Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()); @@ -783,15 +783,15 @@ public class VendorSoftwareProductManagerImplTest { }*/ private List<String> getWantedFileNamesFromCsar(String pathInCsar) - throws IOException { + throws IOException { File translatedFile = vendorSoftwareProductManager.getTranslatedFile(VSP_ID, VERSION10, USER1); return getFileNamesFromFolderInCsar(translatedFile, - pathInCsar); + pathInCsar); } private List<String> getFileNamesFromFolderInCsar(File csar, String folderName) - throws IOException { + throws IOException { List<String> fileNames = new ArrayList<>(); ZipInputStream zip = new ZipInputStream(new FileInputStream(csar)); @@ -823,7 +823,7 @@ public class VendorSoftwareProductManagerImplTest { }*/ private void createPackageFromUpload(String vspId, String user, String filePath) - throws IOException { + throws IOException { uploadFileAndProcess(vspId, user, filePath); checkinSubmitCreatePackage(vspId, user); } @@ -892,7 +892,7 @@ public class VendorSoftwareProductManagerImplTest { candidateManager.process(vspId, VERSION01, user); UploadDataEntity uploadData = - orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version); + orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version); Assert.assertNotNull(uploadData); } @@ -914,7 +914,7 @@ public class VendorSoftwareProductManagerImplTest { private void assertVSPInWantedLocationInVSPList(String vspId, int location, String user) { List<VersionedVendorSoftwareProductInfo> vspList = - vendorSoftwareProductManager.listVsps(null, user); + vendorSoftwareProductManager.listVsps(null, user); Assert.assertEquals(vspList.get(location).getVspDetails().getId(), vspId); } @@ -1013,24 +1013,24 @@ public class VendorSoftwareProductManagerImplTest { VersionInfo versionInfo = new VersionInfo(); versionInfo.setActiveVersion(VERSION01); doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, - action); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1, + action); } private void mockVersioningEntityNotExist(VersionableEntityAction action, String vspId) { doThrow(new CoreException(new EntityNotExistErrorBuilder( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId).build())) - .when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId, USER1, - action); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId).build())) + .when(versioningManagerMock).getEntityVersionInfo( + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId, USER1, + action); } private void MockVersioningEntityLocked(VersionableEntityAction action) { doThrow(new CoreException(new EditOnEntityLockedByOtherErrorBuilder( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1) - .build())) - .when(versioningManagerMock).getEntityVersionInfo( - VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER2, - action); + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1) + .build())) + .when(versioningManagerMock).getEntityVersionInfo( + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER2, + action); } }
\ No newline at end of file |