diff options
Diffstat (limited to 'asdc-tests/src/main/java')
20 files changed, 214 insertions, 7817 deletions
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java index a8342f8879..0e1c0e4da1 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java @@ -163,6 +163,7 @@ public interface Urls { final String GET_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s"; final String GET_RESOURCE_BY_NAME_AND_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/resources/resourceName/%s/resourceVersion/%s"; final String GET_RESOURCE_BY_CSAR_UUID = "http://%s:%s/sdc2/rest/v1/catalog/resources/csar/%s"; + final String GET_RESOURCE_DATA_BY_PARAMS = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/filteredDataByParams?"; final String GET_COMPONENT_REQUIRMENTS_CAPABILITIES = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirmentsCapabilities"; final String DELETE_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s"; @@ -270,7 +271,6 @@ public interface Urls { final String GET_COMPONENT_INSTANCES = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances"; //{containerComponentType}/{containerComponentId}/componentInstances/{componentInstanceUniqueId}/properties final String GET_COMPONENT_INSTANCE_PROPERTIES_BY_ID = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances/%s/properties"; - // Tal New API final String UPDATE_MULTIPLE_COMPONENT_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/multipleComponentInstance"; final String CHANGE_RESOURCE_INSTANCE_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/changeVersion"; diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java index d1b6ff5676..b1d04ba88d 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java @@ -31,7 +31,7 @@ import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.ComponentInstanceAttribute; +import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; @@ -69,13 +69,13 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest { .addComponentInstanceToComponentContainer(vfcWithAttributes, vf).left().value(); // util method to get the specific attribute from the vf - Function<Resource, ComponentInstanceAttribute> attributeGetter = resourceVf -> resourceVf + Function<Resource, ComponentInstanceProperty> attributeGetter = resourceVf -> resourceVf .getComponentInstancesAttributes().values().iterator().next().stream() .filter(att -> att.getName().equals("private_address")).findAny().get(); // update attribute on vfc instance final Resource vfWithInsatncePreUpdate = swallowException( () -> (Resource) AtomicOperationUtils.getCompoenntObject(vf, UserRoleEnum.DESIGNER)); - ComponentInstanceAttribute attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate); + ComponentInstanceProperty attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate); final String newAttValue = "NewValue"; attributeOfRI.setValue(newAttValue); String body = gson.toJson(attributeOfRI); @@ -87,7 +87,7 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest { // Retrieve updated vf and verify attribute was updated final Resource vfWithInsatncePostUpdate = swallowException( () -> (Resource) AtomicOperationUtils.getCompoenntObject(vf, UserRoleEnum.DESIGNER)); - ComponentInstanceAttribute updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate); + ComponentInstanceProperty updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate); assertEquals(updatedAttribute.getValue(), newAttValue); } diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ValidateConformanceLevel.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ValidateConformanceLevel.java index 08e7539b28..24c91935d4 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ValidateConformanceLevel.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ValidateConformanceLevel.java @@ -63,13 +63,40 @@ public class ValidateConformanceLevel extends ComponentBaseTest { Service serviceFirstImport = ResponseParser.parseToObjectUsingMapper(createdService.getResponse(), Service.class); Component serviceObject = AtomicOperationUtils.changeComponentState(serviceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - RestResponse apiRes = ComponentRestUtils.validateConformanceLevel(serviceObject.getUniqueId(), user.getUserId()); + RestResponse apiRes = ComponentRestUtils.validateConformanceLevel(serviceObject.getUUID(), user.getUserId()); String result = apiRes.getResponse(); assertTrue(apiRes.getErrorCode() == 200); assertTrue(result.equals("true")); } @Test + public void testValidateServiceConformanceLevelForSecondMajorVersion() throws Exception { + User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + ServiceReqDetails service = ElementFactory.getDefaultService(); + RestResponse createdService = ServiceRestUtils.createService(service, user); + BaseRestUtils.checkCreateResponse(createdService); + Service serviceFirstImport = ResponseParser.parseToObjectUsingMapper(createdService.getResponse(), Service.class); + Component serviceObject = AtomicOperationUtils.changeComponentState(serviceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + String uuid1 = serviceObject.getUUID(); + Component service20Object = AtomicOperationUtils.changeComponentState(serviceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service20Object = AtomicOperationUtils.changeComponentState(service20Object, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + String uuid2 = service20Object.getUUID(); + + assertTrue(uuid1 != uuid2); + + RestResponse apiRes = ComponentRestUtils.validateConformanceLevel(uuid1, user.getUserId()); + String result = apiRes.getResponse(); + assertTrue(apiRes.getErrorCode() == 200); + assertTrue(result.equals("true")); + + apiRes = ComponentRestUtils.validateConformanceLevel(uuid2, user.getUserId()); + result = apiRes.getResponse(); + assertTrue(apiRes.getErrorCode() == 200); + assertTrue(result.equals("true")); + } + + @Test public void testValidateConformanceLevel404() throws Exception { User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); RestResponse apiRes = ComponentRestUtils.validateConformanceLevel("fake-uuid-for-test", user.getUserId()); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/FilteredDataByParamsComponentServletTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/FilteredDataByParamsComponentServletTest.java new file mode 100644 index 0000000000..541294c141 --- /dev/null +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/FilteredDataByParamsComponentServletTest.java @@ -0,0 +1,124 @@ +package org.openecomp.sdc.ci.tests.execute.imports; + +import static org.testng.AssertJUnit.assertEquals; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.codec.binary.Base64; +import org.junit.rules.TestName; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer; +import org.openecomp.sdc.be.ui.model.UiResourceDataTransfer; +import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; +import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.testng.annotations.Test; + + + +public class FilteredDataByParamsComponentServletTest extends ComponentBaseTest{ + + private static final String CSAR_NAME = "LDSA1_with_inputs.csar"; + private static final String COMPONENT_INSTANCES = "include=componentInstances"; + private static final String COMPONENT_INSTANCES_RELATIONS = "include=componentInstancesRelations"; + private static final String DEPLOYMENT_ARTIFACTS = "include=deploymentArtifacts"; + private static final String INFORMATIONAL_ARTIFACTS = "include=artifacts"; + private static final String METADATA = "include=metadata"; + public static TestName name = new TestName(); + + + + protected User designerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + public FilteredDataByParamsComponentServletTest() { + super(name, ImportCsarResourceTest.class.getName()); + } + + + @Test + public void getComponentInstancesAndComponentInstancesRelationsTest() throws Exception { + Resource resource = ResourceRestUtils.importResourceFromCsar(CSAR_NAME); + List<String> parameters = new ArrayList<>(); + parameters.add(COMPONENT_INSTANCES); + parameters.add(COMPONENT_INSTANCES_RELATIONS); + // create UiComponentDataTransfer and parse the ComponentInstancesRelations into it + RestResponse resourceGetResponse = ResourceRestUtils.getResourceFilteredDataByParams(designerDetails, resource.getUniqueId() , parameters); + UiComponentDataTransfer uiComponentWithComponentInstancesAndRelations = ResponseParser.parseToObjectUsingMapper(resourceGetResponse.getResponse() , UiComponentDataTransfer.class); + + uiComponentWithComponentInstancesAndRelations.getComponentInstances().stream().sorted((object1, object2) -> object1.getUniqueId().compareTo(object2.getUniqueId())); + resource.getComponentInstances().stream().sorted((object1, object2) -> object1.getUniqueId().compareTo(object2.getUniqueId())); + + for (int i = 0 ; i < resource.getComponentInstances().size() ; i++){ + assertEquals(uiComponentWithComponentInstancesAndRelations.getComponentInstances().get(i).getUniqueId() ,resource.getComponentInstances().get(i).getUniqueId()); + } + assertEquals(uiComponentWithComponentInstancesAndRelations.getComponentInstancesRelations().size() , resource.getComponentInstancesRelations().size()); + } + + + @Test + public void getComponentDeploymentAndInformationalArtifacts() throws Exception { + Resource resource = ResourceRestUtils.importResourceFromCsar(CSAR_NAME); + List<String> parameters = new ArrayList<>(); + parameters.add(DEPLOYMENT_ARTIFACTS); + parameters.add(INFORMATIONAL_ARTIFACTS); + + // create new UiComponentData transfer and parse the artifacts into it + RestResponse resourceGetResponse = ResourceRestUtils.getResourceFilteredDataByParams(designerDetails, resource.getUniqueId() , parameters); + UiComponentDataTransfer uiComponentWithArtifacts = ResponseParser.parseToObjectUsingMapper(resourceGetResponse.getResponse() , UiComponentDataTransfer.class); + + List<ArtifactDefinition> deploymentArtifactsFromResource = new ArrayList<ArtifactDefinition>(resource.getDeploymentArtifacts().values()); + List<ArtifactDefinition> deploymentArtifactsFromUiComponent = new ArrayList<ArtifactDefinition>(uiComponentWithArtifacts.getDeploymentArtifacts().values()); + List<ArtifactDefinition> informationalArtifactsFromResource = new ArrayList<ArtifactDefinition>(resource.getArtifacts().values()); + List<ArtifactDefinition> informationalArtifactsFromUiComponent = new ArrayList<ArtifactDefinition>(uiComponentWithArtifacts.getArtifacts().values()); + + deploymentArtifactsFromResource.stream().sorted((object1, object2) -> object1.getUniqueId().compareTo(object2.getUniqueId())); + deploymentArtifactsFromUiComponent.stream().sorted((object1, object2) -> object1.getUniqueId().compareTo(object2.getUniqueId())); + informationalArtifactsFromResource.stream().sorted((object1, object2) -> object1.getUniqueId().compareTo(object2.getUniqueId())); + informationalArtifactsFromUiComponent.stream().sorted((object1, object2) -> object1.getUniqueId().compareTo(object2.getUniqueId())); + + for (int i = 0 ; i < deploymentArtifactsFromResource.size() ; i++){ + assertEquals(deploymentArtifactsFromResource.get(i).getUniqueId() , deploymentArtifactsFromUiComponent.get(i).getUniqueId()); + } + + for (int i = 0 ; i < informationalArtifactsFromResource.size() ; i++){ + assertEquals(informationalArtifactsFromResource.get(i).getUniqueId() , informationalArtifactsFromUiComponent.get(i).getUniqueId()); + } + } + + + @Test + public void getComponentMetadataTest() throws Exception { + + Resource resource = ResourceRestUtils.importResourceFromCsar(CSAR_NAME); + List<String> parameters = new ArrayList<>(); + parameters.add(METADATA); + + // create new UiResourceDataTransfer and parse the metadata into it + RestResponse resourceGetResponse = ResourceRestUtils.getResourceFilteredDataByParams(designerDetails, resource.getUniqueId() , parameters); + UiResourceDataTransfer uiResourceWithMetadata = ResponseParser.parseToObjectUsingMapper(resourceGetResponse.getResponse(), UiResourceDataTransfer.class); + + // assert that the metadata is equal + assertEquals(uiResourceWithMetadata.getMetadata().getName(), resource.getName()); + assertEquals(uiResourceWithMetadata.getMetadata().getVersion() , resource.getVersion()); + assertEquals(uiResourceWithMetadata.getMetadata().getUniqueId() , resource.getUniqueId()); + assertEquals(uiResourceWithMetadata.getMetadata().getUUID(), resource.getUUID()); + } + + + + +} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java index 6bf3477c1f..f0421fb026 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java @@ -1468,26 +1468,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { @Test public void createImportRIRelationByCapNameFromCsarUITest() throws Exception { - User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - String payloadName = "vmmc_relate_by_cap_name.csar"; - ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource(); - String rootPath = System.getProperty("user.dir"); - Path path = null; - byte[] data = null; - String payloadData = null; - - path = Paths.get(rootPath + CSARS_PATH + "vmmc_relate_by_cap_name.csar"); - data = Files.readAllBytes(path); - payloadData = Base64.encodeBase64String(data); - resourceDetails.setPayloadData(payloadData); - - // create new resource from Csar - resourceDetails.setCsarUUID(payloadName); - resourceDetails.setPayloadName(payloadName); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails); - BaseRestUtils.checkCreateResponse(createResource); - Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + Resource resource = ResourceRestUtils.importResourceFromCsar("vmmc_relate_by_cap_name.csar"); // assert all relations created assertEquals(80, resource.getComponentInstancesRelations().size()); } diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java index 9e8a2a1f95..56841e1c5d 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java @@ -38,7 +38,6 @@ import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; @@ -1470,12 +1469,12 @@ public class ImportNewResourceCITest extends ComponentBaseTest { checkListValues(listValue.get(1), 2, SPECIAL_CHARACTERS); // Verify attributes - List<AttributeDefinition> attributes = resource.getAttributes(); + List<PropertyDefinition> attributes = resource.getAttributes(); assertEquals("check properties size", 2, attributes.size()); // Verify attribute from type map - AttributeDefinition attributeMapDefinition = attributes.stream() + PropertyDefinition attributeMapDefinition = attributes.stream() .filter(p -> p.getName().equals("validation_test_map")).findFirst().get(); String defaultMapValue = attributeMapDefinition.getDefaultValue(); Map attributeMapValue = gson.fromJson(defaultMapValue, Map.class); @@ -1484,7 +1483,7 @@ public class ImportNewResourceCITest extends ComponentBaseTest { checkMapValues(attributeMapValue, "key", 2, SPECIAL_CHARACTERS); // Verify attribute from type list - AttributeDefinition attributeListDefinition = attributes.stream() + PropertyDefinition attributeListDefinition = attributes.stream() .filter(p -> p.getName().equals("validation_test_list")).findFirst().get(); String defaultListValue = attributeListDefinition.getDefaultValue(); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java index 0973135295..ef95b34198 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java @@ -46,7 +46,6 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.CapReqDef; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.ComponentInstance; @@ -2837,9 +2836,9 @@ public class ImportToscaResourceTest extends ComponentBaseTest { ToscaNodeTypeInfo parseToscaNodeYaml = utils .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData())); - HashMap<String, AttributeDefinition> attr = new HashMap<>(); + HashMap<String, PropertyDefinition> attr = new HashMap<>(); - AttributeDefinition newAttr2 = new AttributeDefinition(); + PropertyDefinition newAttr2 = new PropertyDefinition(); newAttr2.setName("networks"); newAttr2.setType("map"); newAttr2.setDefaultValue("{\"keyA\" : val1 , \"keyB\" : val2}"); @@ -2850,17 +2849,17 @@ public class ImportToscaResourceTest extends ComponentBaseTest { newAttr2.setSchema(schema); attr.put("networks", newAttr2); - AttributeDefinition newAttr1 = new AttributeDefinition(); + PropertyDefinition newAttr1 = new PropertyDefinition(); newAttr1.setName("public_address"); newAttr1.setType("string"); attr.put("public_address", newAttr1); - AttributeDefinition newAttr3 = new AttributeDefinition(); + PropertyDefinition newAttr3 = new PropertyDefinition(); newAttr3.setName("ports"); newAttr3.setDescription("this is my description"); attr.put("ports", newAttr3); - AttributeDefinition newAttr = new AttributeDefinition(); + PropertyDefinition newAttr = new PropertyDefinition(); newAttr.setDefaultValue("myDefault"); newAttr.setName("private_address"); newAttr.setStatus("supported"); @@ -2880,8 +2879,8 @@ public class ImportToscaResourceTest extends ComponentBaseTest { AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false); } - private void validateResourceAttribute(Resource resource, Map<String, AttributeDefinition> attr) { - List<AttributeDefinition> resList = resource.getAttributes(); + private void validateResourceAttribute(Resource resource, Map<String, PropertyDefinition> attr) { + List<PropertyDefinition> resList = resource.getAttributes(); int size = resList.size(); String attributeName; for (int i = 0; i < size; i++) { diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java deleted file mode 100644 index 6a4fa3ba55..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java +++ /dev/null @@ -1,1478 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS_DELETE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_UNSUPPORTED_ERROR; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class ChangeServiceInstanceVersionTest extends ComponentInstanceBaseTest { - - protected ArtifactReqDetails heatArtifactDetails; - public String firstVfInstanceUniqueId; - public String firstVfInstanceName; - public String secondVfInstanceUniqueId; - public String secoundVfInstanceName; - public String serviceInstanceToReplaceUniqueId; - public String expectedServiceName; - public String expectedPosX; - public String expectedPosY; - public String actualServiceInstanceName; - public String actualPosX; - public String actualPosY; - - @Rule - public static TestName name = new TestName(); - - public ChangeServiceInstanceVersionTest() { - super(name, ChangeServiceInstanceVersionTest.class.getName()); - } - - @BeforeMethod - public void before() throws Exception { - firstVfInstanceName = null; - secoundVfInstanceName = null; - firstVfInstanceUniqueId = null; - secondVfInstanceUniqueId = null; - serviceInstanceToReplaceUniqueId = null; - expectedServiceName = null; - expectedPosX = null; - expectedPosY = null; - actualServiceInstanceName = null; - actualPosX = null; - actualPosY = null; - init(); - createComponents(); - } - - private void createComponents() throws Exception { - heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); - createAtomicResource(resourceDetailsVFC_01); - changeResourceStateToCertified(resourceDetailsVFC_01); - createAtomicResource(resourceDetailsCP_01); - changeResourceStateToCertified(resourceDetailsCP_01); - createAtomicResource(resourceDetailsVL_01); - changeResourceStateToCertified(resourceDetailsVL_01); - createAtomicResource(resourceDetailsVFC_02); - changeResourceStateToCertified(resourceDetailsVFC_02); - createAtomicResource(resourceDetailsCP_02); - changeResourceStateToCertified(resourceDetailsCP_02); - createAtomicResource(resourceDetailsVL_02); - changeResourceStateToCertified(resourceDetailsVL_02); - createVF(resourceDetailsVF_02); - createVF(resourceDetailsVF_01); - // create check-In services - createService(serviceDetails_01); - createService(serviceDetails_02); - createService(serviceDetails_03); - createProduct(productDetails_01); - createProduct(productDetails_02); - - // add resourceDetailsCP_01 ,resourceDetailsVFC_01 and - // resourceDetailsCP_01 to resourceDetailsVF_01 and certify - // resourceDetailsVF_01 - certifyVf(resourceDetailsVF_01, resourceDetailsVFC_02, resourceDetailsCP_01); - // add resourceDetailsCP_02 ,resourceDetailsVFC_02 and - // resourceDetailsVL_02 to resourceDetailsVF_02 and certify - // resourceDetailsVF_02 - certifyVf(resourceDetailsVF_02, resourceDetailsVFC_02, resourceDetailsCP_02); - RestResponse createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, - sdncDesignerDetails); // serviceDetails_01 has certified - // resourceDetailsVF_01 - firstVfInstanceName = ResponseParser.getNameFromResponse(createVFInstanceResponse); - createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02, - sdncDesignerDetails); // serviceDetails_01 has certified - // resourceDetailsVF_02 - secoundVfInstanceName = ResponseParser.getUniqueIdFromResponse(createVFInstanceResponse); - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - } - - @Test - public void changeServiceInstanceVersionByPm() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // get the new VF instance uniqueId after checkout service - RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - List<ComponentInstance> serviceComponentInstances = service.getComponentInstances(); - for (ComponentInstance component : serviceComponentInstances) { - if (component.getName().equals(firstVfInstanceName)) { - firstVfInstanceUniqueId = component.getUniqueId(); - } - } - assertTrue(firstVfInstanceUniqueId != null); - // delete resource instance (resourceDetailsVF_01) from Service - RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId, - serviceDetails_01, sdncDesignerDetails); - assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Add different VF instance (resourceDetailsVF_02) to Service - RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(restResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true); - ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse); - actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse); - actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posX"); - actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posY"); - ComponentInstance componentInstance = ResponseParser - .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Verify that Service instance name and position didn't change after - // changing service instance version - assertTrue(actualServiceInstanceName.equals(expectedServiceName)); - assertTrue(actualPosX.equals(expectedPosX)); - assertTrue(actualPosY.equals(expectedPosY)); - } - - @Test - public void changeServiceInstanceVersionByAdmin() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // get the new VF instance uniqueId after checkout service - RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - List<ComponentInstance> serviceComponentInstances = service.getComponentInstances(); - for (ComponentInstance component : serviceComponentInstances) { - if (component.getName().equals(firstVfInstanceName)) { - firstVfInstanceUniqueId = component.getUniqueId(); - } - } - assertTrue(firstVfInstanceUniqueId != null); - // delete resource instance (resourceDetailsVF_01) from Service - RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId, - serviceDetails_01, sdncDesignerDetails); - assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Add different VF instance (resourceDetailsVF_02) to Service - RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(restResponse); - // service [0.2] state to CERTIFICATIONREQUEST - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ResourceRestUtils.checkSuccess(changeStatusResponse); - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, - LifeCycleStatesEnum.STARTCERTIFICATION); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT, - true); - ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse); - actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse); - actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posX"); - actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posY"); - ComponentInstance componentInstance = ResponseParser - .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Verify that Service instance name and position didn't change after - // changing service instance version - assertTrue(actualServiceInstanceName.equals(expectedServiceName)); - assertTrue(actualPosX.equals(expectedPosX)); - assertTrue(actualPosY.equals(expectedPosY)); - } - - @Test - public void changeServiceInstanceToOlderVersion() throws Exception { - // Get VF Instance UniquId [Service version 0.1] - RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - ComponentInstance actualComponentInstance = service.getComponentInstances().get(0); - firstVfInstanceUniqueId = actualComponentInstance.getUniqueId(); - String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse); - - // Checkout service [0.2] - RestResponse changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, - sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // get the new VF instance uniqueId after checkout service - getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - List<ComponentInstance> serviceComponentInstances = service.getComponentInstances(); - for (ComponentInstance component : serviceComponentInstances) { - if (component.getName().equals(firstVfInstanceName)) { - firstVfInstanceUniqueId = component.getUniqueId(); - } - } - assertTrue(firstVfInstanceUniqueId != null); - // delete resource instance (resourceDetailsVF_01) from Service - RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId, - serviceDetails_01, sdncDesignerDetails); - assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Add different VF instance (resourceDetailsVF_02) to Service - RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(restResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // Adding service instance (serviceDetails_01 V0.2) to product without - // saving Req&Cap - RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to Older version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT, - true); - // RestResponse changeServiceInstanceVersionResponse = - // changeServiceInstanceVersion(productDetails_01.getUniqueId(), - // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid, - // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true); - ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse); - actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse); - actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posX"); - actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posY"); - ComponentInstance componentInstance = ResponseParser - .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Verify that Service instance name and position didn't change after - // changing service instance version - assertTrue(actualServiceInstanceName.equals(expectedServiceName)); - assertTrue(actualPosX.equals(expectedPosX)); - assertTrue(actualPosY.equals(expectedPosY)); - } - - // DE190201 - @Test - public void changeServiceInstanceVersionToCertifiedVersion() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - /* - * String serviceNewUniqueUid = - * ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - * serviceDetails_01.setUniqueId(serviceNewUniqueUid); - */ - // get the new VF instance uniqueId after checkout service - RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - List<ComponentInstance> serviceComponentInstances = service.getComponentInstances(); - for (ComponentInstance component : serviceComponentInstances) { - if (component.getName().equals(firstVfInstanceName)) { - firstVfInstanceUniqueId = component.getUniqueId(); - } - } - assertTrue(firstVfInstanceUniqueId != null); - // delete resource instance (resourceDetailsVF_01) from Service - RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId, - serviceDetails_01, sdncDesignerDetails); - assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Add different VF instance (resourceDetailsVF_02) to Service - RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(restResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ResourceRestUtils.checkSuccess(changeStatusResponse); - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, - LifeCycleStatesEnum.STARTCERTIFICATION); - ResourceRestUtils.checkSuccess(changeStatusResponse); - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, - LifeCycleStatesEnum.CERTIFY); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true); - // RestResponse changeServiceInstanceVersionResponse = - // changeServiceInstanceVersion(productDetails_01.getUniqueId(), - // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid, - // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true); - ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse); - actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse); - actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posX"); - actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posY"); - ComponentInstance componentInstance = ResponseParser - .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Verify that Service instance name and position didn't change after - // changing service instance version - assertTrue(actualServiceInstanceName.equals(expectedServiceName)); - assertTrue(actualPosX.equals(expectedPosX)); - assertTrue(actualPosY.equals(expectedPosY)); - } - - // DE191927 - @Test(enabled = false) - public void changeServiceInstanceVersionThenReCheckInProduct() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // get the new VF instance uniqueId after checkout service - RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - List<ComponentInstance> serviceComponentInstances = service.getComponentInstances(); - for (ComponentInstance component : serviceComponentInstances) { - if (component.getName().equals(firstVfInstanceName)) { - firstVfInstanceUniqueId = component.getUniqueId(); - } - } - assertTrue(firstVfInstanceUniqueId != null); - // delete resource instance (resourceDetailsVF_01) from Service - RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId, - serviceDetails_01, sdncDesignerDetails); - assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Add different VF instance (resourceDetailsVF_02) to Service - RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(restResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true); - ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse); - actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse); - actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posX"); - actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posY"); - ComponentInstance componentInstance = ResponseParser - .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - ///////////////////// - productOldUniqueId = productDetails_01.getUniqueId(); - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - ///////////////////////////////////////////// - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Verify that Service instance name and position didn't change after - // changing service instance version - assertTrue(actualServiceInstanceName.equals(expectedServiceName)); - assertTrue(actualPosX.equals(expectedPosX)); - assertTrue(actualPosY.equals(expectedPosY)); - } - - @Test - public void changeServiceInstanceToHisVersion() throws Exception { - // Get VF Instance UniquId [Service version 0.1] - RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse); - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // get the new VF instance uniqueId after checkout service - getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - List<ComponentInstance> serviceComponentInstances = service.getComponentInstances(); - for (ComponentInstance component : serviceComponentInstances) { - if (component.getName().equals(firstVfInstanceName)) { - firstVfInstanceUniqueId = component.getUniqueId(); - } - } - assertTrue(firstVfInstanceUniqueId != null); - // delete resource instance (resourceDetailsVF_01) from Service - RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId, - serviceDetails_01, sdncDesignerDetails); - assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Add different VF instance (resourceDetailsVF_02) to Service - RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(restResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT, - true); - // RestResponse changeServiceInstanceVersionResponse = - // changeServiceInstanceVersion(productDetails_01.getUniqueId(), - // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid, - // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true); - ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse); - actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse); - actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posX"); - actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posY"); - ComponentInstance componentInstance = ResponseParser - .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Verify that Service instance name and position didn't change after - // changing service instance version - assertTrue(actualServiceInstanceName.equals(expectedServiceName)); - assertTrue(actualPosX.equals(expectedPosX)); - assertTrue(actualPosY.equals(expectedPosY)); - } - - @Test - public void changeServiceInstanceVersionByAdminNotByProductOwner() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT, - true); - assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), - changeServiceInstanceVersionResponse.getResponse()); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - - } - - @Test - public void changeServiceInstanceVersionByPmNotByProductOwner() throws Exception { - // Adding service instance (serviceDetails_01) to product AND ---> - // saving Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // change uniqueId after product check-out in expected Req&Cap - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId); - // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1 - // instead sdncPmDetails1) - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion( - productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails2, - ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), - changeServiceInstanceVersionResponse.getResponse()); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void changeServiceInstanceVersionByTester() throws Exception { - // Adding service instance (serviceDetails_01) to product AND ---> - // saving Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // change uniqueId after product check-out in expected Req&Cap - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1 - // instead sdncPmDetails1) - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion( - productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, - sdncTesterDetails, ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), - changeServiceInstanceVersionResponse.getResponse()); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void changeServiceInstanceVersionProductIsNotCheckOut() throws Exception { - // Adding service instance (serviceDetails_01) to product AND ---> - // saving Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // CHANGE Service Instance VERSION for Non checkedOut product - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productOldUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), - changeServiceInstanceVersionResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - // DE191727 - @Test(enabled = false) - public void changeServiceInstanceVersionServiceIsInCheckOutState() throws Exception { - // Adding service instance (serviceDetails_01) to product AND ---> - // saving Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // change uniqueId after product check-out in expected Req&Cap - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // CHANGE Service Instance VERSION to service in checkOut state - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion( - productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, - ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(serviceNewUniqueUid); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales, - changeServiceInstanceVersionResponse.getResponse()); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - - } - - @Test - public void changeServiceInstanceVersionServiceInstanceDoesNotExist() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // change service instance to newer version - String serviceUniqueUidNotExist = "1234567890"; - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceUniqueUidNotExist, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(serviceUniqueUidNotExist); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales, - changeServiceInstanceVersionResponse.getResponse()); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - // DE189392 - @Test(enabled = false) - public void changeServiceInstanceNonExistingProduct() throws Exception { - // Adding service instance (serviceDetails_01) to product saving Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // change service instance to newer version - Non existing Product - String productNewUniqueIdNotExist = "1234567890"; - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueIdNotExist, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(productNewUniqueIdNotExist); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales, - changeServiceInstanceVersionResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void changeServiceInstanceVersionToNonExisitingServiceVersion() throws Exception { - // Adding service instance (serviceDetails_01) to product saving Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // change service instance to Non-existing version - String serviceUniqueUidNotExist = "1234567890"; - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceUniqueUidNotExist, sdncPmDetails1, ComponentTypeEnum.PRODUCT, - true); - assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(serviceUniqueUidNotExist); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), varibales, - changeServiceInstanceVersionResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void changeServiceInstanceComponentTypeIsNotProduct() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version for NON-Component Type = - // Product (e.g. service) - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.SERVICE, true); - assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales, - changeServiceInstanceVersionResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void changeServiceInstanceComponentTypeNotSupported() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version for NON-Component Type = - // Product (e.g. service) - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, - ComponentTypeEnum.SERVICE_INSTANCE, true); - assertEquals("Check response code ", STATUS_CODE_UNSUPPORTED_ERROR, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("null"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales, - changeServiceInstanceVersionResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void SeveralServiceInstanceFromSameServiceVersionChangeVersionOnlyForOneServiceInstance() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - serviceDetails_01.setUniqueId(serviceNewUniqueUid); - // get the new VF instance uniqueId after checkout service - RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1); - Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class); - List<ComponentInstance> serviceComponentInstances = service.getComponentInstances(); - for (ComponentInstance component : serviceComponentInstances) { - if (component.getName().equals(firstVfInstanceName)) { - firstVfInstanceUniqueId = component.getUniqueId(); - } - } - assertTrue(firstVfInstanceUniqueId != null); - // delete resource instance (resourceDetailsVF_01) from Service - RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId, - serviceDetails_01, sdncDesignerDetails); - assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Add different VF instance (resourceDetailsVF_02) to Service - RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(restResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get service instance new uniqueId , name and position after checkout - // product - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true); - ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse); - actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse); - actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posX"); - actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(), - "posY"); - ComponentInstance componentInstance = ResponseParser - .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Verify that Service instance name and position didn't change after - // changing service instance version - assertTrue(actualServiceInstanceName.equals(expectedServiceName)); - assertTrue(actualPosX.equals(expectedPosX)); - assertTrue(actualPosY.equals(expectedPosY)); - } - - @Test - public void changeServiceInstanceVersionByNonAsdcUser() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - nonAsdcUser.setUserId("bt760h"); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), - changeServiceInstanceVersionResponse.getResponse()); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void changeServiceInstanceVersionEmptyUserId() throws Exception { - // Adding service instance (serviceDetails_01) to product without saving - // Req&Cap - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, - sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Adding service instance (serviceDetails_02) to product AND ---> Save - // Req&Cap - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // check-in product - RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Checkout service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeStatusResponse); - String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - // Check-In service [0.2] - changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeStatusResponse); - // check-out product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeStatusResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - nonAsdcUser.setUserId(""); - // change service instance to newer version - RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId, - serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true); - assertEquals("Check response code ", STATUS_CODE_MISSING_INFORMATION, - changeServiceInstanceVersionResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), - changeServiceInstanceVersionResponse.getResponse()); - // Check-in product - changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, - LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeStatusResponse); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - //////////////////////////////////// - private void updateNewComponentInstanceId(RestResponse createServiceInstanceResp, String productNewUniqueId) - throws Exception { - String firstServiceInstanceNormalizedName = ResponseParser - .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId()); - Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class); - List<ComponentInstance> componentInstances = product.getComponentInstances(); - for (ComponentInstance component : componentInstances) { - if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) { - serviceInstanceToReplaceUniqueId = component.getUniqueId(); - expectedServiceName = component.getName(); - expectedPosX = component.getPosX(); - expectedPosY = component.getPosY(); - } - } - assertTrue(serviceInstanceToReplaceUniqueId != null); - } - - private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - if (restResponse.getErrorCode() == 200) { - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails, - LifeCycleStatesEnum.STARTCERTIFICATION); - } else - return restResponse; - if (restResponse.getErrorCode() == 200) { - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails, - LifeCycleStatesEnum.CERTIFY); - if (restResponse.getErrorCode() == 200) { - String newVersion = ResponseParser.getVersionFromResponse(restResponse); - resourceDetails.setVersion(newVersion); - resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED); - resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId()); - resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName()); - String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), - "uniqueId"); - resourceDetails.setUniqueId(uniqueIdFromRresponse); - } - } - return restResponse; - } - - private void certifyVf(ResourceReqDetails resource, ResourceReqDetails computeResource, - ResourceReqDetails cpResource) throws Exception { - RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, cpResource, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance); - - createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, computeResource, - sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - String toCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance); - - RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, - sdncDesignerDetails, resource.getUniqueId()); - ResourceRestUtils.checkSuccess(response); - - String capOwnerId = toCompInstId; - User user = sdncDesignerDetails; - ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE; - - fulfillCpRequirement(resource, fromCompInstId, toCompInstId, capOwnerId, user, containerCompType); - - RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource); - ResourceRestUtils.checkSuccess(changeResourceStateToCertified); - } -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java deleted file mode 100644 index 623b29b8e6..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.rules.TestName; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.model.category.CategoryDefinition; -import org.openecomp.sdc.be.model.category.GroupingDefinition; -import org.openecomp.sdc.be.model.category.SubCategoryDefinition; -import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.testng.annotations.BeforeMethod; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -public abstract class ProductBaseTest extends ComponentBaseTest { - User productStrategistUser1; - User productStrategistUser2; - User productStrategistUser3; - User productManager1; - User productManager2; - User adminUser; - User designerUser; - - // Category1->Subcategory1->Grouping1 - protected List<CategoryDefinition> defaultCategories; - - protected static String auditAction; - protected static ComponentOperationEnum operation; - - public ProductBaseTest(TestName testName, String className) { - super(testName, className); - } - - @BeforeMethod - public void beforeProductTest() throws IOException, Exception { - productStrategistUser1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST1); - productStrategistUser2 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST2); - productStrategistUser3 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST3); - productManager1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); - productManager2 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER2); - adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - createDefaultChain(); - } - - private void createDefaultChain() throws Exception { - CategoryDefinition productCategoryDefinition = ElementFactory.getDefaultCategory(); - SubCategoryDefinition productSubCategoryDefinition = ElementFactory.getDefaultSubCategory(); - GroupingDefinition productGroupingDefinition = ElementFactory.getDefaultGroup(); - productCategoryDefinition.addSubCategory(productSubCategoryDefinition); - productSubCategoryDefinition.addGrouping(productGroupingDefinition); - List<CategoryDefinition> definitionsList = new ArrayList<>(); - definitionsList.add(productCategoryDefinition); - defaultCategories = createCategoriesChain(definitionsList); - } - - private List<CategoryDefinition> createCategoriesChain(List<CategoryDefinition> categoryDefinitions) - throws Exception { - for (CategoryDefinition categoryDefinition : categoryDefinitions) { - RestResponse createCategory = CategoryRestUtils.createCategory(categoryDefinition, productStrategistUser1, - PRODUCT_COMPONENT_TYPE); - int status = createCategory.getErrorCode().intValue(); - if (status == BaseRestUtils.STATUS_CODE_CREATED) { - String categoryId = ResponseParser.getUniqueIdFromResponse(createCategory); - categoryDefinition.setUniqueId(categoryId); - } - List<SubCategoryDefinition> subcategories = categoryDefinition.getSubcategories(); - for (SubCategoryDefinition subCategoryDefinition : subcategories) { - RestResponse createSubCategory = CategoryRestUtils.createSubCategory(subCategoryDefinition, - categoryDefinition, productStrategistUser1, PRODUCT_COMPONENT_TYPE); - status = createSubCategory.getErrorCode().intValue(); - if (status == BaseRestUtils.STATUS_CODE_CREATED) { - String subCategoryId = ResponseParser.getUniqueIdFromResponse(createSubCategory); - subCategoryDefinition.setUniqueId(subCategoryId); - } - List<GroupingDefinition> groupings = subCategoryDefinition.getGroupings(); - for (GroupingDefinition groupingDefinition : groupings) { - RestResponse createGroupingRest = CategoryRestUtils.createGrouping(groupingDefinition, - subCategoryDefinition, categoryDefinition, productStrategistUser1, PRODUCT_COMPONENT_TYPE); - status = createGroupingRest.getErrorCode().intValue(); - if (status == BaseRestUtils.STATUS_CODE_CREATED) { - String groupingId = ResponseParser.getUniqueIdFromResponse(createGroupingRest); - groupingDefinition.setUniqueId(groupingId); - } - } - } - } - RestResponse allCategories = CategoryRestUtils.getAllCategories(productStrategistUser1, PRODUCT_COMPONENT_TYPE); - Gson gson = new Gson(); - List<CategoryDefinition> res = gson.fromJson(allCategories.getResponse(), - new TypeToken<List<CategoryDefinition>>() { - }.getType()); - return res; - } - - // Category1->Subcategory1->[Grouping1, Grouping11] - protected List<CategoryDefinition> addSecondGroupingToDefaultCategory() throws Exception { - GroupingDefinition productGroupingDefinition = ElementFactory.getDefaultGroup(); - productGroupingDefinition.setName("Grouping11"); - defaultCategories.get(0).getSubcategories().get(0).addGrouping(productGroupingDefinition); - return createCategoriesChain(defaultCategories); - } - - // Category1->[Subcategory1->[Grouping1, - // Grouping11],Subcategory2->[Grouping12]] - protected List<CategoryDefinition> addSubcategoryAndGroupingToDefaultCategory() throws Exception { - GroupingDefinition groupingDefinition1 = ElementFactory.getDefaultGroup(); - groupingDefinition1.setName("Grouping11"); - defaultCategories.get(0).getSubcategories().get(0).addGrouping(groupingDefinition1); - - SubCategoryDefinition subCategory2 = ElementFactory.getDefaultSubCategory(); - subCategory2.setName("Subcategory2"); - GroupingDefinition groupingDefinition2 = ElementFactory.getDefaultGroup(); - groupingDefinition2.setName("Grouping12"); - subCategory2.addGrouping(groupingDefinition2); - defaultCategories.get(0).addSubCategory(subCategory2); - return createCategoriesChain(defaultCategories); - } - - // [Category1->[Subcategory1->[Grouping1, - // Grouping11],Subcategory2->[Grouping12]], - // Category2->[Subcategory1->[Grouping1],Subcategory2->[Grouping1]], - // Category3->[Subcategory1->[Grouping11],Subcategory2->[Grouping11, - // Grouping22]]] - protected List<CategoryDefinition> addManyGroupingsDiffCategories() throws Exception { - CategoryDefinition category2 = ElementFactory.getDefaultCategory(); - category2.setName("Category2"); - CategoryDefinition category3 = ElementFactory.getDefaultCategory(); - category3.setName("Category3"); - SubCategoryDefinition subCategory1 = ElementFactory.getDefaultSubCategory(); - subCategory1.setName("Subcategory1"); - SubCategoryDefinition subCategory2 = ElementFactory.getDefaultSubCategory(); - subCategory2.setName("Subcategory2"); - SubCategoryDefinition subCategory1_2 = ElementFactory.getDefaultSubCategory(); - subCategory1_2.setName("Subcategory1"); - SubCategoryDefinition subCategory2_2 = ElementFactory.getDefaultSubCategory(); - subCategory2_2.setName("Subcategory2"); - SubCategoryDefinition subCategory1_3 = ElementFactory.getDefaultSubCategory(); - subCategory1_3.setName("Subcategory1"); - SubCategoryDefinition subCategory2_3 = ElementFactory.getDefaultSubCategory(); - subCategory2_3.setName("Subcategory2"); - - GroupingDefinition groupingDefinition1 = ElementFactory.getDefaultGroup(); - groupingDefinition1.setName("Grouping1"); - GroupingDefinition groupingDefinition11 = ElementFactory.getDefaultGroup(); - groupingDefinition11.setName("Grouping11"); - GroupingDefinition groupingDefinition12 = ElementFactory.getDefaultGroup(); - groupingDefinition12.setName("Grouping12"); - GroupingDefinition groupingDefinition22 = ElementFactory.getDefaultGroup(); - groupingDefinition22.setName("Grouping22"); - - defaultCategories.get(0).getSubcategories().get(0).addGrouping(groupingDefinition11); - subCategory2.addGrouping(groupingDefinition12); - defaultCategories.get(0).addSubCategory(subCategory2); - - defaultCategories.add(category2); - defaultCategories.add(category3); - category2.addSubCategory(subCategory1_2); - category2.addSubCategory(subCategory2_2); - subCategory1_2.addGrouping(groupingDefinition1); - subCategory2_2.addGrouping(groupingDefinition1); - category3.addSubCategory(subCategory1_3); - category3.addSubCategory(subCategory2_3); - subCategory1_3.addGrouping(groupingDefinition11); - subCategory2_3.addGrouping(groupingDefinition11); - subCategory2_3.addGrouping(groupingDefinition22); - return createCategoriesChain(defaultCategories); - } -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java deleted file mode 100644 index 1820315841..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.testng.AssertJUnit.assertEquals; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.enums.AuditJsonKeysEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.DbUtils; -import org.openecomp.sdc.ci.tests.utils.general.Convertor; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; -import org.openecomp.sdc.common.api.Constants; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class ProductCheckinTest extends ProductLifecycleTest { - - @Rule - public static TestName name = new TestName(); - - public ProductCheckinTest() { - super(name, ProductCheckinTest.class.getName()); - } - - @BeforeClass - public static void staticInit() { - auditAction = CHECKIN_ACTION; - operation = ComponentOperationEnum.CHANGE_STATE_CHECKIN; - } - - @Test - public void checkInProductByCreator() throws Exception { - - String checkinComment = "good checkin"; - RestResponse checkInResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN, checkinComment); - assertEquals("Check response code after checkin resource", 200, checkInResponse.getErrorCode().intValue()); - Product checkedInProduct = ResponseParser.parseToObjectUsingMapper(checkInResponse.getResponse(), - Product.class); - - expectedProduct.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, checkedInProduct, operation); - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(checkedInProduct, - auditAction, productManager1, ActionStatus.OK, "0.1", "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, checkedInProduct.getUUID()); - expectedProductAudit.setCOMMENT(checkinComment); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction, AuditJsonKeysEnum.COMMENT); - } - - @Test - public void checkInProductByPM() throws Exception { - - String checkinComment = "good checkin"; - RestResponse response = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN, checkinComment); - assertEquals("Check response code after checkin resource", 200, response.getErrorCode().intValue()); - - User checkoutUser = productManager2; - response = LifecycleRestUtils.changeProductState(expectedProduct, checkoutUser, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkin resource", 200, response.getErrorCode().intValue()); - expectedProduct = ResponseParser.parseToObjectUsingMapper(response.getResponse(), Product.class); - - DbUtils.cleanAllAudits(); - checkinComment = "good checkin no 2"; - response = LifecycleRestUtils.changeProductState(expectedProduct, checkoutUser, LifeCycleStatesEnum.CHECKIN, - checkinComment); - assertEquals("Check response code after checkin resource", 200, response.getErrorCode().intValue()); - - Product checkedInProduct = ResponseParser.parseToObjectUsingMapper(response.getResponse(), Product.class); - - expectedProduct.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - expectedProduct.setVersion("0.2"); - expectedProduct.setLastUpdaterUserId(checkoutUser.getUserId()); - expectedProduct.setLastUpdaterFullName(checkoutUser.getFullName()); - - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, checkedInProduct, operation); - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(checkedInProduct, - auditAction, checkoutUser, ActionStatus.OK, "0.2", "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, checkedInProduct.getUUID()); - expectedProductAudit.setCOMMENT(checkinComment); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction, AuditJsonKeysEnum.COMMENT); - } - - @Test - public void checkInProductByAdmin() throws Exception { - - String checkinComment = "good checkin"; - RestResponse checkInResponse = LifecycleRestUtils.changeProductState(expectedProduct, adminUser, - LifeCycleStatesEnum.CHECKIN, checkinComment); - assertEquals("Check response code after checkin resource", 200, checkInResponse.getErrorCode().intValue()); - Product checkedInProduct = ResponseParser.parseToObjectUsingMapper(checkInResponse.getResponse(), - Product.class); - - expectedProduct.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - expectedProduct.setLastUpdaterUserId(adminUser.getUserId()); - expectedProduct.setLastUpdaterFullName(adminUser.getFullName()); - - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, checkedInProduct, operation); - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(checkedInProduct, - auditAction, adminUser, ActionStatus.OK, "0.1", "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, checkedInProduct.getUUID()); - expectedProductAudit.setCOMMENT(checkinComment); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction, AuditJsonKeysEnum.COMMENT); - } - - @Test - public void checkInProductByPMNotOwner() throws Exception { - - RestResponse checkInResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager2, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 403, checkInResponse.getErrorCode().intValue()); - String[] auditParameters = new String[] { expectedProduct.getName(), "product", productManager1.getFirstName(), - productManager1.getLastName(), productManager1.getUserId() }; - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, - auditAction, productManager2, ActionStatus.COMPONENT_CHECKOUT_BY_ANOTHER_USER, "0.1", "0.1", - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - expectedProduct.getUUID(), auditParameters); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - - @Test - public void checkInProductByPsRoleNotAllowed() throws Exception { - - RestResponse checkInResponse = LifecycleRestUtils.changeProductState(expectedProduct, productStrategistUser1, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 409, checkInResponse.getErrorCode().intValue()); - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, - auditAction, productStrategistUser1, ActionStatus.RESTRICTED_OPERATION, "0.1", "0.1", - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - expectedProduct.getUUID()); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - - @Test - public void checkInProductNotExist() throws Exception { - String notExisitingUuid = "1234"; - expectedProduct.setUniqueId(notExisitingUuid); - RestResponse checkInResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 404, checkInResponse.getErrorCode().intValue()); - String[] auditParameters = new String[] { "", "product" }; - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, - auditAction, productManager1, ActionStatus.PRODUCT_NOT_FOUND, Constants.EMPTY_STRING, - Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, auditParameters); - expectedProductAudit.setCURR_STATE(Constants.EMPTY_STRING); - expectedProductAudit.setRESOURCE_NAME(notExisitingUuid); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - - @Test - public void checkInProductAlreadyCheckedIn() throws Exception { - RestResponse checkInResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 200, checkInResponse.getErrorCode().intValue()); - DbUtils.cleanAllAudits(); - checkInResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager2, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 409, checkInResponse.getErrorCode().intValue()); - String[] auditParameters = new String[] { expectedProduct.getName(), "product", productManager1.getFirstName(), - productManager1.getLastName(), productManager1.getUserId() }; - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, - auditAction, productManager2, ActionStatus.COMPONENT_ALREADY_CHECKED_IN, "0.1", "0.1", - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, - expectedProduct.getUUID(), auditParameters); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java deleted file mode 100644 index efb4a15255..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.testng.AssertJUnit.assertEquals; - -import java.io.FileNotFoundException; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.DbUtils; -import org.openecomp.sdc.ci.tests.utils.Utils; -import org.openecomp.sdc.ci.tests.utils.general.Convertor; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class ProductCheckoutTest extends ProductLifecycleTest { - - @Rule - public static TestName name = new TestName(); - - @BeforeClass - public static void staticInit() { - auditAction = CHECKOUT_ACTION; - operation = ComponentOperationEnum.CHANGE_STATE_CHECKOUT; - } - - public ProductCheckoutTest() { - super(name, ProductCheckoutTest.class.getName()); - } - - @Test - public void checkOutProductByPmNotInContacts() throws Exception { - checkOutProductSuccess(productManager2); - } - - @Test - public void checkOutProductByPmInContacts() throws Exception { - checkOutProductSuccess(productManager1); - } - - @Test - public void checkOutProductByAdmin() throws Exception { - checkOutProductSuccess(adminUser); - } - - @Test - public void checkOutProductByPs() throws Exception { - // Changed in 1604 patch - now it's restricted - checkOutProductRestricted(productStrategistUser3); - // checkOutProductSuccess(productStrategistUser3); - } - - @Test - public void checkOutProductByDesignerRoleNotAllowed() throws Exception { - checkOutProductRestricted(designerUser); - } - - @Test - public void checkOutProductAlreadyCheckedOut() throws Exception { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 200, lcsResponse.getErrorCode().intValue()); - - lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkin resource", 200, lcsResponse.getErrorCode().intValue()); - Product checkedOutProduct = ResponseParser.parseToObjectUsingMapper(lcsResponse.getResponse(), Product.class); - - DbUtils.cleanAllAudits(); - - lcsResponse = LifecycleRestUtils.changeProductState(checkedOutProduct, productManager2, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkin resource", 403, lcsResponse.getErrorCode().intValue()); - String[] auditParameters = new String[] { checkedOutProduct.getName(), "product", productManager1.getFirstName(), productManager1.getLastName(), productManager1.getUserId() }; - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(checkedOutProduct, auditAction, productManager2, ActionStatus.COMPONENT_IN_CHECKOUT_STATE, "0.2", "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, checkedOutProduct.getUUID(), auditParameters); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - - private void checkOutProductSuccess(User checkoutUser) throws Exception, FileNotFoundException { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 200, lcsResponse.getErrorCode().intValue()); - - lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, checkoutUser, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkin resource", 200, lcsResponse.getErrorCode().intValue()); - - // 0.1 is not highest now - RestResponse prevVersionProductResp = ProductRestUtils.getProduct(expectedProduct.getUniqueId(), productStrategistUser1.getUserId()); - Product prevVersionProduct = ResponseParser.parseToObjectUsingMapper(prevVersionProductResp.getResponse(), Product.class); - Boolean falseParam = false; - assertEquals(falseParam, prevVersionProduct.isHighestVersion()); - - Product checkedOutProduct = ResponseParser.parseToObjectUsingMapper(lcsResponse.getResponse(), Product.class); - - expectedProduct.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - expectedProduct.setVersion("0.2"); - expectedProduct.setLastUpdaterUserId(checkoutUser.getUserId()); - expectedProduct.setLastUpdaterFullName(checkoutUser.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, checkedOutProduct, operation); - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(checkedOutProduct, auditAction, checkoutUser, ActionStatus.OK, "0.1", "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, checkedOutProduct.getUUID()); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - - private void checkOutProductRestricted(User checkoutUser) throws Exception, FileNotFoundException { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin resource", 200, lcsResponse.getErrorCode().intValue()); - - lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, checkoutUser, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkin resource", 409, lcsResponse.getErrorCode().intValue()); - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, auditAction, checkoutUser, ActionStatus.RESTRICTED_OPERATION, "0.1", "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, expectedProduct.getUUID()); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java deleted file mode 100644 index fe5a6e34f9..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java +++ /dev/null @@ -1,1175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS_DELETE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_UNSUPPORTED_ERROR; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class ProductComponentInstanceCRUDTest extends ComponentInstanceBaseTest { - - protected ArtifactReqDetails heatArtifactDetails; - @Rule - public static TestName name = new TestName(); - - public ProductComponentInstanceCRUDTest() { - super(name, ProductComponentInstanceCRUDTest.class.getName()); - } - - @BeforeMethod - public void before() throws Exception { - init(); - createComponents(); - } - - private void createComponents() throws Exception { - - heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); - createAtomicResource(resourceDetailsVFC_01); - changeResourceStateToCertified(resourceDetailsVFC_01); - createAtomicResource(resourceDetailsCP_01); - changeResourceStateToCertified(resourceDetailsCP_01); - createAtomicResource(resourceDetailsVL_01); - changeResourceStateToCertified(resourceDetailsVL_01); - createAtomicResource(resourceDetailsVFC_02); - changeResourceStateToCertified(resourceDetailsVFC_02); - createAtomicResource(resourceDetailsCP_02); - changeResourceStateToCertified(resourceDetailsCP_02); - createAtomicResource(resourceDetailsVL_02); - changeResourceStateToCertified(resourceDetailsVL_02); - createVF(resourceDetailsVF_02); - createVF(resourceDetailsVF_01); - // create check-In services - createService(serviceDetails_01); - createService(serviceDetails_02); - createService(serviceDetails_03); - createProduct(productDetails_01); - createProduct(productDetails_02); - - // addresourceDetailsCP_02 ,resourceDetailsVFC_02 and - // resourceDetailsVL_02 to resourceDetailsVF_02 check-in VF - RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVFC_02, sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsCP_02, sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVL_02, sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN); - resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - // addresourceDetailsCP_01 ,resourceDetailsVFC_01 and - // resourceDetailsVL_01 to resourceDetailsVF_01 and certify - // resourceDetailsVF_01 - certifyVf(resourceDetailsVF_01); - createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // serviceDetails_01 - // has - // certified - // VF - createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02, sdncDesignerDetails); // serviceDetails_02 - // has - // check-in - // VF - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - } - - // pass - @Test - public void createServiceInstanceTest() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - // DE189427 - @Test(enabled = false) - public void createServiceInstanceFromCheckedOutState() throws Exception { - // can't create instance of checked-out component - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceInToAnotherServiceInstance() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String uniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, uniqueIdFromResponse, ComponentTypeEnum.PRODUCT); - assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_NOT_FOUND); - } - - @Test - public void createSeveralServiceInstanceFromSameServices() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void createSeveralServiceInstanceFromDifferentServices() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void createCertifiedServiceInstance() throws Exception { - changeServiceStateToCertified(serviceDetails_01); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceByPm() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceWithoutVf() throws Exception { - LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncAdminDetails, "0.1", LifeCycleStatesEnum.CHECKIN); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_02, serviceDetails_03, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_02, 1, 0); - } - - @Test - public void createServiceInstanceByNonProductOwner() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails2); - assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceByNonAsdcUser() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); - ; - nonExistingSdncUser.setUserId("bt1234"); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonExistingSdncUser); - assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceToNotCheckOutProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - // pass - @Test - public void createServiceInstanceNameIsEmpty() throws Exception { - String expectedServiceInstanceName = serviceDetails_01.getName() + " 1"; - String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "1"; - serviceDetails_01.setName(""); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName); - getComponentAndValidateRIs(productDetails_01, 1, 0); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(expectedServiceInstanceName, actualComponentInstance.getName()); - assertEquals((expectedServiceInstancenormalizedName).toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - // pass - @Test - public void createServiceInstanceNameIsNull() throws Exception { - String expectedServiceInstanceName = serviceDetails_01.getName() + " 1"; - String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "1"; - serviceDetails_01.setName(null); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName); - getComponentAndValidateRIs(productDetails_01, 1, 0); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(expectedServiceInstanceName, actualComponentInstance.getName()); - assertEquals((expectedServiceInstancenormalizedName).toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - @Test(enabled = false) - public void createServiceInstanceToNonExistingProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, "blabla", ComponentTypeEnum.PRODUCT); - AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, createServiceInstanceResp.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("blabla"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, createServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceToNonSupportedComponentType() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE); - assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("null"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales, createServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - // pass - @Test - public void createServiceInstancePositionIsEmpty() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - serviceInstanceReqDetails.setPosX(""); - serviceInstanceReqDetails.setPosY(""); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstancePositionIsNull() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - serviceInstanceReqDetails.setPosX(null); - serviceInstanceReqDetails.setPosY(null); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class); - addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceByDesigner() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncDesignerDetails); - assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void createServiceInstanceUserIdIsEmpty() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - nonSdncDetails.setUserId(""); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonSdncDetails); - assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - //// Update Service instance - - @Test - public void updateServiceInstanceNameByPm() throws Exception { - // Check-in Product by PM and Check-out by PM - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - // Create service instance by PM - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "abcD"; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance Name ", newName, instanceName); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(newName, actualComponentInstance.getName()); - assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - @Test - public void updateServiceInstanceNewNameAndLocation() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "updaatedName100"; - serviceInstanceReqDetails.setPosX("100"); - serviceInstanceReqDetails.setPosY("100"); - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX()); - assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY()); - assertEquals(newName, actualComponentInstance.getName()); - assertEquals(newName.toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - @Test(enabled = false) - public void updateServiceInstanceNameRemoveSpacesFromBiginningAndEnd() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = " Abcd "; - String expectedNewName = " Abcd "; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (expectedNewName).toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance Name ", expectedNewName, instanceName); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(expectedNewName, actualComponentInstance.getName()); - assertEquals((expectedNewName).toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - // pass - @Test - public void updateServiceInstanceNameAllowedCharacters() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "qwer-TYUIOP_asd_0987654321.Abcd"; - String ExpectedNormalizName = "qwertyuiopasd0987654321abcd"; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", ExpectedNormalizName, instanceNormalizedName); - assertEquals("check Resource Instance Name ", newName, instanceName); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(newName, actualComponentInstance.getName()); - assertEquals(ExpectedNormalizName, actualComponentInstance.getNormalizedName()); - - } - - @Test - public void updateInstanceNameInvalidCharacters() throws Exception { - char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|', '\\', ',' }; - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "Abcd1"; - String updateName; - for (int i = 0; i < invalidChars.length; i++) { - updateName = newName + invalidChars[i]; - serviceInstanceReqDetails.setName(updateName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - assertEquals("Check response code ", STATUS_CODE_INVALID_CONTENT, updateServiceInstanceResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("Service Instance"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), varibales, updateServiceInstanceResponse.getResponse()); - } - } - - // pass - @Test - public void updateInstanceNameMaxLength() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl12345"; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance Name ", newName, instanceName); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(newName, actualComponentInstance.getName()); - assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - @Test - public void updateInstanceNameExceedMaxLength() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String expectedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name"); - String expectedNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName"); - String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456"; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - assertEquals("Check response code ", STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT, updateServiceInstanceResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("Service Instance"); - varibales.add("50"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), varibales, updateServiceInstanceResponse.getResponse()); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(expectedName, actualComponentInstance.getName()); - assertEquals(expectedNormalizedName, actualComponentInstance.getNormalizedName()); - } - - @Test - public void updateServiceInstanceNameEmpty() throws Exception { - // see US534663 In case a PS/PM removes the current service instance - // name then BE has to generate again the "default" service instance - // name - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = ""; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "2").toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 2"), instanceName); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(instanceName, actualComponentInstance.getName()); - assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName()); - } - - // pass - @Test - public void updateServiceInstanceNameNull() throws Exception { - // see US534663 In case a PS/PM removes the current service instance - // name then BE has to generate again the "default" service instance - // name - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = null; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "2").toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 2"), instanceName); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(instanceName, actualComponentInstance.getName()); - assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName()); - } - - @Test - public void updateServiceInstanceCheckedByOtherUser() throws Exception { - // see US534663 In case a PS/PM removes the current service instance - // name then BE has to generate again the "default" service instance - // name - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "blabla"; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails2, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, updateServiceInstanceResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateServiceInstanceResponse.getResponse()); - } - - @Test - public void updateServiceInstance_UserIdIsNonAsdcUser() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "blabla"; - serviceInstanceReqDetails.setName(newName); - User nonSdncUserDetails = new User(); - nonSdncUserDetails.setUserId("bt4567"); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, nonSdncUserDetails, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, updateServiceInstanceResponse.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateServiceInstanceResponse.getResponse()); - } - - @Test - public void updateServiceInstanceNameToAlreadyExisting() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String ServiceName1 = ResponseParser.getNameFromResponse(createServiceInstanceResp); - createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // Update service instance2 name to service instance1 - serviceInstanceReqDetails.setName(ServiceName1); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - assertEquals("Check response code ", STATUS_CODE_ALREADY_EXISTS, updateServiceInstanceResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("Service Instance"); - varibales.add(ServiceName1); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name(), varibales, updateServiceInstanceResponse.getResponse()); - } - - @Test - public void updateServiceInstanceForNonExistingProduct() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "blabla"; - serviceInstanceReqDetails.setName(newName); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, "blablabla", ComponentTypeEnum.PRODUCT); - AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, updateServiceInstanceResponse.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, updateServiceInstanceResponse.getResponse()); - - } - - @Test - public void updateNonExistingServiceInstance() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String newName = "blabla"; - serviceInstanceReqDetails.setName(newName); - serviceInstanceReqDetails.setUniqueId("11111111"); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(newName); - varibales.add("service instance"); - AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, updateServiceInstanceResponse.getErrorCode().intValue()); - // need to change ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name() to - // ActionStatus.SERVICE_INSTANCE_NOT_FOUND.name() - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND.name(), varibales, updateServiceInstanceResponse.getResponse()); - } - - @Test - public void updateServiceInstanceLocation() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - serviceInstanceReqDetails.setPosX("50"); - serviceInstanceReqDetails.setPosY("100"); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX()); - assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY()); - } - - @Test - public void updateServiceInstanceToNonExistingLocation() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - String nameFromResponse = ResponseParser.getNameFromResponse(createServiceInstanceResp); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - serviceInstanceReqDetails.setPosX("-50"); - serviceInstanceReqDetails.setPosY("-100"); - serviceInstanceReqDetails.setName(nameFromResponse); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX()); - assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY()); - assertEquals(nameFromResponse, actualComponentInstance.getName()); - } - - @Test - public void updateServiceInstanceLocationNameIsEmpty() throws Exception { - String expectedServiceInstanceName = serviceDetails_01.getName() + " 2"; - String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "2"; - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - serviceInstanceReqDetails.setPosX("100"); - serviceInstanceReqDetails.setPosY("200"); - serviceInstanceReqDetails.setName(""); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String nameFromResponse = ResponseParser.getNameFromResponse(updateServiceInstanceResponse); - String postX = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posX"); - String postY = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posY"); - assertEquals(nameFromResponse, expectedServiceInstanceName); - assertEquals(postX, "100"); - assertEquals(postY, "200"); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX()); - assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY()); - assertEquals(nameFromResponse, actualComponentInstance.getName()); - assertEquals(expectedServiceInstancenormalizedName.toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - // pass - @Test - public void updateServiceInstanceNameToProductName() throws Exception { - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01); - RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // ComponentInstance componentInstance = - // ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), - // ComponentInstance.class); - // addCompInstReqCapToExpected(componentInstance, - // ComponentTypeEnum.PRODUCT); - serviceInstanceReqDetails.setName(productDetails_01.getName()); - RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ResourceRestUtils.checkSuccess(updateServiceInstanceResponse); - String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName"); - String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name"); - assertEquals("check Resource Instance normalizedName ", (serviceInstanceReqDetails.getName()).toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance Name ", serviceInstanceReqDetails.getName(), instanceName); - // get product and verify that service instanceName is correct - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - assertEquals(serviceInstanceReqDetails.getName(), actualComponentInstance.getName()); - assertEquals((serviceInstanceReqDetails.getName()).toLowerCase(), actualComponentInstance.getNormalizedName()); - } - - //// Delete Service Instance - - @Test - public void deleteAllServiceInstanceFromProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - getComponentAndValidateRIs(productDetails_01, 0, 0); - } - - @Test - public void deleteServiceWhileServiceInstanceExistInProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - // Delete service while service instance of it exist in product - RestResponse deleteServiceResponse = ServiceRestUtils.deleteServiceById(serviceDetails_01.getUniqueId(), sdncDesignerDetails.getUserId()); - assertTrue(deleteServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - // Get product and verify that service instance still exists - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - // ComponentInstance actualComponentInstance = - // actualProduct.getComponentInstances().get(0); - // assertTrue(serviceInstanceUniqueIdFromResponse == - // actualComponentInstance.getUniqueId()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - // pass - @Test - public void deleteServiceInstanceByPm() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void deleteServiceInstanceByPmCreatedByPm() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void deleteServiceInstanceByPmWhichIsCheckedOutByAnotherPm() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails2); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - // DE190189 - @Test - public void deleteServiceInstanceByPmCreatedByPs() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - String productOldUniqueId = productDetails_01.getUniqueId(); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get product and get service instance new uniquId - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - String serviceInstanceUniqueId = actualComponentInstance.getUniqueId(); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - getComponentAndValidateRIs(productDetails_01, 0, 0); - } - - // DE190189 - @Test - public void deleteServiceInstanceByAdminCreatedByPs() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - String productOldUniqueId = productDetails_01.getUniqueId(); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse); - updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId); - // get product and get service instance new uniquId - RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncAdminDetails.getUserId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class); - ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0); - String serviceInstanceUniqueId = actualComponentInstance.getUniqueId(); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncAdminDetails); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - getComponentAndValidateRIs(productDetails_01, 0, 0); - } - - @Test - public void createAndDeleteServiceInstanceByAdmin() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - // productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncAdminDetails); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncAdminDetails); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncAdminDetails); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void deleteServiceInstanceFromNonCheckOutProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void deleteServiceInstanceByDesigner() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncDesignerDetails); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void deleteServiceInstanceByTester() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncTesterDetails); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void deleteServiceInstanceByPsWhichIsCheckedOutByAnotherPs() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPsDetails2); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - // pass - @Test - public void deleteServiceInstanceByNonAsdcUser() throws Exception { - User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); - ; - nonExistingSdncUser.setUserId("bt1234"); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, nonExistingSdncUser); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void deleteServiceInstanceFromNonExistingProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, "1234567890", serviceInstanceUniqueId, ComponentTypeEnum.PRODUCT); - assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void deleteNonExistingServiceInstanceFromProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - // String serviceInstanceUniqueId = - // ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), "1234567890123456unExistingServiceInstance", ComponentTypeEnum.PRODUCT); - assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("1234567890123456unExistingServiceInstance"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void deleteServiceInstanceFromNonSupportedComponentType() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.RESOURCE_INSTANCE); - assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("null"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales, deleteResourceInstanceResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void deleteServiceInstanceComponentTypeIsNotProduct() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.SERVICE); - assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse()); - getComponentAndValidateRIs(productDetails_01, 2, 0); - } - - @Test - public void deleteServiceInstanceUserIdIsEmpty() throws Exception { - User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - nonSdncDetails.setUserId(""); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, nonSdncDetails); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse()); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - @Test - public void deleteCertifiedServiceInstance() throws Exception { - changeServiceStateToCertified(serviceDetails_01); - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1); - assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE); - getComponentAndValidateRIs(productDetails_01, 1, 0); - } - - //////////////////////////////////// - - private void certifyVf(ResourceReqDetails resource) throws Exception { - RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01, sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance); - - createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_02, sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - String computeCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance); - - createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01, sdncDesignerDetails); - ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - String vlCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance); - - // Fixing Vl/Cp req/cap - ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE; - User user = sdncDesignerDetails; - fulfillCpRequirement(resource, cpCompInstId, computeCompInstId, computeCompInstId, user, containerCompType); - consumeVlCapability(resource, cpCompInstId, vlCompInstId, cpCompInstId, user, containerCompType); - - RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails, resource.getUniqueId()); - ResourceRestUtils.checkSuccess(response); - RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource); - ResourceRestUtils.checkSuccess(changeResourceStateToCertified); - } - - private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - if (restResponse.getErrorCode() == 200) { - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails, LifeCycleStatesEnum.STARTCERTIFICATION); - } else - return restResponse; - if (restResponse.getErrorCode() == 200) { - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails, LifeCycleStatesEnum.CERTIFY); - if (restResponse.getErrorCode() == 200) { - String newVersion = ResponseParser.getVersionFromResponse(restResponse); - resourceDetails.setVersion(newVersion); - resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED); - resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId()); - resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName()); - String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId"); - resourceDetails.setUniqueId(uniqueIdFromRresponse); - } - } - return restResponse; - } - - private RestResponse changeServiceStateToCertified(ServiceReqDetails serviceDetails) throws Exception { - /* - * RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN); ResourceRestUtils.checkSuccess(restResponse); - */ - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - if (restResponse.getErrorCode() == 200) { - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.STARTCERTIFICATION); - } else - return restResponse; - if (restResponse.getErrorCode() == 200) { - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.CERTIFY); - if (restResponse.getErrorCode() == 200) { - serviceDetails.setVersion("1.0"); - serviceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED); - serviceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId()); - serviceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName()); - String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId"); - serviceDetails.setUniqueId(uniqueIdFromRresponse); - } - } - return restResponse; - } - - @Test - public void deleteServiceInstanceTest() throws Exception { - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - String compInstId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - - createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 2, 0); - String compInstId2 = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - - RestResponse deleteServiceInstanceResp = deleteServiceInstance(compInstId, productDetails_01, sdncPmDetails1); - ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 1, 0); - - deleteServiceInstanceResp = deleteServiceInstance(compInstId2, productDetails_01, sdncPmDetails1); - ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp); - getComponentAndValidateRIs(productDetails_01, 0, 0); - } - - @Test - public void returnedServiceInstanceTypeAttributeTest() throws Exception { - String expectedServiceType = ComponentTypeEnum.SERVICE.getValue().toUpperCase(); - - RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1); - ResourceRestUtils.checkCreateResponse(createServiceInstanceResp); - String serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp); - ComponentInstanceRestUtils.checkComponentInstanceType(createServiceInstanceResp, expectedServiceType); - - RestResponse getProductResp = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPsDetails1.getUserId()); - ProductRestUtils.checkSuccess(getProductResp); - Product productObject = ResponseParser.parseToObjectUsingMapper(getProductResp.getResponse(), Product.class); - List<ComponentInstance> productComponentInstances = productObject.getComponentInstances(); - for (ComponentInstance comp : productComponentInstances) { - String actualOriginType = comp.getOriginType().getValue().toUpperCase(); - assertTrue(expectedServiceType.equals(actualOriginType)); - } - - ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_02); - serviceInstanceReqDetails.setUniqueId(serviceUniqueIdFromResponse); - serviceInstanceReqDetails.setComponentUid(serviceDetails_01.getUniqueId()); - RestResponse updateResourceInstance = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT); - ComponentInstanceRestUtils.checkSuccess(updateResourceInstance); - ComponentInstanceRestUtils.checkComponentInstanceType(updateResourceInstance, expectedServiceType); - - } -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java deleted file mode 100644 index 7ac24bdd69..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java +++ /dev/null @@ -1,1711 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.Arrays; - -import org.json.JSONArray; -import org.json.JSONException; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.DbUtils; -import org.openecomp.sdc.ci.tests.utils.Utils; -import org.openecomp.sdc.ci.tests.utils.general.Convertor; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; -import org.openecomp.sdc.common.api.Constants; -import org.testng.annotations.Test; - -public class ProductCreateWithValidationsTest extends ProductBaseTest { - @Rule - public static TestName name = new TestName(); - - public static String INITIAL_PRODUCT_VERSION = "0.1"; - public static String CREATE_AUDIT_ACTION = "Create"; - public String normalizedName; - - public ProductCreateWithValidationsTest() { - super(name, ProductCreateWithValidationsTest.class.getName()); - } - - @Test - public void createProductSuccessValidation() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNotByPmUser() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productStrategistUser1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, - productStrategistUser1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productStrategistUser1, ActionStatus.RESTRICTED_OPERATION, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNotByAsdcUser() throws Exception { - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); - nonAsdcUser.setUserId("bt750k"); - nonAsdcUser.setFirstName(null); - nonAsdcUser.setLastName(null); - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, nonAsdcUser); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, - nonAsdcUser); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, nonAsdcUser, ActionStatus.RESTRICTED_OPERATION, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductUserIdIsEmpty() throws Exception { - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); - nonAsdcUser.setUserId(""); - nonAsdcUser.setFirstName(null); - nonAsdcUser.setLastName(null); - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, nonAsdcUser); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, - nonAsdcUser); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, nonAsdcUser, ActionStatus.MISSING_INFORMATION, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationLessThanMinCharacters() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Pro"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, - ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, Constants.EMPTY_STRING, Constants.EMPTY_STRING, - null, null, Constants.EMPTY_STRING, "Product", "abbreviated"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationMaxLength() throws Exception { - // Max length = 25 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Qwertyuiop1234567890asdfA"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationExceedMaxLength() throws Exception { - // Max length = 25 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Qwertyuiop1234567890asdfAa"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, - ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, Constants.EMPTY_STRING, Constants.EMPTY_STRING, - null, null, Constants.EMPTY_STRING, "Product", "abbreviated"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationEmptyName() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName(""); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", - "abbreviated"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameAlreadyExist() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - // productReqDetails.setName("ProDuct1"); - DbUtils.deleteFromEsDbByPattern("_all"); - createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_ALREADY_EXISTS, - createProduct.getErrorCode().intValue()); - productReqDetails.setVersion("0.1"); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", - productReqDetails.getName()); - constructFieldsForAuditValidation.setCURR_VERSION("0.1"); - constructFieldsForAuditValidation.setCURR_STATE(""); - constructFieldsForAuditValidation.setCURR_STATE("NOT_CERTIFIED_CHECKOUT"); - constructFieldsForAuditValidation.setSERVICE_INSTANCE_ID(null); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationNameIsNull() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName(null); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", - "abbreviated"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - // DE193857 - @Test(enabled = false) - public void createProductNameValidationAllowedCharacters() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Ac_2@3:4& m=n+b-u.j-u'g#b"); // Bug @:&=+'# - normalizedName = "ac234mnbujugb"; - String expectedProductName = "Ac_2@3:4& M=n+b-u.j-u'g#b"; - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - productReqDetails.setName(expectedProductName); - productReqDetails.setName("Ac_2@3:4& M=n+b-u.j-u'g#b"); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setNormalizedName(normalizedName); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - // DE193857 - @Test(enabled = false) - public void createProductNameValidationREmoveExtraNonAlphanumericChars() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Ac____222----333......asd"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setName("Ac_222-333.asd"); - normalizedName = "ac222333asd"; - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationNotAllowedCharacters() throws Exception { - ExpectedProductAudit constructFieldsForAuditValidation; - char invalidChars[] = { '~', '!', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|', - '\\', ',', '$' }; - for (int i = 0; i < invalidChars.length; i++) { - DbUtils.deleteFromEsDbByPattern("_all"); - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("abc" + invalidChars[i]); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", - productManager1); - constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(expectedProduct, - CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", - "abbreviated"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - } - - @Test - public void createProductFullNameContainSpecialCharacters() throws Exception { - char invalidChars[] = { '~', '!', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|', - '\\', ',', '$' }; - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - for (int i = 0; i < invalidChars.length; i++) { - DbUtils.deleteFromEsDbByPattern("_all"); - productReqDetails.setFullName("abc" + invalidChars[i]); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_CREATED, - createProduct.getErrorCode().intValue()); - RestResponse deleteProduct = ProductRestUtils.deleteProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, - deleteProduct.getErrorCode().intValue()); - } - } - - @Test(enabled = false) - public void createProductNameValidationRemoveSpaceFromBeginning() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName(" Qwertyuiop1234567890asdfA"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName().trim())); - normalizedName = productReqDetails.getName().trim().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test(enabled = false) - public void createProductNameValidationRemoveSpaceFromTheEnd() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Qwertyuiop1234567890asdfA "); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName().trim())); - normalizedName = productReqDetails.getName().trim().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationStartWithNumber() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("1Qwert"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName().trim())); - normalizedName = productReqDetails.getName().trim().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationStartWithNonAlphaNumeric() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("_Qwert"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName().trim())); - normalizedName = productReqDetails.getName().trim().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, - ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, Constants.EMPTY_STRING, Constants.EMPTY_STRING, - null, null, Constants.EMPTY_STRING, "Product", "abbreviated"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductNameValidationFirstLetterOfKeyWordsCapitalized() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - // productReqDetails.setTags(Arrays.asList("abba")); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - // productReqDetails.setName("Abba"); - /* - * String actualNormalizedNameFromResponse = - * ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), - * "normalizedName"); - * assertTrue(actualNormalizedNameFromResponse.equals(normalizedName)); - */ - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductFullNameValidationIsEmpty() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setFullName(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", "full"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductFullNameValidationIsNull() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setFullName(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", "full"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductFullNameLessThanMinLength() throws Exception { - // Min is 4 characters - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setFullName("abc"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, - ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, Constants.EMPTY_STRING, Constants.EMPTY_STRING, - null, null, Constants.EMPTY_STRING, "Product", "full"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductFullNameHasMinLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setFullName("abcd"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductFullNameHasMaxLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setFullName( - "Abba1234567890asdfghjk l123zxcvbnm432adfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductFullNameExceedMaxLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setFullName( - "Abba1234567890asdfghjk l123zxcvbnm432adfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.123"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, - ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, Constants.EMPTY_STRING, Constants.EMPTY_STRING, - null, null, Constants.EMPTY_STRING, "Product", "full"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductFullNameRemoveExtraSpaces() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setFullName("Abbaaa a1"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setFullName("Abbaaa a1"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionValidationIsEmpty() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setDescription(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_MISSING_DESCRIPTION, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionValidationIsNull() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setDescription(null); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_MISSING_DESCRIPTION, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionValidCharacters01() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setDescription("qwertyuiopasdfghjklzxcvbnm1234567890<b>Bold<</b>"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setDescription("qwertyuiopasdfghjklzxcvbnm1234567890Bold<"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionValidCharacters02() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setDescription("~!@#$%^&*()_+<>?qwertyuiopasdfghjklzxcvbnm1234567890#"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setDescription("~!@#$%^&*()_+<>?qwertyuiopasdfghjklzxcvbnm1234567890#"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionInValidCharacters() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setDescription("מה"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_INVALID_DESCRIPTION, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionRemoveSpacesFromBeginning() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setDescription(" abcd12345"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setDescription("abcd12345"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionRemoveSpacesFromTheEnd() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setDescription("abcd 12345 xcvb "); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setDescription("abcd 12345 xcvb"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionMaxLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setDescription( - "Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12asdfghjklzxcvbnmqwertyui"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDescriptionExceedMaxLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setDescription( - "Abxba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12Abba1234567890asdfghjkl123zxcvbnm432asdfghjkl_-.123Abba1234567890asdfghjkl23zxcvbnm432asdfghjkl_-.12asdfghjklzxcvbnmqwertyui"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", "1024"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductTagIsEmpty() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product"); - productReqDetails.setTags(Arrays.asList("")); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_FIELD_FORMAT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", "tag"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - // DE192351 - @Test - public void createProductTagValidationAllowedCharacters() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), "Acde2@3:4& m=n+b-u.j-u'g#b")); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductTagsNameValidationProductNameIsNotInTag() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Qwertyuiop1234567890asdfA"); - productReqDetails.setTags(Arrays.asList("Abc")); - normalizedName = productReqDetails.getName().trim().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductSingleTagMaxLength() throws Exception { - // SingleTagMaxLength = 50 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags( - Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345678")); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductSingleTagExceedMaxLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags( - Arrays.asList(productReqDetails.getName(), "Axbba1234567890asdfghjkl123zxcvbnm432asdfgh12345678")); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "50"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductAllTagsMaxLength() throws Exception { - // AllTagsMaxLength = 1024 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags( - Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345601", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345602", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345603", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345604", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345605", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345606", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345607", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345608", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh1234569", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345610", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345611", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345612", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345613", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345614", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345615", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345616", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345617", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345618", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345619", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345")); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductAllTagsExceedMaxLength() throws Exception { - // AllTagsMaxLength = 1024 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags( - Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345601", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345602", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345603", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345604", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345605", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345606", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345607", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345608", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh1234569", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345610", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345611", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345612", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345613", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345614", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345615", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345616", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345617", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345618", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345619", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh123456")); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "1024"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductDuplicateTagRemoved() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductContactsIsEmpty() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - productReqDetails.setContacts(Arrays.asList("")); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_INVALID_CONTACT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductContactsInvalidFormat() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - productReqDetails.setContacts(Arrays.asList("bt750345")); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_INVALID_CONTACT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductConvertContactsToLowerCase() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - productReqDetails.setContacts(Arrays.asList(productManager1.getUserId().toUpperCase())); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setContacts(Arrays.asList(productManager1.getUserId().toLowerCase())); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductContactsDoexNotContainTheProductCreator() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - productReqDetails.setContacts(Arrays.asList(productManager2.getUserId())); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setContacts(Arrays.asList(productManager2.getUserId(), productManager1.getUserId())); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductContactsNotAllowedAsdcUsers() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - productReqDetails.setContacts(Arrays.asList(designerUser.getUserId())); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_PRODUCT_CONTACT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, - designerUser.getUserId()); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductContactsNotAsdcUser() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); // Bug @:&=+'# - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase(); - String nonAsdcUser = "bh1234"; - productReqDetails.setContacts(Arrays.asList(nonAsdcUser)); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_PRODUCT_CONTACT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, nonAsdcUser); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductProjectCodeIsEmpty() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setProjectCode(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.MISSING_PROJECT_CODE, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductProjectCodeIsNull() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setProjectCode(null); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.MISSING_PROJECT_CODE, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductProjectCodeIsNotNumeric() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setProjectCode("asdfgh"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_PROJECT_CODE, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductProjectCodeHasnMinCharacters() throws Exception { - // Min =5 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setProjectCode("12345"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductProjectCodeHasnMaxCharacters() throws Exception { - // Max =10 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setProjectCode("1234567890"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductProjectCodeExceedMaxCharacters() throws Exception { - // Max =10 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setProjectCode("12345678901"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_PROJECT_CODE, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductProjectCodeLessThanMinCharacters() throws Exception { - // Max =10 - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setProjectCode("1234"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_PROJECT_CODE, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIconIsEmpty() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setIcon(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_MISSING_ICON, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIconIsNull() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setIcon(null); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_MISSING_ICON, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIconMaxLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setIcon("asdfghjklqwertyuiozxcvbfv"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIconExceedMaxLength() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setIcon("asdfghjklqwertyuiozxcvbf12"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product", "25"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIconAllowedCharacters() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setIcon("a--s-fghjk_q__r1234567890"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIconInValidCharacters() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - String icon = "asdfg"; - char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', - '|', '\\', ',' }; - RestResponse createProduct; - for (int i = 0; i < invalidChars.length; i++) { - productReqDetails.setIcon(icon + invalidChars[i]); - createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", - productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.COMPONENT_INVALID_ICON, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, "Product"); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - } - - @Test - public void createProductIsActiveisEmpty() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setActive(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setActive("false"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIsActiveisNull() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setActive(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - productReqDetails.setActive("false"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIsActiveisFalse() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setActive("false"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIsActiveisHasInvalidValue() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setActive("xfalse"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, - createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "", productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_CONTENT, - Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - constructFieldsForAuditValidation.setRESOURCE_NAME(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test - public void createProductIsActiveisTrue() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Product1"); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - productReqDetails.setActive("true"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - ////////////////////////////////////////////// - // DE192424 - @Test - public void createProductNameValidationNormalizationNameWithSpaces() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setName("Abba Emma"); - // productReqDetails.setName("abba emma"); - // productReqDetails.setTags(Arrays.asList("abba emma")); - normalizedName = productReqDetails.getName().toLowerCase().replaceAll("\\s+", ""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - String actualNormalizedNameFromResponse = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), - "normalizedName"); - assertTrue(actualNormalizedNameFromResponse.equals(normalizedName)); - // productReqDetails.setName("Abba Emma"); - String productUuid = ResponseParser.getUuidFromResponse(createProduct); - compareExpectedAndActualProducts(productReqDetails, createProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProductRes); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation( - expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, - "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, productUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - private void compareExpectedAndActualProducts(ProductReqDetails productReqDetails, RestResponse createProduct) - throws JSONException { - String productName = ResponseParser.getNameFromResponse(createProduct); - assertTrue(productReqDetails.getName().equals(productName)); - String productIcon = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "icon"); - assertTrue(productReqDetails.getIcon().equals(productIcon)); - String productFullName = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "fullName"); - assertTrue(productReqDetails.getFullName().equals(productFullName)); - String productProjectCode = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "projectCode"); - assertTrue(productReqDetails.getProjectCode().equals(productProjectCode)); - String productIsActive = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "isActive"); - String expectedIsActive = (productReqDetails.getActive() != null ? productReqDetails.getActive() : "false"); - assertTrue(productIsActive.equals(expectedIsActive)); - String productdescription = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "description"); - assertTrue(productReqDetails.getDescription().equals(productdescription)); - String productNormalizedName = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), - "normalizedName"); - assertTrue(normalizedName.equals(productNormalizedName)); - String productContacts = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "contacts"); - JSONArray reciviedContacts = new JSONArray(productContacts); - String actualContact = null; - for (int i = 0; i < reciviedContacts.length(); i++) { - actualContact = reciviedContacts.getString(i); - assertEquals(productReqDetails.getContacts().get(i), actualContact); - } - String productTags = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "tags"); - JSONArray reciviedTages = new JSONArray(productTags); - String actualTag = null; - for (int i = 0; i < reciviedTages.length(); i++) { - actualTag = reciviedTages.getString(i); - assertEquals(productReqDetails.getTags().get(i), actualTag); - } - } - - // END - /////////////////////////////////////////////////////// - @Test - public void createProductSuccessFlow() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, - createProduct.getErrorCode().intValue()); - - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - assertEquals("Check response code after getting created Product", BaseRestUtils.STATUS_CODE_SUCCESS, - getProductRes.getErrorCode().intValue()); - - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(false)); - } - - @Test - public void createProductSetIsActive() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setActive("true"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, - createProduct.getErrorCode().intValue()); - - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), - productManager1.getUserId()); - assertEquals("Check response code after getting created Product", BaseRestUtils.STATUS_CODE_SUCCESS, - getProductRes.getErrorCode().intValue()); - - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, - ComponentOperationEnum.GET_COMPONENT); - assertEquals(actualProduct.getIsActive(), new Boolean(true)); - } - - @Test - public void createProductNoIcon() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setIcon(null); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_MISSING_DATA, - createProduct.getErrorCode().intValue()); - - } - - @Test - public void createProductNoProjectCode() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - productReqDetails.setProjectCode(null); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_MISSING_DATA, - createProduct.getErrorCode().intValue()); - - } - -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java deleted file mode 100644 index d91391d967..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java +++ /dev/null @@ -1,2203 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.model.category.CategoryDefinition; -import org.openecomp.sdc.ci.tests.api.Urls; -import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit; -import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.general.Convertor; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils; -import org.openecomp.sdc.common.api.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -public class ProductCrudTest extends ProductBaseTest { - private static Logger log = LoggerFactory.getLogger(ProductCrudTest.class.getName()); - @Rule - public static TestName name = new TestName(); - - public static String INITIAL_PRODUCT_VERSION = "0.1"; - public static String CREATE_AUDIT_ACTION = "Create"; - public static String UPDATE_AUDIT_ACTION = "Update"; - public static String COMPONENT_TYPE = "Product"; - - private ProductReqDetails productReqDetails; - private RestResponse createProduct; - private Product product; - - public ProductCrudTest() { - super(name, ProductCrudTest.class.getName()); - } - - @Test // (enabled=false) - public void createAndGetAll() throws Exception { - createProductAndGet(UserRoleEnum.DESIGNER); - } - - private void createProductAndGet(UserRoleEnum user) throws Exception, IOException { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - - RestResponse catalog = CatalogRestUtils.getCatalog(user.getUserId()); - assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_SUCCESS, catalog.getErrorCode().intValue()); - - try { - JsonElement jElement = new JsonParser().parse(catalog.getResponse()); - JsonObject jObject = jElement.getAsJsonObject(); - JsonArray products = (JsonArray) jObject.get("products"); - assertEquals("Check product array size", 1, products.size()); - Iterator<JsonElement> iter = products.iterator(); - while (iter.hasNext()) { - JsonElement next = iter.next(); - Product product = ResponseParser.parseToObjectUsingMapper(next.toString(), Product.class); - assertNotNull(product); - assertEquals("Check product name", productReqDetails.getName(), product.getName()); - // Map<String, String> allVersions = product.getAllVersions(); - // assertEquals("Check product name", 1, allVersions.size()); - } - - } catch (Exception e) { - log.debug("exception", e); - } - } - - @Test - public void getAllNoProcduts() throws Exception { - - RestResponse catalog = CatalogRestUtils.getCatalog(); - assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_SUCCESS, catalog.getErrorCode().intValue()); - - try { - JsonElement jElement = new JsonParser().parse(catalog.getResponse()); - JsonObject jObject = jElement.getAsJsonObject(); - JsonArray products = (JsonArray) jObject.get("products"); - assertEquals("Check product array size", 0, products.size()); - } catch (Exception e) { - log.debug("exception", e); - } - - } - - @Test - public void getAllNoAttHeader() throws Exception { - String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort()); - - List<String> headersToRemove = new ArrayList<String>(); - headersToRemove.add(HttpHeaderEnum.USER_ID.getValue()); - - RestResponse catalog = CatalogRestUtils.sendGetAndRemoveHeaders(url, null, headersToRemove); - assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION, catalog.getErrorCode().intValue()); - - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), catalog.getResponse()); - } - - @Test - public void getAllWrongUser() throws Exception { - RestResponse catalog = CatalogRestUtils.getCatalog("kj8976"); - assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, catalog.getErrorCode().intValue()); - - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), catalog.getResponse()); - } - - @Test // (enabled=false) - public void getAllWithProductStrategist_User() throws Exception { - createProductAndGet(UserRoleEnum.PRODUCT_STRATEGIST1); - } - - @Test // (enabled=false) - public void getAllWithProductManager_User() throws Exception { - createProductAndGet(UserRoleEnum.PRODUCT_MANAGER1); - } - - @Test // (enabled=false) - public void createProductNoCategories() throws Exception { - createProductWithCategories(null); - } - - @Test // (enabled=false) - public void createProductOneGrouping() throws Exception { - // Category1->[Subcategory1->[Grouping1]] - createProductWithCategories(defaultCategories); - } - - @Test // (enabled=false) - public void createProductTwoGroupingsSameSubCategory() throws Exception { - // Category1->Subcategory1->[Grouping1, Grouping11] - List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory(); - createProductWithCategories(addSecondGroupingToDefaultCategory); - } - - @Test // (enabled=false) - public void createProductTwoSubsDifferentGroupings() throws Exception { - // Category1->[Subcategory1->[Grouping1, - // Grouping11],Subcategory2->[Grouping12]] - List<CategoryDefinition> addSubcategoryAndGroupingToDefaultCategory = addSubcategoryAndGroupingToDefaultCategory(); - createProductWithCategories(addSubcategoryAndGroupingToDefaultCategory); - } - - @Test // (enabled=false) - public void createManyGroupingsDiffCategories() throws Exception { - // [Category1->[Subcategory1->[Grouping1, - // Grouping11],Subcategory2->[Grouping12]], - // Category2->[Subcategory1->[Grouping1],Subcategory2->[Grouping1]], - // Category3->[Subcategory1->[Grouping11],Subcategory2->[Grouping11, - // Grouping22]]] - List<CategoryDefinition> addSubcategoryAndGroupingToDefaultCategory = addManyGroupingsDiffCategories(); - createProductWithCategories(addSubcategoryAndGroupingToDefaultCategory); - } - - @Test // (enabled=false) - public void createProductEmptyUserId() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - User emptyUser = new User(); - emptyUser.setUserId(""); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, emptyUser); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION, createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, emptyUser); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(expectedProduct, CREATE_AUDIT_ACTION, emptyUser, ActionStatus.MISSING_INFORMATION, Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, - null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test // (enabled=false) - public void createProductNonExistingUserId() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - User notExistingUser = new User(); - notExistingUser.setUserId("jj6444"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, notExistingUser); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, notExistingUser); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(expectedProduct, CREATE_AUDIT_ACTION, notExistingUser, ActionStatus.RESTRICTED_OPERATION, Constants.EMPTY_STRING, Constants.EMPTY_STRING, - null, null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test // (enabled=false) - public void createProductInvalidJson() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct_Invalid_Json(productManager1.getUserId()); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, productManager1); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_CONTENT, Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, - null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setRESOURCE_NAME(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test // (enabled=false) - public void createProductAdminRoleNotAllowed() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - User wrongRole = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, wrongRole); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, wrongRole); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(expectedProduct, CREATE_AUDIT_ACTION, wrongRole, ActionStatus.RESTRICTED_OPERATION, Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, - null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test // (enabled=false) - public void createProductProductStrategistRoleNotAllowed() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - User wrongRole = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST3); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, wrongRole); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, createProduct.getErrorCode().intValue()); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, wrongRole); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(expectedProduct, CREATE_AUDIT_ACTION, wrongRole, ActionStatus.RESTRICTED_OPERATION, Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, - null, Constants.EMPTY_STRING); - constructFieldsForAuditValidation.setCURR_VERSION(""); - constructFieldsForAuditValidation.setCURR_STATE(""); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - @Test // (enabled=false) - public void getProductSuccessFlow() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - assertEquals("Check response code after getting created Product", BaseRestUtils.STATUS_CODE_SUCCESS, getProductRes.getErrorCode().intValue()); - - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.GET_COMPONENT); - } - - @Test // (enabled=false) - public void getNonExistedProduct() throws Exception { - - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - assertEquals("Check response code after getting created Product", BaseRestUtils.STATUS_CODE_SUCCESS, getProductRes.getErrorCode().intValue()); - - Product product = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class); - assertEquals("Assert on product icon", "Product1", product.getName()); - - RestResponse deleteProductRes = ProductRestUtils.deleteProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - assertEquals("Check response code for deletign Product", BaseRestUtils.STATUS_CODE_SUCCESS, deleteProductRes.getErrorCode().intValue()); - - RestResponse getProductAfterDeleteRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - assertEquals("Check response code after getting deleted Product", BaseRestUtils.STATUS_CODE_NOT_FOUND, getProductAfterDeleteRes.getErrorCode().intValue()); - } - - @Test // (enabled=false) - public void getProductMissingHeader() throws Exception { - - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - - productManager1.setUserId(null); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - assertEquals("Check response code after getting created Producuct with UserId extracted from header", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION, getProductRes.getErrorCode().intValue()); - - } - - @Test // (enabled=false) - public void getProductNonExistingUser() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - - productManager1.setUserId("bt1111"); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - assertEquals("Check response code after getting created Producuct with non exsisting user", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, getProductRes.getErrorCode().intValue()); - } - - @Test // (enabled=false) - public void createProductAndGetProductWithDifferentUser() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - User sdncProductStrategistUserAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), sdncProductStrategistUserAdminDetails.getUserId()); - assertEquals("Check response code after getting created Product different user role", BaseRestUtils.STATUS_CODE_SUCCESS, getProductRes.getErrorCode().intValue()); - } - - // US594753 - Update Product metadata - - // If user update "product name" we need to remove the old product name from - // "Tags" and add the new product name instead - will handled in mew US - @Test(enabled = false) - public void updateProductAllFieldsByPM() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - // Update product - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("NewProductName"); - List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory(); - productReqDetails.setFullName("New Full name"); - productReqDetails.setActive("false"); - productReqDetails.setContacts(Arrays.asList(productManager2.getUserId().toLowerCase(), productManager1.getUserId().toLowerCase())); - productReqDetails.setDescription("New Product Description"); - productReqDetails.setIcon("asdfghjklqwertyuiozxcvbfv"); - productReqDetails.setProjectCode("98765"); - productReqDetails.setCategories(addSecondGroupingToDefaultCategory); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), - // productOldName)); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductByPS() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription("New discription"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productStrategistUser1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateProduct.getResponse()); - } - - @Test // (enabled=false) - public void updateProductByAdmin() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription("New discription"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, designerUser); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateProduct.getResponse()); - } - - @Test // (enabled=false) - public void updateProductByNonPmUser() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - // Update product name - productReqDetails.setDescription("New discription"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, designerUser); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateProduct.getResponse()); - } - - @Test // (enabled=false) - public void updateProductByNonAsdcUser() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - // Update product name - productReqDetails.setDescription("New discription"); - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - nonAsdcUser.setUserId("bt789k"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, nonAsdcUser); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateProduct.getResponse()); - } - - @Test // (enabled=false) - public void updateProductUserIdIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - // Update product name - productReqDetails.setDescription("New discription"); - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - nonAsdcUser.setUserId(""); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, nonAsdcUser); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), updateProduct.getResponse()); - } - - @Test // (enabled=false) - public void updateProductByNonProductOwner() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription("New discription"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.GET_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductNotInCheckoutState() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - // Update product name - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - String valueFromJsonResponse = ResponseParser.getValueFromJsonResponse(changeProductLifeCycle.getResponse(), "lastUpdateDate"); - expectedProduct.setLastUpdateDate(Long.parseLong(valueFromJsonResponse)); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductNameIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName(""); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("abbreviated"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductNameIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager2, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - // List<String> tags = productReqDetails.getTags(); - // tags.removeAll(tags); - productReqDetails.setTags(new ArrayList<>()); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName(null); // no update will be performed - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2); - ProductRestUtils.checkSuccess(updateProduct); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager2); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(product.getName().toLowerCase()); - expectedProduct.setName(product.getName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductNameLessThanMinLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("ABC"); // no update will be performed - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("abbreviated"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - // If user update "product name" we need to remove the old product name from - // "Tags" and add the new product name instead - will handled in mew US - @Test(enabled = false) - public void updateProductNameHasMinLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager2, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("NewP"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - productReqDetails.setLastUpdaterUserId(productManager2.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager2.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager2); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - // If user update "product name" we need to remove the old product name from - // "Tags" and add the new product name instead - will handled in mew US - // DE193857 - Normalized Name is not removing special characters - @Test(enabled = false) - public void updateProductNameMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - // Update product name - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("Ac_2B3U4k mSKnob-u.j-uGgP"); - String newNormalizedName = "ac2b3u4kmsknobujuggp"; - String newName = "Ac_2B3U4k MSKnob-u.j-uGgP"; - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setTags(Arrays.asList(newName)); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(newNormalizedName); - expectedProduct.setName(newName); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductNameExceedMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("Ac_2B3U4k mSKnob-u.j-uGgPx"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("abbreviated"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductNameAlreadyExist() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager2); - ProductRestUtils.checkCreateResponse(createProduct); - Product product1 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product1, productManager2, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setName("Product2000"); - // productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - createProduct = ProductRestUtils.createProduct(productReqDetails, productManager2); - ProductRestUtils.checkCreateResponse(createProduct); - Product product2 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product2, productManager2, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product2, productManager2, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product2.getUniqueId()); - productReqDetails.setUUID(product2.getUUID()); - productReqDetails.setName(product1.getName()); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_ALREADY_EXISTS, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add(product1.getName()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager2.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product2.getUniqueId()); - expectedProduct.setVersion(product2.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - // DE193857 - Normalized Name is not removing special characters - // If user update "product name" we need to remove the old product name from - // "Tags" and add the new product name instead - will handled in mew US - @Test(enabled = false) - public void updateProductNameAllowedCharacters() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - // Update product name - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("A_BU4k m&K=o#b-u.j-uG'g+P"); // Allowed - // characters - // [a-z,A-Z,0-9] - // , ‘ ‘ - // (space), - // ampersand - // "&", dash - // “-“, plus - // "+", period - // ".", - // apostrophe - // "'", hashtag - // "#", equal - // "=", period - // ":", at "@", - // and - // underscore - // "_" - String newNormalizedName = "abu4km&kobujuggp"; - String newName = "A_BU4k M&K=o#b-u.j-uG'g+P"; - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setTags(Arrays.asList(newName)); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(newNormalizedName); - expectedProduct.setName(newName); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - // If user update "product name" we need to remove the old product name from - // "Tags" and add the new product name instead - will handled in mew US - @Test(enabled = false) - public void updateProductNameRemoveSpaceFromBeginning() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName(" asdfg"); - String newNormalizedName = "asdfg"; - String newName = "Asdfg"; - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // productReqDetails.setTags(Arrays.asList(newName, productOldName)); - productReqDetails.setTags(Arrays.asList(newName)); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(newNormalizedName); - expectedProduct.setName(newName); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - // If user update "product name" we need to remove the old product name from - // "Tags" and add the new product name instead - will handled in mew US - @Test(enabled = false) - public void updateProductNameRemoveSpaceFromEnd() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("asdfg fc "); - String newNormalizedName = "asdfgfc"; - String newName = "Asdfg Fc"; - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // productReqDetails.setTags(Arrays.asList(newName, productOldName)); - productReqDetails.setTags(Arrays.asList(newName)); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(newNormalizedName); - expectedProduct.setName(newName); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - //// DE193857 - Normalized Name is not removing special characters - // If user update "product name" we need to remove the old product name from - //// "Tags" and add the new product name instead - will handled in mew US - @Test(enabled = false) - public void updateProductNameRemoveExtraNonAlphanumericChars() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("A__k &&==##---u..hG'''+++"); - String newNormalizedName = "akhg"; - String newName = "A_k &=#-u.hG'+"; - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // productReqDetails.setTags(Arrays.asList(newName, productOldName)); - productReqDetails.setTags(Arrays.asList(newName)); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(newNormalizedName); - expectedProduct.setName(newName); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - // If user update "product name" we need to remove the old product name from - // "Tags" and add the new product name instead - will handled in mew US - @Test(enabled = false) - public void updateProductNameValidationStartWithNumber() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("1000Ab"); - String newNormalizedName = productReqDetails.getName().toLowerCase(); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName())); - // productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), - // productOldName)); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setNormalizedName(newNormalizedName); - expectedProduct.setName(productReqDetails.getName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductNameValidationStartWithNonAlphaNumeric() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setName("_1000Ab"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("abbreviated"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductFullNameIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName(""); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("full"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductFullNameIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName(null); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setNormalizedName(product.getNormalizedName()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setFullName(product.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductFullNameHasMinLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName("asdc"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setNormalizedName(product.getNormalizedName()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setFullName(productReqDetails.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductFullNameHasMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName("1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setNormalizedName(product.getNormalizedName()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setFullName(productReqDetails.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductFullNamelessThanMinLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName("123"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("full"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductFullNameExceedMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName("1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjkx"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("full"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - // DE193947 - @Test - public void updateProductFullNameWithSpecialCharacters() throws Exception { - char invalidChars[] = { '~', '!', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|', '\\', ',', '$', '#', '@', '+' }; - String fullName = "avbng"; - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - for (int i = 0; i < invalidChars.length; i++) { - productReqDetails.setFullName(fullName + invalidChars[i]); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, updateProduct.getErrorCode().intValue()); - } - } - - @Test // (enabled=false) - public void updateProductFullNameValidCharactersCharacters01() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName("qwertyuiopasdfghjklzxcvbnm1234567890<b>Bold<</b>"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setNormalizedName(product.getNormalizedName()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setFullName("qwertyuiopasdfghjklzxcvbnm1234567890Bold<"); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductFullNameRemoveExtraSpaces() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setFullName("Abbaaa a1"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setNormalizedName(product.getNormalizedName()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setFullName("Abbaaa a1"); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription(""); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription(null); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test(enabled = false) - public void updateProductDescriptionValidCharacters01() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription("~!@#$%^&*()_+<>?qwertyuiopasdfghjklzxcvbnm1234567890#"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setDescription("~!@#$%^&*()_+<>?qwertyuiopasdfghjklzxcvbnm1234567890#"); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionValidCharacters02() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription("qwertyuiopasdfghjklzxcvbnm1234567890<b>Bold<</b>"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setDescription("qwertyuiopasdfghjklzxcvbnm1234567890Bold<"); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionInValidCharacters() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription("מה"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_DESCRIPTION.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionRemoveSpacesFromBeginning() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription(" abcd12345 g"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setDescription("abcd12345 g"); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionRemoveSpacesFromTheEnd() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setDescription("abcd12345 gdf "); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setDescription("abcd12345 gdf"); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - String description = "1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfg"; - productReqDetails.setDescription(description); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setDescription(description); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductDescriptionExceedMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - String description = "01234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfg"; - productReqDetails.setDescription(description); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("1024"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductTagIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(Arrays.asList("")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - varibales.add("tag"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductTagIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(null); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setTags(product.getTags()); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductTagsNameValidationProductNameIsNotInTag() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(Arrays.asList("Abc")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(), new ArrayList<String>(), updateProduct.getResponse()); - } - - @Test // (enabled=false) - public void createProductSingleTagMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345678")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setTags(productReqDetails.getTags()); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductSingleTagExceedMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh123456788")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("50"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductAllTagsMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345601", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345602", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345603", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345604", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345605", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345606", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345607", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345608", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh1234569", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345610", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345611", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345612", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345613", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345614", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345615", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345616", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345617", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345618", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345619", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setTags(productReqDetails.getTags()); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductAllTagsExceedMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345601", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345602", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345603", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345604", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345605", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345606", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345607", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345608", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh1234569", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345610", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345611", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345612", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345613", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345614", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345615", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345616", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345617", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345618", "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345619", - "Abba1234567890asdfghjkl123zxcvbnm432asdfgh123456")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add("1024"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductTagsDuplicateTagRemoved() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), "KoKo", "KoKo")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata updated - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setTags(Arrays.asList(productReqDetails.getName(), "KoKo")); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductContactsIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setContacts(Arrays.asList("")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductContactsIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setContacts(null); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductContactsInvalidFormat() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setContacts(Arrays.asList("bt750345")); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(COMPONENT_TYPE); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductConvertContactsToLowerCase() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setContacts(Arrays.asList(productManager2.getUserId().toUpperCase())); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setContacts(Arrays.asList(productManager2.getUserId().toLowerCase(), productManager1.getUserId())); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductContactsNotAllowedAsdcUsers() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setContacts(Arrays.asList(productStrategistUser1.getUserId())); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(productStrategistUser1.getUserId()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PRODUCT_CONTACT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductContactsNotAsdcUser() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - String nonAsdcUserUserId = "bt567h"; - productReqDetails.setContacts(Arrays.asList(nonAsdcUserUserId)); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> varibales = new ArrayList<String>(); - varibales.add(nonAsdcUserUserId); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PRODUCT_CONTACT.name(), varibales, updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductProjectCodeIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setProjectCode(""); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_PROJECT_CODE.name(), new ArrayList<String>(), updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductProjectCodeIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setProjectCode(null); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setProjectCode(product.getProjectCode()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductProjectCodeLessThanMinCharacters() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setProjectCode("9870"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROJECT_CODE.name(), new ArrayList<String>(), updateProduct.getResponse()); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductProjectCodeHasnMinCharacters() throws Exception { // min - // =5 - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setProjectCode("98700"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setProjectCode(productReqDetails.getProjectCode()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductProjectCodeHasnMaxCharacters() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setProjectCode("1234567890"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setProjectCode(productReqDetails.getProjectCode()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductProjectCodeExceedMaxCharacters() throws Exception {// Max - // =10 - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setProjectCode("12345678901"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROJECT_CODE.name(), new ArrayList<String>(), updateProduct.getResponse()); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setProjectCode(product.getProjectCode()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductProjectCodeIsNotNumeric() throws Exception { - // Max =10 - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setProjectCode("1234a"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROJECT_CODE.name(), new ArrayList<String>(), updateProduct.getResponse()); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setProjectCode(product.getProjectCode()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIconIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setIcon(""); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> variables = new ArrayList<String>(); - variables.add(COMPONENT_TYPE); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), variables, updateProduct.getResponse()); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIcon(product.getIcon()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIconIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setIcon(null); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - // Get Product and verify that metadata didn't change - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIcon(product.getIcon()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIconMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setIcon("A_a-1-2--b__BB1234567890A"); // Max length = - // 25 - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIcon(productReqDetails.getIcon()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIconExceedMaxLength() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setIcon("A_a-1-2--b__BB1234567890A_"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> variables = new ArrayList<String>(); - variables.add(COMPONENT_TYPE); - variables.add("25"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), variables, updateProduct.getResponse()); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIcon(product.getIcon()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIconInValidCharacters() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - String icon = "asdfg"; // Allowed characters [a-zA-Z0-9], dash (‘-‘), - // underscore (‘_’). - char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|', '\\', ',' }; - RestResponse updateProduct; - for (int i = 0; i < invalidChars.length; i++) { - productReqDetails.setIcon(icon + invalidChars[i]); - updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ArrayList<String> variables = new ArrayList<String>(); - variables.add(COMPONENT_TYPE); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), variables, updateProduct.getResponse()); - } - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIcon(product.getIcon()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIsActiveIsEmpty() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setActive(""); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIsActive(false); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIsActiveIsTrue() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setActive("true"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIsActive(true); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIsActiveIsNull() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories); - productReqDetails.setActive("true"); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setActive(null); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIsActive(true); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIsActiveIsFalse() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setActive("false"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - expectedProduct.setIsActive(false); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductIsActiveHasInvalidValue() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setActive("eeeee"); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), new ArrayList<String>(), updateProduct.getResponse()); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT, updateProduct.getErrorCode().intValue()); - RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - ProductRestUtils.checkSuccess(getProduct); - Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - expectedProduct.setUniqueId(product.getUniqueId()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class); - expectedProduct.setVersion(product.getVersion()); - expectedProduct.setLastUpdaterUserId(productManager1.getUserId()); - expectedProduct.setLastUpdaterFullName(productManager1.getFullName()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductAssociations() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory(); - productReqDetails.setCategories(addSecondGroupingToDefaultCategory); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setCategories(productReqDetails.getCategories()); - expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductAssociations02() throws Exception { - List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory(); // Category1->Subcategory1->[Grouping1, - // Grouping11] - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(addSecondGroupingToDefaultCategory); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - List<CategoryDefinition> defaultCategory = addSubcategoryAndGroupingToDefaultCategory(); // Category1->[Subcategory1->[Grouping1, - // Grouping11],Subcategory2->[Grouping12]] - productReqDetails.setCategories(defaultCategory); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setCategories(productReqDetails.getCategories()); - expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductRemoveAllAssociations() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - List<CategoryDefinition> defaultCategory = new ArrayList<CategoryDefinition>(); - productReqDetails.setCategories(defaultCategory); - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setCategories(productReqDetails.getCategories()); - expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - @Test // (enabled=false) - public void updateProductAssociationsCategotyIsNull() throws Exception { - createProducrByPSAndCheckIn(); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - productReqDetails.setUniqueId(product.getUniqueId()); - productReqDetails.setUUID(product.getUUID()); - productReqDetails.setCategories(null);// product categories will not be - // updated - RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1); - ProductRestUtils.checkSuccess(updateProduct); - productReqDetails.setLastUpdaterUserId(productManager1.getUserId()); - productReqDetails.setLastUpdaterFullName(productManager1.getFullName()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1); - expectedProduct.setUUID(product.getUUID()); - expectedProduct.setInvariantUUID(product.getInvariantUUID()); - expectedProduct.setCategories(product.getCategories()); - expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase()); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.UPDATE_COMPONENT); - } - - //////////////////////////////////////////////////////////////////////// - - private void createProductWithCategories(List<CategoryDefinition> categoryDefinitions) throws Exception { - ProductReqDetails productReqDetails = (categoryDefinitions != null ? ElementFactory.getDefaultProduct(categoryDefinitions) : ElementFactory.getDefaultProduct()); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - Product actualProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - String actualUuid = ResponseParser.getUuidFromResponse(createProduct); - Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION, productManager1); - String normalizedNameFomJsonResponse = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(), "normalizedName"); - expectedProduct.setNormalizedName(normalizedNameFomJsonResponse); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct, ComponentOperationEnum.CREATE_COMPONENT); - ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING, "0.1", null, - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, actualUuid); - AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION); - } - - private void createProducrByPSAndCheckIn() throws Exception { - productReqDetails = ElementFactory.getDefaultProduct(defaultCategories); - createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - ProductRestUtils.checkCreateResponse(createProduct); - product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.checkSuccess(changeProductLifeCycle); - } - - @Test - public void checkInvariantUuidIsImmutable() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - String invariantUuidDefinedByUser = "!!!!!!!!!!!!!!!!!!!!!!!!"; - productReqDetails.setInvariantUUID(invariantUuidDefinedByUser); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - BaseRestUtils.checkStatusCode(createProduct, "create request failed", false, 201); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - Product ProductCreation = ResponseParser.convertProductResponseToJavaObject(createProduct.getResponse()); - String invariantUUIDcreation = ProductCreation.getInvariantUUID(); - - // validate get response - RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(), productManager1.getUserId()); - BaseRestUtils.checkSuccess(getProductRes); - Product productGetting = ResponseParser.convertProductResponseToJavaObject(getProductRes.getResponse()); - String invariantUUIDgetting = productGetting.getInvariantUUID(); - assertEquals(invariantUUIDcreation, invariantUUIDgetting); - - // Update Product with new invariant UUID - RestResponse restResponseUpdate = ProductRestUtils.updateProduct(productReqDetails, productManager1); - BaseRestUtils.checkSuccess(restResponseUpdate); - Product updatedProduct = ResponseParser.convertProductResponseToJavaObject(restResponseUpdate.getResponse()); - String invariantUUIDupdating = updatedProduct.getInvariantUUID(); - assertEquals(invariantUUIDcreation, invariantUUIDupdating); - - // Do checkin - RestResponse restResponseCheckin = LifecycleRestUtils.changeProductState(productReqDetails, productManager1, LifeCycleStatesEnum.CHECKIN); - BaseRestUtils.checkSuccess(restResponseCheckin); - Product checkinProduct = ResponseParser.convertProductResponseToJavaObject(restResponseCheckin.getResponse()); - String invariantUUIDcheckin = checkinProduct.getInvariantUUID(); - String version = checkinProduct.getVersion(); - assertEquals(invariantUUIDcreation, invariantUUIDcheckin); - assertEquals(version, "0.1"); - - // Do checkout - RestResponse restResponseCheckout = LifecycleRestUtils.changeProductState(productReqDetails, productManager1, LifeCycleStatesEnum.CHECKOUT); - BaseRestUtils.checkSuccess(restResponseCheckout); - Product checkoutProduct = ResponseParser.convertProductResponseToJavaObject(restResponseCheckout.getResponse()); - String invariantUUIDcheckout = checkoutProduct.getInvariantUUID(); - version = checkoutProduct.getVersion(); - assertEquals(invariantUUIDcreation, invariantUUIDcheckout); - assertEquals(version, "0.2"); - - } - - // US672129 Benny - private void getProductValidateInvariantUuid(String productUniqueId, String invariantUUIDcreation) throws Exception { - RestResponse getProduct = ProductRestUtils.getProduct(productUniqueId, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId()); - assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, getProduct.getErrorCode().intValue()); - assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(getProduct)); - } - - @Test // invariantUUID generated when the component is created and never - // changed - public void productInvariantUuid() throws Exception { - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - String invariantUuidDefinedByUser = "12345"; - productReqDetails.setInvariantUUID(invariantUuidDefinedByUser); - RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1); - assertEquals("Check response code after create resource", BaseRestUtils.STATUS_CODE_CREATED, createProduct.getErrorCode().intValue()); - // invariantUUID generated when the component is created and never - // changed - String invariantUUIDcreation = ResponseParser.getInvariantUuid(createProduct); - getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation); - // Update Product with new invariant UUID - RestResponse restResponse = ProductRestUtils.updateProduct(productReqDetails, productManager1); - assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); - getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation); - // Checkin - restResponse = LifecycleRestUtils.changeProductState(productReqDetails, productManager1, LifeCycleStatesEnum.CHECKIN); - assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); - assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse)); - getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation); - // Checkout - restResponse = LifecycleRestUtils.changeProductState(productReqDetails, productManager1, LifeCycleStatesEnum.CHECKOUT); - assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); - assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse)); - getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation); - - // UnDo-CheckOut - restResponse = LifecycleRestUtils.changeProductState(productReqDetails, productManager1, LifeCycleStatesEnum.UNDOCHECKOUT); - assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); - assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse)); - getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation); - - } - -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductGetFollowedTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductGetFollowedTest.java deleted file mode 100644 index aebea697b2..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductGetFollowedTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class ProductGetFollowedTest extends ProductBaseTest { - - protected Product product200; - protected Product product400; - - private ProductReqDetails productDetails200; - private ProductReqDetails productDetails400; - - @Rule - public static TestName name = new TestName(); - - public ProductGetFollowedTest() { - super(name, ProductGetFollowedTest.class.getName()); - } - - @BeforeMethod - public void init() throws Exception { - createProducts(); - } - - @Test - public void followedPageTest() throws Exception { // Actions - RestResponse changeLifeCycleResponse; - changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeLifeCycleResponse); - changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeLifeCycleResponse); - // Expected users Followed page - ProductValidationUtils.checkUserFollowedPage(productManager1, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400); - ProductValidationUtils.checkUserFollowedPage(productManager2, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400); - } - - @Test - public void followedPagePmCheckedOutProductWasCheckInByOtherPm() throws Exception { - ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.changeProductLifeCycle(product400, productManager1, LifeCycleStatesEnum.CHECKOUT); - RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product200, productManager2, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeLifeCycleResponse); - - ProductValidationUtils.checkUserFollowedPage(productManager1, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400); - } - - @Test - public void followedPagePmCheckInProduct02() throws Exception { - ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN); - - ProductValidationUtils.checkUserFollowedPage(productManager1, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400); - ProductValidationUtils.checkUserFollowedPage(productManager2, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400); - } - - @Test - public void followedPageAdminCheckoutProductWasCheckedinByPm() throws Exception { - ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN); - RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product400, adminUser, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeLifeCycleResponse); - - ProductValidationUtils.checkUserFollowedPage(productManager1, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400); - } - - @Test - public void followedPageAdminCheckInProduct() throws Exception { - ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.changeProductLifeCycle(product400, adminUser, LifeCycleStatesEnum.CHECKOUT); - RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product400, adminUser, LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(changeLifeCycleResponse); - - ProductValidationUtils.checkUserFollowedPage(productManager1, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400); - } - - @Test - public void followedPagePmCheckoutProductWasCheckedinByAdmin() throws Exception { - ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN); - ProductRestUtils.changeProductLifeCycle(product200, adminUser, LifeCycleStatesEnum.CHECKOUT); - ProductRestUtils.changeProductLifeCycle(product200, adminUser, LifeCycleStatesEnum.CHECKIN); - RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product200, productManager2, LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(changeLifeCycleResponse); - - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product200); - ProductValidationUtils.checkUserFollowedPage(productManager2, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400); - ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400); - } - - private void createProducts() throws Exception { - // PM1 (Product manager) create :PR200 (check In State) - // PM2 (Product manager) create :PR400 (check In State) - - productDetails200 = ElementFactory.getDefaultProduct("CiProd200", defaultCategories); - productDetails400 = ElementFactory.getDefaultProduct("CiProd400", defaultCategories); - - RestResponse createProduct = ProductRestUtils.createProduct(productDetails200, productManager1); - ResourceRestUtils.checkCreateResponse(createProduct); - product200 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - - createProduct = ProductRestUtils.createProduct(productDetails400, productManager2); - ResourceRestUtils.checkCreateResponse(createProduct); - product400 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - } - -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java deleted file mode 100644 index 26bb3e29e9..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.testng.AssertJUnit.assertEquals; - -import org.junit.rules.TestName; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.testng.annotations.BeforeMethod; - -public abstract class ProductLifecycleTest extends ProductBaseTest { - - protected static final String CHECKIN_ACTION = "Checkin"; - protected static final String CHECKOUT_ACTION = "Checkout"; - protected static final String UNDO_CHECKOUT_ACTION = "UndoCheckout"; - - protected Product expectedProduct; - - public ProductLifecycleTest(TestName testName, String className) { - super(testName, className); - } - - @BeforeMethod - public void init() throws Exception { - ProductReqDetails defaultProduct = ElementFactory.getDefaultProduct(defaultCategories); - RestResponse createProduct = ProductRestUtils.createProduct(defaultProduct, productManager1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, - createProduct.getErrorCode().intValue()); - expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - } -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java deleted file mode 100644 index 479dbb9436..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; - -import org.apache.log4j.lf5.util.ResourceUtils; -import org.junit.Before; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.ArtifactUtils; -import org.openecomp.sdc.ci.tests.utils.DbUtils; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; - -public class ProductTestBase extends ProductBaseTest { - - public ProductTestBase(TestName testName, String className) { - super(testName, className); - } - - protected ResourceReqDetails downloadResourceDetails; - protected ServiceReqDetails serviceDetails; - protected ComponentInstanceReqDetails resourceInstanceReqDetails; - protected User sdncUserDetails; - protected ArtifactReqDetails heatArtifactDetails; - protected ArtifactReqDetails defaultArtifactDetails; - protected ResourceUtils resourceUtils; - protected ArtifactUtils artifactUtils; - protected Resource resource; - protected Service service; - protected Product product; - - // protected static ServiceUtils serviceUtils = new ServiceUtils(); - - @Before - public void before() throws Exception { - - initializeMembers(); - createComponents(); - - } - - public void initializeMembers() throws IOException, Exception { - - downloadResourceDetails = ElementFactory.getDefaultResource(); - serviceDetails = ElementFactory.getDefaultService(); - sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); - resourceInstanceReqDetails = ElementFactory.getDefaultComponentInstance(); - - } - - protected void createComponents() throws Exception { - - RestResponse response = ResourceRestUtils.createResource(downloadResourceDetails, sdncUserDetails); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("resource uniqueId is null:", downloadResourceDetails.getUniqueId()); - - ArtifactReqDetails heatArtifactDetails = ElementFactory - .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); - response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncUserDetails, - downloadResourceDetails.getUniqueId()); - assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(), - response.getErrorCode() == 200); - - // certified resource - response = LifecycleRestUtils.certifyResource(downloadResourceDetails); - assertTrue("certify resource request returned status:" + response.getErrorCode(), - response.getErrorCode() == 200); - - response = ResourceRestUtils.getResource(downloadResourceDetails.getUniqueId()); - assertTrue("response code is not 200, returned: " + response.getErrorCode(), response.getErrorCode() == 200); - resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse()); - - response = ServiceRestUtils.createService(serviceDetails, sdncUserDetails); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("service uniqueId is null:", serviceDetails.getUniqueId()); - - // add resource instance with HEAT deployment artifact to the service - resourceInstanceReqDetails.setComponentUid(downloadResourceDetails.getUniqueId()); - response = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails, sdncUserDetails, - serviceDetails.getUniqueId(), ComponentTypeEnum.SERVICE); - assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201); - - // certified service - response = LifecycleRestUtils.certifyService(serviceDetails); - assertTrue("certify service request returned status:" + response.getErrorCode(), - response.getErrorCode() == 200); - - response = ServiceRestUtils.getService(serviceDetails, sdncUserDetails); - assertTrue("response code is not 200, returned: " + response.getErrorCode(), response.getErrorCode() == 200); - service = ResponseParser.convertServiceResponseToJavaObject(response.getResponse()); - - DbUtils.cleanAllAudits(); - - ProductReqDetails defaultProduct = ElementFactory.getDefaultProduct(defaultCategories); - RestResponse createProduct = ProductRestUtils.createProduct(defaultProduct, productStrategistUser1); - assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED, - createProduct.getErrorCode().intValue()); - product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class); - - // add service instance to product - // - - } -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java deleted file mode 100644 index 412e6fd92d..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.model.ArtifactUiDownloadData; -import org.openecomp.sdc.ci.tests.utils.Decoder; -import org.openecomp.sdc.ci.tests.utils.Utils; -import org.testng.annotations.Test; - -import com.google.gson.Gson; - -public class ProductToscaYamlGenerationTest extends ProductTestBase { - - @Rule - public static TestName name = new TestName(); - - public ProductToscaYamlGenerationTest() { - super(name, ProductToscaYamlGenerationTest.class.getName()); - } - - @Test - public void productToscaYamlFormat() throws IOException { - - String heatEnvArtifactHeader = (String) Utils.parseYamlConfig("heatEnvArtifactHeader"); - // System.out.println("heatEnvArtifactHeader = \n" + - // heatEnvArtifactHeader); - - String heatEnvArtifactFooter = (String) Utils.parseYamlConfig("heatEnvArtifactFooter"); - // System.out.println("heatEnvArtifactFooter = \n" + - // heatEnvArtifactFooter); - - // temporary commented - // RestResponse downloadResourceInstanceHeatArtifact = - // ArtifactRestUtils.downloadResourceInstanceArtifact(service.getUniqueId(), - // resourceInstanceId, sdncUserDetails, - // heatArtifactDefinition.getUniqueId()); - // assertTrue("expected request returned status:" + 200 + ", actual: " + - // downloadResourceInstanceHeatArtifact.getErrorCode(), - // downloadResourceInstanceHeatArtifact.getErrorCode()==200); - - // InputStream stream = - // getDecodedSteramFromString(downloadResourceInstanceHeatArtifact.getResponse()); - // System.out.println(Utils.getParamValueFromYamlByKey(stream, - // "description", String.class)); - - // node_types - - } - - private InputStream getDecodedSteramFromString(String encoded64Payload) throws IOException { - - Gson gson = new Gson(); - ArtifactUiDownloadData artifactUiDownloadData = gson.fromJson(encoded64Payload, ArtifactUiDownloadData.class); - String decodedPayload = Decoder.decode(artifactUiDownloadData.getBase64Contents()); - return new ByteArrayInputStream(decodedPayload.getBytes()); - - } - -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java deleted file mode 100644 index d4bfb62377..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.execute.product; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNull; - -import java.io.FileNotFoundException; - -import org.junit.Rule; -import org.junit.rules.TestName; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.general.Convertor; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; -import org.openecomp.sdc.common.api.Constants; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class ProductUndoCheckoutTest extends ProductLifecycleTest { - - @Rule - public static TestName name = new TestName(); - - @BeforeClass - public static void staticInit() { - auditAction = UNDO_CHECKOUT_ACTION; - operation = ComponentOperationEnum.CHANGE_STATE_UNDO_CHECKOUT; - } - - public ProductUndoCheckoutTest() { - super(name, ProductUndoCheckoutTest.class.getName()); - } - - @Test - public void undoCheckOutProductByPm() throws Exception { - undoCheckOutProductSuccess(productManager1, false); - } - - @Test - public void undoCheckOutProductByAdmin() throws Exception { - undoCheckOutProductSuccess(adminUser, true); - } - - @Test - public void undoCheckOutAfterCreate() throws Exception { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.UNDOCHECKOUT); - assertEquals("Check response code after undo checkout product", 200, lcsResponse.getErrorCode().intValue()); - - // Verify version was removed - lcsResponse = ProductRestUtils.getProduct(expectedProduct.getUniqueId(), productManager1.getUserId()); - assertEquals("Check response code after get undone product", 404, lcsResponse.getErrorCode().intValue()); - - Product emptyProduct = ResponseParser.parseToObjectUsingMapper(lcsResponse.getResponse(), Product.class); - assertNull(emptyProduct); - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(emptyProduct, - auditAction, productManager1, ActionStatus.OK, "0.1", Constants.EMPTY_STRING, - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null, Constants.EMPTY_STRING); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - - } - - @Test - public void undoCheckOutNotExist() throws Exception { - String notExistId = "1234"; - expectedProduct.setUniqueId(notExistId); - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.UNDOCHECKOUT); - assertEquals("Check response code after undo checkout product", 404, lcsResponse.getErrorCode().intValue()); - expectedProduct.setName(notExistId); - String[] auditParameters = new String[] { Constants.EMPTY_STRING }; - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, - auditAction, productManager1, ActionStatus.PRODUCT_NOT_FOUND, Constants.EMPTY_STRING, - Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING, auditParameters); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - - } - - @Test - public void undoCheckOutNotInCheckout() throws Exception { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin product", 200, lcsResponse.getErrorCode().intValue()); - - lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.UNDOCHECKOUT); - assertEquals("Check response code after undo checkout product", 409, lcsResponse.getErrorCode().intValue()); - - String[] auditParameters = new String[] { expectedProduct.getName(), "product", productManager1.getFirstName(), - productManager1.getLastName(), productManager1.getUserId() }; - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, - auditAction, productManager1, ActionStatus.COMPONENT_ALREADY_CHECKED_IN, "0.1", "0.1", - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, - expectedProduct.getUUID(), auditParameters); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - - } - - @Test - public void undoCheckOutProductByPsRoleNotAllowed() throws Exception { - undoCheckOutProductRestricted(productStrategistUser1); - } - - @Test - public void undoCheckOutProductByPmNotStateOwner() throws Exception { - undoCheckOutProductForbidden(productManager2); - } - - private void undoCheckOutProductSuccess(User user, boolean isAdmin) throws Exception, FileNotFoundException { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin product", 200, lcsResponse.getErrorCode().intValue()); - - // Checking undo checkout of admin even if not state owner - User checkoutUser = isAdmin ? productManager1 : user; - - lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, checkoutUser, - LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout product", 200, lcsResponse.getErrorCode().intValue()); - Product productToBeUndone = ResponseParser.parseToObjectUsingMapper(lcsResponse.getResponse(), Product.class); - - lcsResponse = LifecycleRestUtils.changeProductState(productToBeUndone, user, LifeCycleStatesEnum.UNDOCHECKOUT); - assertEquals("Check response code after undo checkout product", 200, lcsResponse.getErrorCode().intValue()); - - // Verify version was removed - lcsResponse = ProductRestUtils.getProduct(productToBeUndone.getUniqueId(), user.getUserId()); - assertEquals("Check response code after get undone product", 404, lcsResponse.getErrorCode().intValue()); - - lcsResponse = ProductRestUtils.getProduct(expectedProduct.getUniqueId(), user.getUserId()); - assertEquals("Check response code after get latest version", 200, lcsResponse.getErrorCode().intValue()); - - Product latestProduct = ResponseParser.parseToObjectUsingMapper(lcsResponse.getResponse(), Product.class); - - expectedProduct.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, latestProduct, operation); - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(latestProduct, - auditAction, user, ActionStatus.OK, "0.2", "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, latestProduct.getUUID()); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - - private void undoCheckOutProductRestricted(User undoCheckoutUser) throws Exception, FileNotFoundException { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin product", 200, lcsResponse.getErrorCode().intValue()); - - lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout product", 200, lcsResponse.getErrorCode().intValue()); - Product productToBeUndone = ResponseParser.parseToObjectUsingMapper(lcsResponse.getResponse(), Product.class); - - lcsResponse = LifecycleRestUtils.changeProductState(productToBeUndone, undoCheckoutUser, - LifeCycleStatesEnum.UNDOCHECKOUT); - assertEquals("Check response code after undocheckout product", 409, lcsResponse.getErrorCode().intValue()); - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(productToBeUndone, - auditAction, undoCheckoutUser, ActionStatus.RESTRICTED_OPERATION, "0.2", "0.2", - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - productToBeUndone.getUUID()); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - - private void undoCheckOutProductForbidden(User undoCheckoutUser) throws Exception, FileNotFoundException { - RestResponse lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkin product", 200, lcsResponse.getErrorCode().intValue()); - - lcsResponse = LifecycleRestUtils.changeProductState(expectedProduct, productManager1, - LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout product", 200, lcsResponse.getErrorCode().intValue()); - Product productToBeUndone = ResponseParser.parseToObjectUsingMapper(lcsResponse.getResponse(), Product.class); - - lcsResponse = LifecycleRestUtils.changeProductState(productToBeUndone, undoCheckoutUser, - LifeCycleStatesEnum.UNDOCHECKOUT); - assertEquals("Check response code after undocheckout product", 403, lcsResponse.getErrorCode().intValue()); - String[] auditParameters = new String[] { productToBeUndone.getName(), "product", - productManager1.getFirstName(), productManager1.getLastName(), productManager1.getUserId() }; - - ExpectedProductAudit expectedProductAudit = Convertor.constructFieldsForAuditValidation(expectedProduct, - auditAction, undoCheckoutUser, ActionStatus.COMPONENT_CHECKOUT_BY_ANOTHER_USER, "0.2", "0.2", - LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, - productToBeUndone.getUUID(), auditParameters); - AuditValidationUtils.validateAuditProduct(expectedProductAudit, auditAction); - } - -} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java index 6e4a6a8018..90371662a7 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java @@ -24,16 +24,22 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; import org.apache.http.client.ClientProtocolException; import org.json.JSONException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; @@ -62,6 +68,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ResourceRestUtils extends BaseRestUtils { + + private static final String CSARS_PATH = "/src/test/resources/CI/csars/"; private static Logger logger = LoggerFactory.getLogger(ResourceRestUtils.class.getName()); // ****** CREATE ******* @@ -384,6 +392,16 @@ public class ResourceRestUtils extends BaseRestUtils { return http.httpSendGet(url, headersMap); } + + public static RestResponse getResourceFilteredDataByParams(User sdncModifierDetails, String uniqueId , List<String> parameters) throws IOException { + Config config = Utils.getConfig(); + String urlGetResourceDataByParams = Urls.GET_RESOURCE_DATA_BY_PARAMS; + String joinedParameters = StringUtils.join(parameters , "&"); + String url = String.format(urlGetResourceDataByParams + joinedParameters , config.getCatalogBeHost(), config.getCatalogBePort(), uniqueId); + return sendGet(url, sdncModifierDetails.getUserId()); + + } + public static RestResponse sendOptionsTowardsCatalogFeWithUuid() throws IOException { @@ -661,5 +679,33 @@ public class ResourceRestUtils extends BaseRestUtils { return ProductRestUtils.changeServiceInstanceVersion(containerUniqueId, instanceToReplaceUniqueId, newResourceUniqueId, sdncModifierDetails, componentType); } + + public static Resource importResourceFromCsar(String csarName) throws Exception{ + User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + String payloadName = csarName; + ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource(); + String rootPath = System.getProperty("user.dir"); + Path path = null; + byte[] data = null; + + String payloadData = null; + + path = Paths.get(rootPath + CSARS_PATH + csarName); + data = Files.readAllBytes(path); + payloadData = Base64.encodeBase64String(data); + resourceDetails.setPayloadData(payloadData); + + // create new resource from Csar + resourceDetails.setCsarUUID(payloadName); + resourceDetails.setPayloadName(payloadName); + resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); + RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails); + BaseRestUtils.checkCreateResponse(createResource); + Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + return resource; + + // add to restResourceUtil + } + } |