diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org')
3 files changed, 29 insertions, 22 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java index 9479e08af8..217cdf585b 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java @@ -7,7 +7,6 @@ import org.mockito.Spy; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; @@ -196,18 +195,24 @@ public class ComputeManagerImplTest { public void testUpdateHEATComputeName() throws Exception { doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID)) .when(computeDao).get(anyObject()); + + String updatedName = COMPUTE1_ID + " name updated"; + CompositionEntityValidationData toBeReturned = + new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID); + + toBeReturned.setErrors(Arrays.asList("#/name: "+updatedName+" is not a valid value."+ + COMPUTE1_ID+"is the only possible value for this field")); + doReturn(toBeReturned).when(compositionEntityDataManagerMock).validateEntity(anyObject(),anyObject(),anyObject()); + ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID); ComputeData computeData = new ComputeData(); - computeData.setName(COMPUTE1_ID + " name updated"); + computeData.setName(updatedName); computeData.setDescription(COMPUTE1_ID + " desc updated"); computeEntity.setComputeCompositionData(computeData); - try { - computeManager.updateCompute(computeEntity); - } catch (CoreException ex) { - Assert - .assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED); - } + CompositionEntityValidationData output = computeManager.updateCompute(computeEntity); + + Assert.assertEquals(output.getErrors(), toBeReturned.getErrors()); } @Test 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 3a9af0d752..b44bf2d43d 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 @@ -184,17 +184,23 @@ public class ImageManagerImplTest { public void testUpdateHEATImageFileName() throws Exception { doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID)) .when(imageDao).get(anyObject()); + + String updatedName = IMAGE1_ID +" name updated"; + CompositionEntityValidationData toBeReturned = + new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID); + + toBeReturned.setErrors(Arrays.asList("#/name: "+updatedName+" is not a valid value."+ + IMAGE1_ID+"is the only possible value for this field")); + doReturn(toBeReturned).when(compositionEntityDataManagerMock).validateEntity(anyObject(),anyObject(),anyObject()); + ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID); Image imageData = new Image(); - imageData.setFileName(IMAGE1_ID + " name updated"); + imageData.setFileName(updatedName); imageData.setDescription(IMAGE1_ID + " desc updated"); imageEntity.setImageCompositionData(imageData); - try { - imageManager.updateImage(imageEntity); - } catch (CoreException ex) { - Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED); - } + CompositionEntityValidationData output = imageManager.updateImage(imageEntity); + Assert.assertEquals(output.getErrors(), toBeReturned.getErrors()); } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java index 9efb9e1d11..6ce0f1876c 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java @@ -350,7 +350,7 @@ public class NicManagerImplTest { CompositionEntityValidationData toBeReturned = new CompositionEntityValidationData(CompositionEntityType.nic, NIC1_ID); - toBeReturned.setErrors(Arrays.asList("error1", "error2")); + toBeReturned.setErrors(Arrays.asList("Field does not conform to predefined criteria:name : must match [a-zA-Z0-9_]*$")); doReturn(toBeReturned) .when(compositionEntityDataManagerMock) .validateEntity(anyObject(), anyObject(), anyObject()); @@ -363,13 +363,9 @@ public class NicManagerImplTest { nicData.setNetworkId(NETWORK1_ID); nicEntity.setNicCompositionData(nicData); - try { - nicManager.updateNic(nicEntity); - Assert.fail(); - } catch (CoreException ex) { - Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED, - ex.code().id()); - } + CompositionEntityValidationData output = nicManager.updateNic(nicEntity); + Assert.assertEquals(output.getErrors(),toBeReturned.getErrors()); + } |