diff options
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute')
74 files changed, 8093 insertions, 8488 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java index 3af40c5bb8..fc0e33d3a8 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java @@ -20,9 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.TODO; -import java.io.File; -import java.io.IOException; - +import fj.data.Either; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -39,7 +37,8 @@ import org.testng.AssertJUnit; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import fj.data.Either; +import java.io.File; +import java.io.IOException; public class ImportCapabilityTypeCITest { public static final DbUtils DbUtils = new DbUtils(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java index 66e450b077..c735169e77 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java @@ -20,11 +20,9 @@ package org.openecomp.sdc.ci.tests.execute.artifacts; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; - +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import fj.data.Either; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpResponseException; @@ -37,7 +35,6 @@ import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -46,11 +43,7 @@ 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.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactUiDownloadData; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; @@ -63,11 +56,7 @@ 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.AtomicOperationUtils; 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.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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.util.GeneralUtility; @@ -77,10 +66,10 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; - -import fj.data.Either; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; public class ArtifactServletTest extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java index ff99a6bb10..5072f58112 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java @@ -20,30 +20,12 @@ package org.openecomp.sdc.ci.tests.execute.artifacts; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - import org.apache.commons.lang3.tuple.Pair; 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.ArtifactDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; @@ -56,12 +38,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.general.FileUtils; -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.LifecycleRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ArtifactValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; @@ -72,6 +49,16 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import static org.testng.AssertJUnit.*; + public class CrudArt extends ComponentBaseTest { private static Logger logger = LoggerFactory.getLogger(CrudArt.class.getName()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java index fb620c9b82..02bf110c8d 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java @@ -20,12 +20,11 @@ package org.openecomp.sdc.ci.tests.execute.artifacts; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; - +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import fj.data.Either; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -39,7 +38,6 @@ import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; @@ -47,26 +45,14 @@ 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.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactUiDownloadData; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; 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.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; @@ -91,12 +77,11 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import fj.data.Either; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; public class DownloadComponentArt extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java index bc57512a11..80e0a54ee4 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java @@ -20,42 +20,32 @@ package org.openecomp.sdc.ci.tests.execute.artifacts; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.List; -import java.util.Map; - import org.apache.commons.codec.binary.Base64; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactUiDownloadData; -import org.openecomp.sdc.be.model.ComponentInstance; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceInstantiationType; 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.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.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.rest.*; import org.testng.annotations.Test; import org.yaml.snakeyaml.Yaml; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + public class HeatEnvArtifact extends ComponentBaseTest { @Rule @@ -78,7 +68,9 @@ public class HeatEnvArtifact extends ComponentBaseTest { Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(certifyState.getResponse(), Resource.class); - ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId()); + ServiceReqDetails serviceDetails = ElementFactory.getDefaultService( + "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(), + ServiceInstantiationType.A_LA_CARTE.getValue()); // 2 create service RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails); @@ -128,7 +120,9 @@ public class HeatEnvArtifact extends ComponentBaseTest { Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(certifyState.getResponse(), Resource.class); - ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId()); + ServiceReqDetails serviceDetails = ElementFactory.getDefaultService( + "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(), + ServiceInstantiationType.A_LA_CARTE.getValue()); // 2 create service RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java index 02bef89f2c..b15da07139 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java @@ -21,61 +21,38 @@ package org.openecomp.sdc.ci.tests.execute.artifacts; //import static org.junit.Assert.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.javatuples.Pair; +import fj.data.Either; 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.ArtifactDefinition; -import org.openecomp.sdc.be.model.Component; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; 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.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; -import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.general.FileUtils; -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.LifecycleRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.datastax.driver.core.Row; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; -import fj.data.Either; +import static org.testng.AssertJUnit.*; public class PlaceHolderValidations extends ComponentBaseTest { private static Logger logger = LoggerFactory.getLogger(PlaceHolderValidations.class.getName()); @@ -140,7 +117,7 @@ public class PlaceHolderValidations extends ComponentBaseTest { } } - private void validateToscaArtifactsBeforeAndAfterSFT(ResourceReqDetails resourceDetails) + /*private void validateToscaArtifactsBeforeAndAfterSFT(ResourceReqDetails resourceDetails) throws IOException, Exception { RestResponse componentResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails1); Component component = ResponseParser.convertResourceResponseToJavaObject(componentResponse.getResponse()); @@ -161,15 +138,15 @@ public class PlaceHolderValidations extends ComponentBaseTest { List<Row> fetchFromTable = CassandraUtils.fetchFromTableQuery("sdcartifact", "resources", fields); assertTrue(1 == fetchFromTable.size()); } - } + }*/ - @Test + /*@Test public void validateToscaArtifactsBeforeAndAfterSFT() throws IOException, Exception { // TODO ADD VF and Service validateToscaArtifactsBeforeAndAfterSFT(resourceDetails1); validateToscaArtifactsBeforeAndAfterSFT(resourceCP); validateToscaArtifactsBeforeAndAfterSFT(resourceVL); - } + }*/ @Test public void validateToscaPlaceHoldersByConfig() throws IOException, Exception { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java index c049211e97..be9b8b8135 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java @@ -20,13 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.artifacts; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition; @@ -53,6 +46,13 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.yaml.snakeyaml.Yaml; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class ValidateArtResponse extends ComponentBaseTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java index 8a7a2f65fa..09c4d387a2 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java @@ -20,9 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.artifacts; -import java.util.Arrays; -import java.util.List; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -46,6 +43,9 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.AssertJUnit; import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.List; + public class ValidateHeatArtFieldsTypes extends ComponentBaseTest { protected User sdncDesignerDetails; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java index 537a70984e..0033e37932 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java @@ -20,12 +20,8 @@ package org.openecomp.sdc.ci.tests.execute.attribute; -import static org.junit.Assert.assertEquals; -import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException; - -import java.io.File; -import java.util.function.Function; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; @@ -41,8 +37,11 @@ import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; import org.testng.annotations.Test; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import java.io.File; +import java.util.function.Function; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException; public class ComponentInstanceAttributeTest extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java index 61c9442f44..0385bbc23f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java @@ -20,10 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.category; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - +import com.google.gson.Gson; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; @@ -35,10 +32,7 @@ import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; @@ -53,7 +47,9 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; public class CatalogDataApiTest extends ComponentBaseTest { @@ -201,9 +197,10 @@ public class CatalogDataApiTest extends ComponentBaseTest { String vendorRelease = "0.1"; String contactId = "al1976"; String icon = "myIcon"; + String instantiationType = ServiceInstantiationType.A_LA_CARTE.getValue(); ServiceReqDetails svcdetails = new ServiceReqDetails(serviceName, category, serviceTags, description, - contactId, icon); + contactId, icon, instantiationType); return svcdetails; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java index ade662a20c..ed41149f21 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java @@ -20,25 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.category; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE; -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_CREATED; -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_RESTRICTED_OPERATION; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.commons.lang3.text.WordUtils; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; @@ -64,6 +45,13 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.File; +import java.util.*; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + public class CategoriesTests extends CategoriesBaseTest { private static final String GET_CATEGORY_HIERARCHY = "GetCategoryHierarchy"; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java index ec36798bc1..3d2b3a06cf 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java @@ -20,12 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.category; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.util.HashMap; -import java.util.Map; - import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; @@ -38,6 +32,12 @@ import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.testng.annotations.Test; +import java.util.HashMap; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + public class ElementsApiTest extends ComponentBaseTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java index 7858b3259f..b0e7bd3eff 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java @@ -20,18 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.category; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE; -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_CREATED; -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; -import static org.testng.AssertJUnit.assertEquals; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -54,6 +42,9 @@ import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*; +import static org.testng.AssertJUnit.assertEquals; + public class GroupingTest extends CategoriesBaseTest { protected static final String ADD_GROUPING = "AddGrouping"; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java index dd96ebfc2f..eada2b43b1 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java @@ -20,21 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.category; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE; -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_CREATED; -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; -import static org.testng.AssertJUnit.assertEquals; - -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; @@ -56,6 +41,12 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*; +import static org.testng.AssertJUnit.assertEquals; + public class SubCategoriesTest extends ComponentBaseTest { protected static final String ADD_SUB_CATEGORY = "AddSubCategory"; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java index 586856bd72..ab6551f49e 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java @@ -20,12 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.devCI; -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; @@ -34,6 +28,12 @@ import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinitio import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + public class AndreyTest { private static ToscaDefinition parseToscaYamlToJavaObject; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java index 4cb46a3810..7a69d374eb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java @@ -20,6 +20,14 @@ package org.openecomp.sdc.ci.tests.execute.devCI; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition; +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; +import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition; +import org.openecomp.sdc.ci.tests.utils.CsarParserUtils; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -28,25 +36,11 @@ import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition; -import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; -import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition; -import org.openecomp.sdc.ci.tests.utils.CsarParserUtils; - public class ArtifactFromCsar { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java index 99890c1105..9e77526654 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java @@ -226,7 +226,7 @@ public class ImportCsarUpdate extends ComponentBaseTest { } - @Test + /*@Test public void updateVFsearchByCsarStartCertifaicationState() throws Exception { ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); @@ -256,7 +256,7 @@ public class ImportCsarUpdate extends ComponentBaseTest { resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups()); - } + }*/ @Test public void updateVFsearchBySystemNameCheckInState() throws Exception { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java index 49e5950db5..802de24d4f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java @@ -20,8 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.devCI; -import static org.testng.AssertJUnit.assertTrue; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; @@ -38,6 +36,8 @@ import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import static org.testng.AssertJUnit.assertTrue; + public class ImportCsarValidateArtifacts extends ComponentBaseTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java index 7acf1206e7..49b13b587b 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java @@ -20,10 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.devCI; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - +import fj.data.Either; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; @@ -32,13 +29,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.DistributionNotificationStatusEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; @@ -46,7 +37,9 @@ import org.openecomp.sdc.ci.tests.utils.validation.DistributionValidationUtils; import org.openecomp.sdc.externalApis.CRUDExternalAPI; import org.testng.annotations.Test; -import fj.data.Either; +import java.util.Arrays; +import java.util.List; +import java.util.Map; public class test1 extends ComponentBaseTest{ diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java index b4a9bb87ce..7f97ca36be 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java @@ -20,13 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.distribution; -import static org.testng.AssertJUnit.assertEquals; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition; @@ -54,6 +47,13 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; + public class AuthanticationTests extends ComponentBaseTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java index e2a9207718..94715b2495 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java @@ -20,16 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.distribution; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.zip.ZipInputStream; - import org.apache.commons.codec.binary.Base64; import org.junit.Rule; import org.junit.rules.TestName; @@ -53,12 +43,7 @@ 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.Utils; 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.ConsumerRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.util.GeneralUtility; @@ -67,6 +52,16 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipInputStream; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + public class DistributionDownloadArtifactTest extends ComponentBaseTest { protected static ResourceReqDetails resourceDetails; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java index 80b70d675e..e49c912ef4 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java @@ -20,62 +20,35 @@ package org.openecomp.sdc.ci.tests.execute.externalapi; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; import org.apache.commons.codec.binary.Base64; import org.junit.Rule; 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.ArtifactDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; -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.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; 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.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; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.*; public class DownloadArtifactsTest extends ComponentBaseTest { @Rule @@ -127,9 +100,11 @@ public class DownloadArtifactsTest extends ComponentBaseTest { ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.CP.toString()); serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY, - sdncDesignerDetails.getUserId()); + sdncDesignerDetails.getUserId(), + ServiceInstantiationType.A_LA_CARTE.getValue()); serviceDetails_02 = ElementFactory.getDefaultService("newtestservice2", ServiceCategoriesEnum.MOBILITY, - sdncDesignerDetails.getUserId()); + sdncDesignerDetails.getUserId(), + ServiceInstantiationType.A_LA_CARTE.getValue()); } @Test diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java index c3371493d9..404ed04766 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java @@ -21,15 +21,6 @@ //US505653 package org.openecomp.sdc.ci.tests.execute.general; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; - -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.junit.Rule; import org.junit.rules.TestName; @@ -54,11 +45,7 @@ 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.AtomicOperationUtils; 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.ConsumerRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.util.ValidationUtils; @@ -67,6 +54,13 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.*; + public class BasicHttpAuthenticationTest extends ComponentBaseTest { protected static final String AUTH_FAILED_INVALID_AUTHENTICATION_HEADER = "AUTH_FAILED_INVALID_AUTHENTICATION_HEADER"; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java index eea4e8ad5a..0934ebb4c2 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java @@ -20,10 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.general; -import static org.testng.AssertJUnit.assertEquals; - -import java.util.HashMap; - +import com.google.gson.Gson; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -43,7 +40,9 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.util.HashMap; + +import static org.testng.AssertJUnit.assertEquals; public class ManageEcompConsumerCredentials extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java index acb7e15c6c..e460614d8c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java @@ -20,13 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.general; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.List; -import java.util.UUID; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; @@ -38,6 +31,13 @@ import org.openecomp.sdc.common.api.Constants; import org.testng.AssertJUnit; import org.testng.annotations.Test; +import java.io.IOException; +import java.util.List; +import java.util.UUID; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + public class UuidTest extends ComponentBaseTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/groups/GroupsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/groups/GroupsTest.java new file mode 100644 index 0000000000..4a2f98e588 --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/groups/GroupsTest.java @@ -0,0 +1,164 @@ +package org.openecomp.sdc.ci.tests.execute.groups; + +import fj.data.Either; +import org.apache.commons.collections.MapUtils; +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.*; +import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest; +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.ComponentInstanceRestUtils; +import org.testng.annotations.Test; +import org.testng.collections.Lists; + +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import static org.junit.Assert.*; +import static org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils.*; +import static org.testng.Assert.assertNull; + +public class GroupsTest extends ComponentBaseTest { + @Rule + public static TestName name = new TestName(); + + public static final String groupName = "x_group"; + public static final String capabilityName = "vlan_assignment"; + public static final String propertyName = "vfc_instance_group_reference"; + public static final String csarsFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ; + + public GroupsTest() { + super(name, GroupsTest.class.getName()); + } + + @Test + public void importResourceWithGroupsTest() throws Exception { + importResource("with_groups.csar"); + } + + @Test + public void importResourceWitIncorrectCapabilityNameTest() throws Exception { + RestResponse createResource = getCreateResourceRestResponse(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, "incorrect_cap.csar", csarsFilePath); + BaseRestUtils.checkErrorResponse(createResource, ActionStatus.MISSING_CAPABILITIES,(Lists.newArrayList("vlan_assignment1")).toString(), "group", "x_group"); + } + + @Test + public void importResourceWithoutCapabilitiesTest() throws Exception { + Resource resource = importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, "without_caps.csar", csarsFilePath); + validateComponentGroupCapabilityPropertyValue(resource, null); + } + + @Test + public void updateResourceWithGroupsTest() throws Exception { + Resource resource = importResource("with_groups.csar"); + updateResource(resource, "with_groups_update.csar"); + } + + @Test + public void supportGroupsWithCapabilitiesServiceLevelTest() throws Exception { + Resource resource = importCertifiedResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, "VLANTaggingFromAmdox1303_2018.csar", csarsFilePath); + CapReqDef caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(resource, UserRoleEnum.DESIGNER.getUserId()); + validateVlanAssignmentGroupCapabilitiesInvisible(caps.getCapabilities()); + + Service service1 = createCertifiedServiceWithInstance(ServiceCategoriesEnum.MOBILITY, resource); + caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(service1, UserRoleEnum.DESIGNER.getUserId()); + validateVlanAssignmentGroupCapabilitiesVisible(caps.getCapabilities()); + + Service service2 = createCertifiedServiceWithInstance(ServiceCategoriesEnum.NETWORK_L4, resource); + caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(service2, UserRoleEnum.DESIGNER.getUserId()); + validateVlanAssignmentGroupCapabilitiesVisible(caps.getCapabilities()); + + Service serviceContainer = createCertifiedServiceWithProxyInstances(ServiceCategoriesEnum.NETWORK_L3, service1, service2); + caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(serviceContainer, UserRoleEnum.DESIGNER.getUserId()); + validateVlanAssignmentGroupCapabilitiesVisible(caps.getCapabilities()); + + assertTrue(serviceContainer.getComponentInstances()!=null); + } + + private void validateVlanAssignmentGroupCapabilitiesVisible(Map<String, List<CapabilityDefinition>> capabilities) { + if(MapUtils.isNotEmpty(capabilities)){ + validateVlanAssignmentGroupCapabilitiesVisibility(capabilities, true); + } + } + + private void validateVlanAssignmentGroupCapabilitiesInvisible(Map<String, List<CapabilityDefinition>> capabilities) { + if(MapUtils.isNotEmpty(capabilities)){ + validateVlanAssignmentGroupCapabilitiesVisibility(capabilities, false); + } + } + private void validateVlanAssignmentGroupCapabilitiesVisibility(Map<String, List<CapabilityDefinition>> capabilities, boolean shouldBeVisible) { + assertTrue(capabilities.containsKey("org.openecomp.capabilities.VLANAssignment") == shouldBeVisible); + } + + private Service createCertifiedServiceWithProxyInstances(ServiceCategoriesEnum category, Service service1, Service service2) throws Exception { + Either<Service, RestResponse> createServiceRes = createServiceByCategory(category, UserRoleEnum.DESIGNER, true); + assertTrue(createServiceRes.isLeft()); + Either<ComponentInstance, RestResponse> result = addComponentInstanceToComponentContainer(service1, createServiceRes.left().value()); + assertTrue(result.isLeft()); + result = addComponentInstanceToComponentContainer(service2, createServiceRes.left().value()); + assertTrue(result.isLeft()); + return certifyService(createServiceRes); + } + + private Service createCertifiedServiceWithInstance(ServiceCategoriesEnum category, Resource resource) throws Exception { + Either<Service, RestResponse> createServiceRes = createServiceByCategory(category, UserRoleEnum.DESIGNER, true); + assertTrue(createServiceRes.isLeft()); + Either<ComponentInstance, RestResponse> result = addComponentInstanceToComponentContainer(resource, createServiceRes.left().value()); + assertTrue(result.isLeft()); + return certifyService(createServiceRes); + } + + private Service certifyService(Either<Service, RestResponse> serviceProxy1) throws Exception { + Service service = getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceProxy1.left().value().getName(), "0.1" ); + assertNotNull(service); + ServiceReqDetails serviceReqDetails = new ServiceReqDetails(service); + RestResponse restResponseService = LCSbaseTest.certifyService(serviceReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); + assertTrue(restResponseService.getErrorCode()==200); + return getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceProxy1.left().value().getName(), "1.0" ); + } + + private static Resource updateResource(Resource resource, String csarFileName) throws Exception { + Resource updatedResource = updateResourceFromCsar(resource, UserRoleEnum.DESIGNER, csarFileName, csarsFilePath); + validateComponentGroupCapabilityPropertyValue(updatedResource, "new_value"); + return updatedResource; + } + + private static Resource importResource(String csarFileName) throws Exception { + Resource resource = importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, csarFileName, csarsFilePath); + validateComponentGroupCapabilityPropertyValue(resource, "success"); + return resource; + } + + private static void validateComponentGroupCapabilityPropertyValue(Component component, String propertyValue) { + assertNotNull(component); + assertNotNull(component.getGroups()); + assertFalse(component.getGroups().isEmpty()); + assertTrue(component.getGroups().size() == 5); + Optional<GroupDefinition> vfcInstanceGroup = component.getGroups().stream().filter(g->g.getName().equals(groupName)).findFirst(); + assertTrue(vfcInstanceGroup.isPresent()); + assertFalse(vfcInstanceGroup.get().getCapabilities().isEmpty()); + assertTrue(vfcInstanceGroup.get().getCapabilities().size() == 1); + assertNotNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment")); + assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").size() == 1); + assertNotNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0)); + assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getName().equals(capabilityName)); + assertNotNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties()); + assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().size() == 1); + assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().get(0).getName().equals(propertyName)); + if(propertyValue == null) + assertNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().get(0).getValue()); + else + assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().get(0).getValue().equals(propertyValue)); + } + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java index 6b351c12d0..56502757de 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java @@ -20,28 +20,12 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - import org.apache.commons.codec.binary.Base64; import org.junit.Rule; 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.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactUiDownloadData; -import org.openecomp.sdc.be.model.Component; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; @@ -56,6 +40,15 @@ import org.openecomp.sdc.common.util.YamlToObjectConverter; import org.testng.annotations.Test; import org.yaml.snakeyaml.Yaml; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import static org.junit.Assert.*; + public class CsarUtilsTest extends ComponentBaseTest { public static final String ASSET_TOSCA_TEMPLATE = "assettoscatemplate"; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java index a6088deac0..3f017f448c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java @@ -20,70 +20,40 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -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 java.util.Map.Entry; -import java.util.Optional; -import java.util.stream.Collectors; - +import com.google.gson.Gson; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; import org.apache.commons.codec.binary.Base64; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactUiDownloadData; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstInputsMap; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.ComponentInstanceInput; -import org.openecomp.sdc.be.model.ComponentInstancePropInput; -import org.openecomp.sdc.be.model.ComponentInstanceProperty; -import org.openecomp.sdc.be.model.GroupDefinition; -import org.openecomp.sdc.be.model.InputDefinition; -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.be.model.*; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; 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.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; 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.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.InputsRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils; import org.openecomp.sdc.common.api.Constants; import org.testng.annotations.Test; import org.yaml.snakeyaml.Yaml; -import com.google.gson.Gson; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +import static org.junit.Assert.*; public class ExportToscaTest extends ComponentBaseTest { @Rule @@ -283,7 +253,9 @@ public class ExportToscaTest extends ComponentBaseTest { Resource createdResource = createVfFromCSAR(sdncModifierDetails, "csar_1"); RestResponse checkinState = LifecycleRestUtils.changeComponentState(createdResource, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN); BaseRestUtils.checkSuccess(checkinState); - ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId()); + ServiceReqDetails serviceDetails = ElementFactory.getDefaultService( + "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(), + ServiceInstantiationType.A_LA_CARTE.getValue()); //2 create service RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails); @@ -377,7 +349,6 @@ public class ExportToscaTest extends ComponentBaseTest { } - // ---------------------------------------- private void validateInput(InputDefinition inputDef, Map<String, Object> inputInFile) { assertEquals("validate input type", inputDef.getType(), (String) inputInFile.get("type")); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java index 8ea66700cf..eed10581e2 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java @@ -20,23 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - +import com.google.gson.Gson; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.WordUtils; import org.junit.Rule; @@ -44,46 +28,34 @@ import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.GroupDefinition; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.*; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceInstantiationType; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; 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.GroupRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.util.ValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; + +import static org.testng.AssertJUnit.*; public class ImportCsarResourceTest extends ComponentBaseTest { private static Logger log = LoggerFactory.getLogger(ImportCsarResourceTest.class.getName()); @@ -558,10 +530,10 @@ public class ImportCsarResourceTest extends ComponentBaseTest { LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN); LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); - lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST); +/* lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST); LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.STARTCERTIFICATION); - LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); + LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);*/ lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.CERTIFY); LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKOUT); @@ -1554,10 +1526,10 @@ public class ImportCsarResourceTest extends ComponentBaseTest { LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN); LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); - lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST); +/* lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST); LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.STARTCERTIFICATION); - LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); + LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);*/ lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.CERTIFY); LifecycleRestUtils.checkSuccess(lifecycleChangeResponse); Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(lifecycleChangeResponse.getResponse(), Resource.class); @@ -1566,7 +1538,9 @@ public class ImportCsarResourceTest extends ComponentBaseTest { User modifier = new User(); modifier.setUserId(designerUserId); - ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY, designerUserId); + ServiceReqDetails serviceDetails = ElementFactory.getDefaultService( + "newtestservice1", ServiceCategoriesEnum.MOBILITY, designerUserId, + ServiceInstantiationType.A_LA_CARTE.getValue()); RestResponse serviceRes = ServiceRestUtils.createService(serviceDetails, modifier); ResourceRestUtils.checkCreateResponse(serviceRes); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java index 873d33979f..f10aa5da3c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java @@ -20,22 +20,8 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - +import com.google.gson.Gson; +import fj.data.Either; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -53,11 +39,7 @@ import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.ImportTestTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.RespJsonKeysEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.TODO.ImportCapabilityTypeCITest; @@ -74,9 +56,14 @@ import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.io.File; +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.util.*; +import java.util.Map.Entry; -import fj.data.Either; +import static org.testng.AssertJUnit.*; public class ImportGenericResourceCITest extends ComponentBaseTest { private static Logger log = LoggerFactory.getLogger(ImportGenericResourceCITest.class.getName()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java index 61c846242c..f529f00cf9 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java @@ -20,18 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpStatus; import org.junit.Rule; @@ -46,12 +35,7 @@ import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.ImportTestTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; @@ -70,1455 +54,1458 @@ import org.openecomp.sdc.common.util.GeneralUtility; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.io.IOException; +import java.util.*; + +import static org.testng.AssertJUnit.*; public class ImportNewResourceCITest extends ComponentBaseTest { - // public static UserUtils userUtils = new UserUtils(); - // public ResourceUtils resourceUtils = new ResourceUtils(); - // public AuditValidationUtils AuditValidationUtils = new - // AuditValidationUtils(); - // protected ArtifactUtils artifactUtils = new ArtifactUtils(); - - protected String resourceVersion = null; - protected String auditAction = null; - public User sdncModifierDetails = new User(); - protected String artifactName1 = "data_artifact1.sh"; - protected String artifactName2 = "data_artifact2.sh"; - protected String interfaze = "standard"; - protected String interfaceArtifactName = "data_interface1.sh"; - - private String SPECIAL_CHARACTERS = "~!#@~$%^*()[];:'\"|\\/"; - - public ResourceReqDetails resourceDetails = new ResourceReqDetails(); - - public Gson gson = new Gson(); - - @Rule - public static TestName name = new TestName(); - - public ImportNewResourceCITest() { - super(name, ImportNewResourceCITest.class.getName()); - } - - @BeforeMethod - public void before() throws Exception { - - // init user - sdncModifierDetails.setUserId(UserRoleEnum.ADMIN.getUserId()); - // init resource details - resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003"); - } - - @Test - public void importAllTestResources_toValidateNewAPI() throws Exception { - - for (ImportTestTypesEnum currResource : ImportTestTypesEnum.values()) { - // clean audit - DbUtils.cleanAllAudits(); - - // import testResources trough newResource API - RestResponse importResponse = ImportRestUtils.importNewResourceByName(currResource.getFolderName(), - UserRoleEnum.ADMIN); - System.err.println("import Resource " + "<" + currResource.getFolderName() + ">" + "response: " - + importResponse.getErrorCode()); - - // validate response - ImportRestUtils.validateImportTestTypesResp(currResource, importResponse); - if (currResource.getvalidateAudit() == true) { - // validate audit - // String baseVersion="0.1"; - String baseVersion = ""; - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(currResource.getActionStatus().name()); - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject(); - String auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId()); - expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName()); - expectedResourceAuditJavaObject.setResourceName(currResource.getNormativeName()); - expectedResourceAuditJavaObject.setResourceType("Resource"); - expectedResourceAuditJavaObject.setPrevVersion(""); - expectedResourceAuditJavaObject.setCurrVersion(baseVersion); - expectedResourceAuditJavaObject.setPrevState(""); - // expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); - expectedResourceAuditJavaObject.setCurrState(""); - expectedResourceAuditJavaObject.setComment(null); - expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); - List<String> variables = (currResource.getErrorParams() != null ? currResource.getErrorParams() - : new ArrayList<String>()); - String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); - expectedResourceAuditJavaObject.setDesc(auditDesc); - AuditValidationUtils.validateAuditImport(expectedResourceAuditJavaObject, auditAction); - } - } - } - - protected RestResponse importNewResource(UserRoleEnum userRoleEnum) throws Exception { - - // init user - sdncModifierDetails.setUserId(userRoleEnum.getUserId()); - // init resource details - resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003"); - // clean ES DB - DbUtils.cleanAllAudits(); - // import new resource (expected checkOut state) - RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test", userRoleEnum); - return importResponse; - } - - @Test(enabled = false) - public void importUIResource() throws IOException { - String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" - + " org.openecomp.resource.importResource4test:\r\n" + " derived_from: tosca.nodes.Root\r\n" - + " description: someDesc"; - - String encodedPayload = new String(Base64.encodeBase64(payload.getBytes())); - - String json = "{\r\n" + " \"resourceName\": \"importResource4test\",\r\n" - + " \"payloadName\": \"importResource4test.yml\",\r\n" - + " \"categories\": [{\"name\": \"Application L4+\",\"normalizedName\": \"application l4+\",\"uniqueId\": \"resourceNewCategory.application l4+\",\"subcategories\": [{\"name\": \"Web Server\"}]}],\r\n" - + " \"description\": \"ResourceDescription\",\r\n" + " \"vendorName\": \"VendorName\",\r\n" - + " \"vendorRelease\": \"VendorRelease\",\r\n" + " \"contactId\": \"AT1234\",\r\n" - + " \"icon\": \"router\",\r\n" + " \"tags\": [\r\n" + " \"importResource4test\"\r\n" + " ],\r\n" - + " \"payloadData\": \"" + encodedPayload + "\"\r\n" + "}"; - - String md5 = GeneralUtility.calculateMD5Base64EncodedByString(json); - - Map<String, String> headers = new HashMap<String, String>(); - headers.put(Constants.MD5_HEADER, md5); - headers.put(Constants.USER_ID_HEADER, UserRoleEnum.ADMIN.getUserId()); - headers.put(Constants.CONTENT_TYPE_HEADER, "application/json"); - - String url = String.format(Urls.CREATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort()); - - HttpRequest httpUtil = new HttpRequest(); - RestResponse httpSendPost = httpUtil.httpSendPost(url, json, headers); - Integer errorCode = httpSendPost.getErrorCode(); - assertTrue(errorCode == HttpStatus.SC_CREATED); - - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_suc() throws Exception { - - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - - // validate response - - resourceVersion = "0.1"; - - // ResourceRespJavaObject resourceRespJavaObject = - // Convertor.constructFieldsForRespValidation(resourceDetails, - // resourceVersion); - // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - // ResourceValidationUtils.validateResp(importResponse, - // resourceRespJavaObject); - // - // //validate get response - // - // RestResponse resourceGetResponse = - // ResourceRestUtils.getResource(sdncModifierDetails, resourceVersion); - // ResourceValidationUtils.validateResp(resourceGetResponse, - // resourceRespJavaObject); - Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - assertNotNull(resourceFromImport); - - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); - resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - - // validate get response - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceRespJavaObject.getUniqueId()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // validate - ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); - - // validate audit - resourceDetails.setVersion(resourceDetails.getVersion()); - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails, resourceVersion); - - auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setPrevState(""); - expectedResourceAuditJavaObject.setPrevVersion(""); - expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setStatus("201"); - expectedResourceAuditJavaObject.setDesc("OK"); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - - } - - @Test - public void importNewResource_byTester_failed() throws Exception { - - RestResponse importResponse = importNewResource(UserRoleEnum.TESTER); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 409, importResponse.getErrorCode().intValue()); - - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_existInCheckout_updateVendorName_updateCategory() throws Exception { - - // import new resource - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in other state - importResponse = ImportRestUtils.importNewResourceByName("importResource4testUpdateVendorNameAndCategory", - UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); - - // validate response - Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - assertNotNull(resourceFromImport); - - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); - resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - - // validate get response - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceRespJavaObject.getUniqueId()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // validate - ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); - - // validate audit - resourceDetails.setVersion(resourceDetails.getVersion()); - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails); - - auditAction = "ResourceImport"; - resourceVersion = "0.1"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - expectedResourceAuditJavaObject.setStatus("200"); - expectedResourceAuditJavaObject.setDesc("OK"); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - } - - @Test - public void importNewResource_perfromByAdmin_ownedBy_diffrentUser() throws Exception { - - RestResponse importResponse = importNewResource(UserRoleEnum.DESIGNER); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - - Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - // clean audit - DbUtils.cleanAllAudits(); - - importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - - ErrorInfo errorInfo = ErrorValidationUtils - .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name()); - assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode()); - - String[] split = resourceFromImport.getLastUpdaterFullName().split(" "); - String firstName = split[0]; - String lastName = split[1]; - List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName, - resourceFromImport.getLastUpdaterUserId()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables, - importResponse.getResponse()); - - } - - @Test - public void importNewResource_perfromByDesigner_ownedBy_diffrentUser() throws Exception { - - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - // clean audit - DbUtils.cleanAllAudits(); - - importResponse = importNewResource(UserRoleEnum.DESIGNER); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - - ErrorInfo errorInfo = ErrorValidationUtils - .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name()); - assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode()); - - String[] split = resourceFromImport.getLastUpdaterFullName().split(" "); - String firstName = split[0]; - String lastName = split[1]; - List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName, - resourceFromImport.getLastUpdaterUserId()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables, - importResponse.getResponse()); - - } - - @Test(enabled = false) - public void importNewResource_nameSpace_vf() throws Exception { - RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVF", - UserRoleEnum.DESIGNER); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - Resource resourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(importResponse.getResponse()); - assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VF)); - - } - - @Test - public void importNewResource_nameSpace_vfc() throws Exception { - RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVFC", - UserRoleEnum.DESIGNER); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - Resource resourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(importResponse.getResponse()); - assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC)); - } - - @Test - public void importNewResource_nameSpace_vl() throws Exception { - RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVL", - UserRoleEnum.DESIGNER); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - Resource resourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(importResponse.getResponse()); - assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VL)); - - } - - @Test - public void importNewResource_nameSpace_cp() throws Exception { - RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testCP", - UserRoleEnum.DESIGNER); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - - Resource resourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(importResponse.getResponse()); - assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.CP)); - } - - @Test - public void importNewResource_nameSpace_unknown() throws Exception { - RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test", - UserRoleEnum.DESIGNER); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - Resource resourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(importResponse.getResponse()); - assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC)); - - } - - @Test - public void importNewResource_MissingNameSpace() throws Exception { - RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testMissingNameSpace", - UserRoleEnum.DESIGNER); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 400, importResponse.getErrorCode().intValue()); - - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_existInCheckOut() throws Exception { - - // import new resource - - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in CHECKOUT state - - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); - - // validate response - Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - assertNotNull(resourceFromImport); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); - resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - - // validate get response - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceRespJavaObject.getUniqueId()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // validate - ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); - - // validate audit - resourceDetails.setVersion(resourceDetails.getVersion()); - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails); - - auditAction = "ResourceImport"; - resourceVersion = "0.1"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - expectedResourceAuditJavaObject.setStatus("200"); - expectedResourceAuditJavaObject.setDesc("OK"); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_existIn_CheckIn_state() throws Exception { - - // import new resource - - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - // checkIn resource - - resourceVersion = resourceDetails.getVersion(); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); - - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in CHECKIN state - - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); - - // validate response - Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - assertNotNull(resourceFromImport); - - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); - resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - - // validate get response - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceRespJavaObject.getUniqueId()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // validate - ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); - - // validate audit - resourceDetails.setVersion(resourceDetails.getVersion()); - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails); - - resourceVersion = "0.2"; - auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - expectedResourceAuditJavaObject.setStatus("200"); - expectedResourceAuditJavaObject.setDesc("OK"); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - } - - @Test - public void importNewResource_existIn_Ready4cert_state_performByTester() throws Exception { - // import new resource - - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceVersion = resourceDetails.getVersion(); - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - // add mandatory artifacts - // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // checkIn resource - resourceVersion = resourceDetails.getVersion(); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); - - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(checkInResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(checkInResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // req4cert resource - RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertNotNull("check response object is not null after resource request for certification", request4cert); - assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in CHECKIN state - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER); - - // validate response - resourceVersion = resourceDetails.getVersion(); - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); - assertNotNull("check response object is not null after create resouce", importResponse); - assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); - assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); - List<String> variables = Arrays.asList(); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, - importResponse.getResponse()); - - // validate audit - - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails, resourceVersion); - - String auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setResourceName(""); - expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId()); - expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName()); - expectedResourceAuditJavaObject.setPrevState(""); - expectedResourceAuditJavaObject.setCurrState(""); - expectedResourceAuditJavaObject.setPrevVersion(""); - expectedResourceAuditJavaObject.setCurrVersion(""); - expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); - String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); - expectedResourceAuditJavaObject.setDesc(auditDesc); - - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_existIn_Ready4cert_state_performByDesigner() throws Exception { - // import new resource - - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceVersion = resourceDetails.getVersion(); - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - // add mandatory artifacts - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // checkIn resource - resourceVersion = resourceDetails.getVersion(); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - // req4cert resource - RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertNotNull("check response object is not null after resource request for certification", request4cert); - assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in other state - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER); - - // validate response - ErrorInfo errorInfo = ErrorValidationUtils - .parseErrorConfigYaml(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name()); - assertNotNull("check response object is not null after create resouce", importResponse); - assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); - assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); - String[] split = resourceFromGet.getLastUpdaterFullName().split(" "); - String firstName = split[0]; - String lastName = split[1]; - List<String> variables = Arrays.asList(resourceFromGet.getName(), "resource", firstName, lastName, - resourceFromGet.getLastUpdaterUserId()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name(), variables, - importResponse.getResponse()); - - // validate audit - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails, resourceVersion); - String auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId()); - expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName()); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.READY_FOR_CERTIFICATION).toString()); - // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState(""); - expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - expectedResourceAuditJavaObject.setCurrVersion(""); - expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); - expectedResourceAuditJavaObject.setDesc(auditDesc); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_existIn_Ready4cert_state_performByAdmin() throws Exception { - - // import new resource - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceVersion = resourceDetails.getVersion(); - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // add mandatory artifacts - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // checkIn resource - resourceVersion = resourceDetails.getVersion(); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - // req4cert resource - RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertNotNull("check response object is not null after resource request for certification", request4cert); - assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in other state - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - resourceVersion = resourceDetails.getVersion(); - // resourceVersion="0.2"; - - // validate response - Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - assertNotNull(resourceFromImport); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); - resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - - // validate get response - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceRespJavaObject.getUniqueId()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // validate - ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); - - // validate audit - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails, resourceVersion); - auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - expectedResourceAuditJavaObject.setStatus("200"); - expectedResourceAuditJavaObject.setDesc("OK"); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - } - - @Test - public void importNewResource_existIn_CerInProgress_state_performByTester() throws Exception { - - // import new resource - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceVersion = resourceDetails.getVersion(); - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // add mandatory artifacts - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // checkIn resource - resourceVersion = resourceDetails.getVersion(); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - // req4cert resource - RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertNotNull("check response object is not null after resource request for certification", request4cert); - assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // startCert - RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertNotNull("check response object is not null after resource request start certification", startCert); - assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in other state - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER); - - // validate response - resourceVersion = resourceDetails.getVersion(); - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); - assertNotNull("check response object is not null after create resouce", importResponse); - assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); - assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); - List<String> variables = Arrays.asList(); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, - importResponse.getResponse()); - - // validate audit - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails, resourceVersion); - String auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setResourceName(""); - expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId()); - expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName()); - expectedResourceAuditJavaObject.setPrevState(""); - expectedResourceAuditJavaObject.setCurrState(""); - expectedResourceAuditJavaObject.setPrevVersion(""); - expectedResourceAuditJavaObject.setCurrVersion(""); - expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); - String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); - expectedResourceAuditJavaObject.setDesc(auditDesc); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_existIn_CerInProgress_state_performByDesigner() throws Exception { - - User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - // import new resource - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceVersion = resourceDetails.getVersion(); - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // add mandatory artifacts - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // checkIn resource - resourceVersion = resourceDetails.getVersion(); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - // req4cert resource - RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertNotNull("check response object is not null after resource request for certification", request4cert); - assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // startCert - RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertNotNull("check response object is not null after resource request start certification", startCert); - assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - resourceVersion = resourceDetails.getVersion(); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in other state - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER); - ErrorInfo errorInfo = ErrorValidationUtils - .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name()); - assertNotNull("check response object is not null after create resouce", importResponse); - assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); - assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); - List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(), - sdncAdminUser.getLastName(), sdncAdminUser.getUserId()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(), - variables, importResponse.getResponse()); - - // validate audit - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails, resourceVersion); - String auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId()); - expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName()); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString()); - // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState(""); - expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - expectedResourceAuditJavaObject.setCurrVersion(""); - expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); - expectedResourceAuditJavaObject.setDesc(auditDesc); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - - } - - // TODO DE171337 - @Test(enabled = false) - public void importNewResource_existIn_CerInProgress_state_performByAdmin() throws Exception { - - User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - - // import new resource - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceVersion = resourceDetails.getVersion(); - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - - // add mandatory artifacts - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // checkIn resource - resourceVersion = resourceDetails.getVersion(); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - // req4cert resource - RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertNotNull("check response object is not null after resource request for certification", request4cert); - assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - // startCert - RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertNotNull("check response object is not null after resource request start certification", startCert); - assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - resourceVersion = resourceDetails.getVersion(); - - // clean audit - DbUtils.cleanAllAudits(); - - // import new resource while resource already exist in other state - importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); - - // validate response - ErrorInfo errorInfo = ErrorValidationUtils - .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name()); - assertNotNull("check response object is not null after create resouce", importResponse); - assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); - assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); - List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(), - sdncAdminUser.getLastName(), sdncAdminUser.getUserId()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(), - variables, importResponse.getResponse()); - - // validate audit - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor - .constructFieldsForAuditValidation(resourceDetails, resourceVersion); - String auditAction = "ResourceImport"; - expectedResourceAuditJavaObject.setAction(auditAction); - expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId()); - expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName()); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString()); - // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState(""); - expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - expectedResourceAuditJavaObject.setCurrVersion(""); - expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); - expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); - expectedResourceAuditJavaObject.setDesc(auditDesc); - AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); - - } - - // TODO DE171337 - // @Test(enabled = false) - // public void - // importNewResource_existIn_Certified_state_chnage_reqAndCap_byDesigner() - // throws Exception{ - // - // // Andrey - set default artifact details - // ArtifactDefinition artifactDefinition = - // artifactUtils.constructDefaultArtifactInfo(); - // - // // import new resource - // RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - // assertNotNull("check response object is not null after import resource", - // importResponse); - // assertNotNull("check error code exists in response after import - // resource", importResponse.getErrorCode()); - // assertEquals("Check response code after import resource", 201, - // importResponse.getErrorCode().intValue()); - // String resourceId = - // ResponseParser.getUniqueIdFromResponse(importResponse); - // resourceDetails = - // ResponseParser.parseToObject(importResponse.getResponse(), - // ResourceReqDetails.class); - // resourceVersion = resourceDetails.getVersion(); - // RestResponse resourceGetResponse = - // ResourceRestUtils.getResource(sdncModifierDetails, - // resourceDetails.getUniqueId()); - // assertEquals("Check response code after get resource", 200, - // resourceGetResponse.getErrorCode().intValue()); - // Resource resourceFromGet = - // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - // assertNotNull(resourceFromGet); - // - // // add mandatory artifacts - // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - // resourceDetails.getUniqueId()); - // assertEquals("Check response code after get resource", 200, - // resourceGetResponse.getErrorCode().intValue()); - // resourceFromGet = - // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - // assertNotNull(resourceFromGet); - // resourceDetails = - // ResponseParser.parseToObject(importResponse.getResponse(), - // ResourceReqDetails.class); - // resourceDetails.setVersion(resourceFromGet.getVersion()); - // - // // add artifact - // artifactDefinition.setArtifactName(artifactName1); - // ArtifactRestUtils.addInformationalArtifactToResource(resourceDetails, - // sdncModifierDetails, resourceVersion , artifactDefinition); - // - // // add artifact - // artifactDefinition.setArtifactName(artifactName2); - // resourceUtils.add_artifact(resourceDetails, sdncModifierDetails, - // resourceVersion , artifactDefinition); - // - // // add interface - // artifactDefinition.setArtifactName(interfaceArtifactName); - // ResourceRestUtils.add_interface(resourceDetails, sdncModifierDetails, - // resourceVersion , artifactDefinition); - // - // //construct fields for validation - // resourceVersion="1.0"; - // - // ResourceRespJavaObject resourceRespJavaObject = - // Convertor.constructFieldsForRespValidation(resourceDetails, - // resourceVersion); - // ArrayList<String> artifacts = new ArrayList<String>(); - // - // artifacts.add(resourceId+":"+artifactName1); - // artifacts.add(resourceId+":"+artifactName2); - // resourceRespJavaObject.setArtifacts(artifacts); - // ArrayList<String> interfaces = new ArrayList<String>(); - // - // interfaces.add(interfaze); - // resourceRespJavaObject.setInterfaces(interfaces); - // - // // checkIn resource - // resourceVersion = resourceDetails.getVersion(); - // String checkinComment = "good checkin"; - // String checkinComentJson = "{\"userRemarks\": \""+checkinComment+"\"}"; - // RestResponse checkInResponse = - // LifecycleRestUtils.changeResourceState(resourceDetails, - // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CHECKIN, - // checkinComentJson); - // assertNotNull("check response object is not null after import resource", - // checkInResponse); - // assertEquals("Check response code after checkout resource", 200, - // checkInResponse.getErrorCode().intValue()); - // - // // req4cert resource - // RestResponse request4cert = - // LifecycleRestUtils.changeResourceState(resourceDetails, - // sdncModifierDetails, resourceVersion, - // LifeCycleStatesEnum.CERTIFICATIONREQUEST); - // assertNotNull("check response object is not null after resource request - // for certification", request4cert); - // assertEquals("Check response code after checkout resource", 200, - // request4cert.getErrorCode().intValue()); - // resourceFromGet = - // ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - // assertNotNull(resourceFromGet); - // resourceDetails = - // ResponseParser.parseToObject(request4cert.getResponse(), - // ResourceReqDetails.class); - // resourceDetails.setVersion(resourceFromGet.getVersion()); - // - // // startCert - // RestResponse startCert = - // LifecycleRestUtils.changeResourceState(resourceDetails, - // sdncModifierDetails, resourceVersion, - // LifeCycleStatesEnum.STARTCERTIFICATION); - // assertNotNull("check response object is not null after resource request - // start certification", startCert); - // assertEquals("Check response code after checkout resource", 200, - // startCert.getErrorCode().intValue()); - // resourceFromGet = - // ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); - // assertNotNull(resourceFromGet); - // resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), - // ResourceReqDetails.class); - // resourceDetails.setVersion(resourceFromGet.getVersion()); - // - // // certify - // RestResponse certify = - // LifecycleRestUtils.changeResourceState(resourceDetails, - // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CERTIFY); - // assertNotNull("check response object is not null after resource request - // certify", certify); - // assertEquals("Check response code after certify resource", 200, - // certify.getErrorCode().intValue()); - // resourceFromGet = - // ResponseParser.convertResourceResponseToJavaObject(certify.getResponse()); - // assertNotNull(resourceFromGet); - // resourceDetails = ResponseParser.parseToObject(certify.getResponse(), - // ResourceReqDetails.class); - // resourceDetails.setVersion(resourceFromGet.getVersion()); - // - // // clean audit - // DbUtils.cleanAllAudits(); - // - // // change resource details - // - // // import new resource while resource already exist in other state - // importResponse = - // ImportRestUtils.importNewResourceByName("importResource4testUpdateWithoutReqCap", - // UserRoleEnum.ADMIN); - // assertNotNull("check response object is not null after import resource", - // importResponse); - // assertNotNull("check error code exists in response after import - // resource", importResponse.getErrorCode()); - // assertEquals("Check response code after import resource", 200, - // importResponse.getErrorCode().intValue()); - // resourceDetails = - // ResponseParser.parseToObject(importResponse.getResponse(), - // ResourceReqDetails.class); - // resourceVersion = resourceDetails.getVersion(); - // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - // resourceDetails.getUniqueId()); - // assertEquals("Check response code after get resource", 200, - // resourceGetResponse.getErrorCode().intValue()); - // resourceFromGet = - // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - // assertNotNull(resourceFromGet); - // - // // validate response - // Resource resourceFromImport = - // ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); - // assertNotNull(resourceFromImport); - // - // resourceDetails = - // ResponseParser.parseToObject(importResponse.getResponse(), - // ResourceReqDetails.class); - // resourceRespJavaObject = - // Convertor.constructFieldsForRespValidation(resourceDetails); - // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - // - // // validate get response - // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - // resourceRespJavaObject.getUniqueId()); - // resourceFromGet = - // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - // assertNotNull(resourceFromGet); - // - // // validate - // ResourceValidationUtils.validateModelObjects(resourceFromImport, - // resourceFromGet); - // - // // validate audit - // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = - // Convertor.constructFieldsForAuditValidation(resourceDetails, - // resourceVersion); - // auditAction="ResourceImport"; - // expectedResourceAuditJavaObject.setAction(auditAction); - // expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - // expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); - // expectedResourceAuditJavaObject.setStatus("200"); - // expectedResourceAuditJavaObject.setDesc("OK"); - // expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); - // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, - // auditAction, null, false); - // } - - @Test - public void importNewResource_uuidTest() throws Exception { - RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); - - assertNotNull("check response object is not null after import resource", importResponse); - assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); - assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); - String oldUuid = ResponseParser.getValueFromJsonResponse(importResponse.getResponse(), "uuid"); - - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceVersion = resourceDetails.getVersion(); - RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - Resource resourceFromGet = ResponseParser - .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - // add mandatory artifacts - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // resourceGetResponse); - resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); - assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - "0.1", LifeCycleStatesEnum.CHECKIN); - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - String newUuid = ResponseParser.getValueFromJsonResponse(checkInResponse.getResponse(), "uuid"); - assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid)); - - // req4cert resource - RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertNotNull("check response object is not null after resource request for certification", request4cert); - assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - String newUuid2 = ResponseParser.getValueFromJsonResponse(request4cert.getResponse(), "uuid"); - assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid2)); - - // startCert - RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertNotNull("check response object is not null after resource request start certification", startCert); - assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); - resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); - assertNotNull(resourceFromGet); - resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); - resourceDetails.setVersion(resourceFromGet.getVersion()); - - String newUuid3 = ResponseParser.getValueFromJsonResponse(startCert.getResponse(), "uuid"); - assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid3)); - - RestResponse certify = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, "0.1", - LifeCycleStatesEnum.CERTIFY); - assertNotNull("check response object is not null after import resource", certify); - assertEquals("Check response code after checkout resource", 200, certify.getErrorCode().intValue()); - - String newUuid4 = ResponseParser.getValueFromJsonResponse(certify.getResponse(), "uuid"); - assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid4)); - - RestResponse checkoutResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - "1.0", LifeCycleStatesEnum.CHECKOUT); - assertNotNull("check response object is not null after import resource", checkInResponse); - assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); - - String newUuid5 = ResponseParser.getValueFromJsonResponse(checkoutResponse.getResponse(), "uuid"); - assertFalse(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid5)); - } - - @Test - public void importNewResource_propertiesMapInternalUrlCredential() throws Exception { - String folderName = "validateProporties_typeMap_valueUrlCredential"; - RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER); - - Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class); - - List<PropertyDefinition> properties = resource.getProperties(); - assertEquals("check properties size", 3, properties.size()); - - PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test")) - .findFirst().get(); - String defaultValue = propertyDefinition.getDefaultValue(); - - Map mapValue = gson.fromJson(defaultValue, Map.class); - assertEquals("check Map value size", 2, mapValue.size()); - checkMapValues(mapValue, "key", 1, null); - checkMapValues(mapValue, "key", 2, null); - - System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode()); - - } - - @Test - public void importNewResource_propertiesListInternalUrlCredential() throws Exception { - String folderName = "validateProporties_typeList_valueUrlCredential"; - RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER); - - Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class); - - List<PropertyDefinition> properties = resource.getProperties(); - assertEquals("check properties size", 3, properties.size()); - - PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test")) - .findFirst().get(); - String defaultValue = propertyDefinition.getDefaultValue(); - - List listValue = gson.fromJson(defaultValue, List.class); - assertEquals("check List value size", 2, listValue.size()); - checkListValues(listValue.get(0), 1, SPECIAL_CHARACTERS); - checkListValues(listValue.get(1), 2, SPECIAL_CHARACTERS); - - // Verify attributes - List<PropertyDefinition> attributes = resource.getAttributes(); + // public static UserUtils userUtils = new UserUtils(); + // public ResourceUtils resourceUtils = new ResourceUtils(); + // public AuditValidationUtils AuditValidationUtils = new + // AuditValidationUtils(); + // protected ArtifactUtils artifactUtils = new ArtifactUtils(); + + protected String resourceVersion = null; + protected String auditAction = null; + public User sdncModifierDetails = new User(); + protected String artifactName1 = "data_artifact1.sh"; + protected String artifactName2 = "data_artifact2.sh"; + protected String interfaze = "standard"; + protected String interfaceArtifactName = "data_interface1.sh"; + + private String SPECIAL_CHARACTERS = "~!#@~$%^*()[];:'\"|\\/"; + + public ResourceReqDetails resourceDetails = new ResourceReqDetails(); + + public Gson gson = new Gson(); + + @Rule + public static TestName name = new TestName(); + + public ImportNewResourceCITest() { + super(name, ImportNewResourceCITest.class.getName()); + } + + @BeforeMethod + public void before() throws Exception { + + // init user + sdncModifierDetails.setUserId(UserRoleEnum.ADMIN.getUserId()); + // init resource details + resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003"); + } + + @Test + public void importAllTestResources_toValidateNewAPI() throws Exception { + + for (ImportTestTypesEnum currResource : ImportTestTypesEnum.values()) { + // clean audit + DbUtils.cleanAllAudits(); + + // import testResources trough newResource API + RestResponse importResponse = ImportRestUtils.importNewResourceByName(currResource.getFolderName(), + UserRoleEnum.ADMIN); + System.err.println("import Resource " + "<" + currResource.getFolderName() + ">" + "response: " + + importResponse.getErrorCode()); + + // validate response + ImportRestUtils.validateImportTestTypesResp(currResource, importResponse); + if (currResource.getvalidateAudit() == true) { + // validate audit + // String baseVersion="0.1"; + String baseVersion = ""; + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(currResource.getActionStatus().name()); + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject(); + String auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId()); + expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName()); + expectedResourceAuditJavaObject.setResourceName(currResource.getNormativeName()); + expectedResourceAuditJavaObject.setResourceType("Resource"); + expectedResourceAuditJavaObject.setPrevVersion(""); + expectedResourceAuditJavaObject.setCurrVersion(baseVersion); + expectedResourceAuditJavaObject.setPrevState(""); + // expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); + expectedResourceAuditJavaObject.setCurrState(""); + expectedResourceAuditJavaObject.setComment(null); + expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); + List<String> variables = (currResource.getErrorParams() != null ? currResource.getErrorParams() + : new ArrayList<String>()); + String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); + expectedResourceAuditJavaObject.setDesc(auditDesc); + AuditValidationUtils.validateAuditImport(expectedResourceAuditJavaObject, auditAction); + } + } + } + + protected RestResponse importNewResource(UserRoleEnum userRoleEnum) throws Exception { + + // init user + sdncModifierDetails.setUserId(userRoleEnum.getUserId()); + // init resource details + resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003"); + // clean ES DB + DbUtils.cleanAllAudits(); + // import new resource (expected checkOut state) + RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test", userRoleEnum); + return importResponse; + } + + @Test(enabled = false) + public void importUIResource() throws IOException { + String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" + + " org.openecomp.resource.importResource4test:\r\n" + " derived_from: tosca.nodes.Root\r\n" + + " description: someDesc"; + + String encodedPayload = new String(Base64.encodeBase64(payload.getBytes())); + + String json = "{\r\n" + " \"resourceName\": \"importResource4test\",\r\n" + + " \"payloadName\": \"importResource4test.yml\",\r\n" + + " \"categories\": [{\"name\": \"Application L4+\",\"normalizedName\": \"application l4+\",\"uniqueId\": \"resourceNewCategory.application l4+\",\"subcategories\": [{\"name\": \"Web Server\"}]}],\r\n" + + " \"description\": \"ResourceDescription\",\r\n" + " \"vendorName\": \"VendorName\",\r\n" + + " \"vendorRelease\": \"VendorRelease\",\r\n" + " \"contactId\": \"AT1234\",\r\n" + + " \"icon\": \"router\",\r\n" + " \"tags\": [\r\n" + " \"importResource4test\"\r\n" + " ],\r\n" + + " \"payloadData\": \"" + encodedPayload + "\"\r\n" + "}"; + + String md5 = GeneralUtility.calculateMD5Base64EncodedByString(json); + + Map<String, String> headers = new HashMap<String, String>(); + headers.put(Constants.MD5_HEADER, md5); + headers.put(Constants.USER_ID_HEADER, UserRoleEnum.ADMIN.getUserId()); + headers.put(Constants.CONTENT_TYPE_HEADER, "application/json"); + + String url = String.format(Urls.CREATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort()); + + HttpRequest httpUtil = new HttpRequest(); + RestResponse httpSendPost = httpUtil.httpSendPost(url, json, headers); + Integer errorCode = httpSendPost.getErrorCode(); + assertTrue(errorCode == HttpStatus.SC_CREATED); + + } + + // TODO DE171337 + @Test(enabled = false) + public void importNewResource_suc() throws Exception { + + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + + // validate response + + resourceVersion = "0.1"; + + // ResourceRespJavaObject resourceRespJavaObject = + // Convertor.constructFieldsForRespValidation(resourceDetails, + // resourceVersion); + // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + // ResourceValidationUtils.validateResp(importResponse, + // resourceRespJavaObject); + // + // //validate get response + // + // RestResponse resourceGetResponse = + // ResourceRestUtils.getResource(sdncModifierDetails, resourceVersion); + // ResourceValidationUtils.validateResp(resourceGetResponse, + // resourceRespJavaObject); + Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + assertNotNull(resourceFromImport); + + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); + resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + + // validate get response + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceRespJavaObject.getUniqueId()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // validate + ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); + + // validate audit + resourceDetails.setVersion(resourceDetails.getVersion()); + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails, resourceVersion); + + auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setPrevState(""); + expectedResourceAuditJavaObject.setPrevVersion(""); + expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setStatus("201"); + expectedResourceAuditJavaObject.setDesc("OK"); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + + } + + @Test + public void importNewResource_byTester_failed() throws Exception { + + RestResponse importResponse = importNewResource(UserRoleEnum.TESTER); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 409, importResponse.getErrorCode().intValue()); + + } + + // TODO DE171337 + @Test(enabled = false) + public void importNewResource_existInCheckout_updateVendorName_updateCategory() throws Exception { + + // import new resource + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in other state + importResponse = ImportRestUtils.importNewResourceByName("importResource4testUpdateVendorNameAndCategory", + UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); + + // validate response + Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + assertNotNull(resourceFromImport); + + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); + resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + + // validate get response + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceRespJavaObject.getUniqueId()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // validate + ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); + + // validate audit + resourceDetails.setVersion(resourceDetails.getVersion()); + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails); + + auditAction = "ResourceImport"; + resourceVersion = "0.1"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + expectedResourceAuditJavaObject.setStatus("200"); + expectedResourceAuditJavaObject.setDesc("OK"); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + } + + @Test + public void importNewResource_perfromByAdmin_ownedBy_diffrentUser() throws Exception { + + RestResponse importResponse = importNewResource(UserRoleEnum.DESIGNER); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + + Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + // clean audit + DbUtils.cleanAllAudits(); + + importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + + ErrorInfo errorInfo = ErrorValidationUtils + .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name()); + assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode()); + + String[] split = resourceFromImport.getLastUpdaterFullName().split(" "); + String firstName = split[0]; + String lastName = split[1]; + List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName, + resourceFromImport.getLastUpdaterUserId()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables, + importResponse.getResponse()); + + } + + @Test + public void importNewResource_perfromByDesigner_ownedBy_diffrentUser() throws Exception { + + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + // clean audit + DbUtils.cleanAllAudits(); + + importResponse = importNewResource(UserRoleEnum.DESIGNER); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + + ErrorInfo errorInfo = ErrorValidationUtils + .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name()); + assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode()); + + String[] split = resourceFromImport.getLastUpdaterFullName().split(" "); + String firstName = split[0]; + String lastName = split[1]; + List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName, + resourceFromImport.getLastUpdaterUserId()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables, + importResponse.getResponse()); + + } + + @Test(enabled = false) + public void importNewResource_nameSpace_vf() throws Exception { + RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVF", + UserRoleEnum.DESIGNER); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + Resource resourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(importResponse.getResponse()); + assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VF)); + + } + + @Test + public void importNewResource_nameSpace_vfc() throws Exception { + RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVFC", + UserRoleEnum.DESIGNER); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + Resource resourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(importResponse.getResponse()); + assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC)); + } + + @Test + public void importNewResource_nameSpace_vl() throws Exception { + RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVL", + UserRoleEnum.DESIGNER); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + Resource resourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(importResponse.getResponse()); + assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VL)); + + } + + @Test + public void importNewResource_nameSpace_cp() throws Exception { + RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testCP", + UserRoleEnum.DESIGNER); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + + Resource resourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(importResponse.getResponse()); + assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.CP)); + } + + @Test + public void importNewResource_nameSpace_unknown() throws Exception { + RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test", + UserRoleEnum.DESIGNER); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + Resource resourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(importResponse.getResponse()); + assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC)); + + } + + @Test + public void importNewResource_MissingNameSpace() throws Exception { + RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testMissingNameSpace", + UserRoleEnum.DESIGNER); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 400, importResponse.getErrorCode().intValue()); + + } + + // TODO DE171337 + @Test(enabled = false) + public void importNewResource_existInCheckOut() throws Exception { + + // import new resource + + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in CHECKOUT state + + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); + + // validate response + Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + assertNotNull(resourceFromImport); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); + resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + + // validate get response + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceRespJavaObject.getUniqueId()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // validate + ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); + + // validate audit + resourceDetails.setVersion(resourceDetails.getVersion()); + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails); + + auditAction = "ResourceImport"; + resourceVersion = "0.1"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + expectedResourceAuditJavaObject.setStatus("200"); + expectedResourceAuditJavaObject.setDesc("OK"); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + } + + // TODO DE171337 + @Test(enabled = false) + public void importNewResource_existIn_CheckIn_state() throws Exception { + + // import new resource + + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + // checkIn resource + + resourceVersion = resourceDetails.getVersion(); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); + + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in CHECKIN state + + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); + + // validate response + Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + assertNotNull(resourceFromImport); + + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); + resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + + // validate get response + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceRespJavaObject.getUniqueId()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // validate + ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); + + // validate audit + resourceDetails.setVersion(resourceDetails.getVersion()); + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails); + + resourceVersion = "0.2"; + auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + expectedResourceAuditJavaObject.setStatus("200"); + expectedResourceAuditJavaObject.setDesc("OK"); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + } + + /* @Test + public void importNewResource_existIn_Ready4cert_state_performByTester() throws Exception { + // import new resource + + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceVersion = resourceDetails.getVersion(); + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + // add mandatory artifacts + // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // checkIn resource + resourceVersion = resourceDetails.getVersion(); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); + + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(checkInResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(checkInResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // req4cert resource + RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertNotNull("check response object is not null after resource request for certification", request4cert); + assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in CHECKIN state + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER); + + // validate response + resourceVersion = resourceDetails.getVersion(); + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); + assertNotNull("check response object is not null after create resouce", importResponse); + assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); + assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); + List<String> variables = Arrays.asList(); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, + importResponse.getResponse()); + + // validate audit + + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails, resourceVersion); + + String auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setResourceName(""); + expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId()); + expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName()); + expectedResourceAuditJavaObject.setPrevState(""); + expectedResourceAuditJavaObject.setCurrState(""); + expectedResourceAuditJavaObject.setPrevVersion(""); + expectedResourceAuditJavaObject.setCurrVersion(""); + expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); + String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); + expectedResourceAuditJavaObject.setDesc(auditDesc); + + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + }*/ + + /* // TODO DE171337 + @Test(enabled = false) + public void importNewResource_existIn_Ready4cert_state_performByDesigner() throws Exception { + // import new resource + + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceVersion = resourceDetails.getVersion(); + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + // add mandatory artifacts + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // checkIn resource + resourceVersion = resourceDetails.getVersion(); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + // req4cert resource + RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertNotNull("check response object is not null after resource request for certification", request4cert); + assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in other state + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER); + + // validate response + ErrorInfo errorInfo = ErrorValidationUtils + .parseErrorConfigYaml(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name()); + assertNotNull("check response object is not null after create resouce", importResponse); + assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); + assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); + String[] split = resourceFromGet.getLastUpdaterFullName().split(" "); + String firstName = split[0]; + String lastName = split[1]; + List<String> variables = Arrays.asList(resourceFromGet.getName(), "resource", firstName, lastName, + resourceFromGet.getLastUpdaterUserId()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name(), variables, + importResponse.getResponse()); + + // validate audit + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails, resourceVersion); + String auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId()); + expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName()); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.READY_FOR_CERTIFICATION).toString()); + // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState(""); + expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + expectedResourceAuditJavaObject.setCurrVersion(""); + expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); + expectedResourceAuditJavaObject.setDesc(auditDesc); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + + }*/ + + /*// TODO DE171337 + @Test(enabled = false) + public void importNewResource_existIn_Ready4cert_state_performByAdmin() throws Exception { + + // import new resource + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceVersion = resourceDetails.getVersion(); + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // add mandatory artifacts + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // checkIn resource + resourceVersion = resourceDetails.getVersion(); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + // req4cert resource + RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertNotNull("check response object is not null after resource request for certification", request4cert); + assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in other state + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + resourceVersion = resourceDetails.getVersion(); + // resourceVersion="0.2"; + + // validate response + Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + assertNotNull(resourceFromImport); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails); + resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + + // validate get response + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceRespJavaObject.getUniqueId()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // validate + ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet); + + // validate audit + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails, resourceVersion); + auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + expectedResourceAuditJavaObject.setStatus("200"); + expectedResourceAuditJavaObject.setDesc("OK"); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + }*/ + + /* @Test + public void importNewResource_existIn_CerInProgress_state_performByTester() throws Exception { + + // import new resource + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceVersion = resourceDetails.getVersion(); + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // add mandatory artifacts + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // checkIn resource + resourceVersion = resourceDetails.getVersion(); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + // req4cert resource + RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertNotNull("check response object is not null after resource request for certification", request4cert); + assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // startCert + RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertNotNull("check response object is not null after resource request start certification", startCert); + assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in other state + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER); + + // validate response + resourceVersion = resourceDetails.getVersion(); + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); + assertNotNull("check response object is not null after create resouce", importResponse); + assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); + assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); + List<String> variables = Arrays.asList(); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, + importResponse.getResponse()); + + // validate audit + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails, resourceVersion); + String auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setResourceName(""); + expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId()); + expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName()); + expectedResourceAuditJavaObject.setPrevState(""); + expectedResourceAuditJavaObject.setCurrState(""); + expectedResourceAuditJavaObject.setPrevVersion(""); + expectedResourceAuditJavaObject.setCurrVersion(""); + expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); + String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); + expectedResourceAuditJavaObject.setDesc(auditDesc); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + }*/ + + /*// TODO DE171337 + @Test(enabled = false) + public void importNewResource_existIn_CerInProgress_state_performByDesigner() throws Exception { + + User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + // import new resource + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceVersion = resourceDetails.getVersion(); + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // add mandatory artifacts + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // checkIn resource + resourceVersion = resourceDetails.getVersion(); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + // req4cert resource + RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertNotNull("check response object is not null after resource request for certification", request4cert); + assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // startCert + RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertNotNull("check response object is not null after resource request start certification", startCert); + assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + resourceVersion = resourceDetails.getVersion(); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in other state + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER); + ErrorInfo errorInfo = ErrorValidationUtils + .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name()); + assertNotNull("check response object is not null after create resouce", importResponse); + assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); + assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); + List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(), + sdncAdminUser.getLastName(), sdncAdminUser.getUserId()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(), + variables, importResponse.getResponse()); + + // validate audit + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails, resourceVersion); + String auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId()); + expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName()); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString()); + // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState(""); + expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + expectedResourceAuditJavaObject.setCurrVersion(""); + expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); + expectedResourceAuditJavaObject.setDesc(auditDesc); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + + }*/ + + /* // TODO DE171337 + @Test(enabled = false) + public void importNewResource_existIn_CerInProgress_state_performByAdmin() throws Exception { + + User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + + // import new resource + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceVersion = resourceDetails.getVersion(); + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + + // add mandatory artifacts + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // checkIn resource + resourceVersion = resourceDetails.getVersion(); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson); + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + // req4cert resource + RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertNotNull("check response object is not null after resource request for certification", request4cert); + assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + // startCert + RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertNotNull("check response object is not null after resource request start certification", startCert); + assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + resourceVersion = resourceDetails.getVersion(); + + // clean audit + DbUtils.cleanAllAudits(); + + // import new resource while resource already exist in other state + importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN); + + // validate response + ErrorInfo errorInfo = ErrorValidationUtils + .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name()); + assertNotNull("check response object is not null after create resouce", importResponse); + assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode()); + assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode()); + List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(), + sdncAdminUser.getLastName(), sdncAdminUser.getUserId()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(), + variables, importResponse.getResponse()); + + // validate audit + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor + .constructFieldsForAuditValidation(resourceDetails, resourceVersion); + String auditAction = "ResourceImport"; + expectedResourceAuditJavaObject.setAction(auditAction); + expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId()); + expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName()); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString()); + // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState(""); + expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + expectedResourceAuditJavaObject.setCurrVersion(""); + expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); + expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables); + expectedResourceAuditJavaObject.setDesc(auditDesc); + AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false); + + }*/ + + // TODO DE171337 + // @Test(enabled = false) + // public void + // importNewResource_existIn_Certified_state_chnage_reqAndCap_byDesigner() + // throws Exception{ + // + // // Andrey - set default artifact details + // ArtifactDefinition artifactDefinition = + // artifactUtils.constructDefaultArtifactInfo(); + // + // // import new resource + // RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + // assertNotNull("check response object is not null after import resource", + // importResponse); + // assertNotNull("check error code exists in response after import + // resource", importResponse.getErrorCode()); + // assertEquals("Check response code after import resource", 201, + // importResponse.getErrorCode().intValue()); + // String resourceId = + // ResponseParser.getUniqueIdFromResponse(importResponse); + // resourceDetails = + // ResponseParser.parseToObject(importResponse.getResponse(), + // ResourceReqDetails.class); + // resourceVersion = resourceDetails.getVersion(); + // RestResponse resourceGetResponse = + // ResourceRestUtils.getResource(sdncModifierDetails, + // resourceDetails.getUniqueId()); + // assertEquals("Check response code after get resource", 200, + // resourceGetResponse.getErrorCode().intValue()); + // Resource resourceFromGet = + // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + // assertNotNull(resourceFromGet); + // + // // add mandatory artifacts + // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + // resourceDetails.getUniqueId()); + // assertEquals("Check response code after get resource", 200, + // resourceGetResponse.getErrorCode().intValue()); + // resourceFromGet = + // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + // assertNotNull(resourceFromGet); + // resourceDetails = + // ResponseParser.parseToObject(importResponse.getResponse(), + // ResourceReqDetails.class); + // resourceDetails.setVersion(resourceFromGet.getVersion()); + // + // // add artifact + // artifactDefinition.setArtifactName(artifactName1); + // ArtifactRestUtils.addInformationalArtifactToResource(resourceDetails, + // sdncModifierDetails, resourceVersion , artifactDefinition); + // + // // add artifact + // artifactDefinition.setArtifactName(artifactName2); + // resourceUtils.add_artifact(resourceDetails, sdncModifierDetails, + // resourceVersion , artifactDefinition); + // + // // add interface + // artifactDefinition.setArtifactName(interfaceArtifactName); + // ResourceRestUtils.add_interface(resourceDetails, sdncModifierDetails, + // resourceVersion , artifactDefinition); + // + // //construct fields for validation + // resourceVersion="1.0"; + // + // ResourceRespJavaObject resourceRespJavaObject = + // Convertor.constructFieldsForRespValidation(resourceDetails, + // resourceVersion); + // ArrayList<String> artifacts = new ArrayList<String>(); + // + // artifacts.add(resourceId+":"+artifactName1); + // artifacts.add(resourceId+":"+artifactName2); + // resourceRespJavaObject.setArtifacts(artifacts); + // ArrayList<String> interfaces = new ArrayList<String>(); + // + // interfaces.add(interfaze); + // resourceRespJavaObject.setInterfaces(interfaces); + // + // // checkIn resource + // resourceVersion = resourceDetails.getVersion(); + // String checkinComment = "good checkin"; + // String checkinComentJson = "{\"userRemarks\": \""+checkinComment+"\"}"; + // RestResponse checkInResponse = + // LifecycleRestUtils.changeResourceState(resourceDetails, + // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CHECKIN, + // checkinComentJson); + // assertNotNull("check response object is not null after import resource", + // checkInResponse); + // assertEquals("Check response code after checkout resource", 200, + // checkInResponse.getErrorCode().intValue()); + // + // // req4cert resource + // RestResponse request4cert = + // LifecycleRestUtils.changeResourceState(resourceDetails, + // sdncModifierDetails, resourceVersion, + // LifeCycleStatesEnum.CERTIFICATIONREQUEST); + // assertNotNull("check response object is not null after resource request + // for certification", request4cert); + // assertEquals("Check response code after checkout resource", 200, + // request4cert.getErrorCode().intValue()); + // resourceFromGet = + // ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + // assertNotNull(resourceFromGet); + // resourceDetails = + // ResponseParser.parseToObject(request4cert.getResponse(), + // ResourceReqDetails.class); + // resourceDetails.setVersion(resourceFromGet.getVersion()); + // + // // startCert + // RestResponse startCert = + // LifecycleRestUtils.changeResourceState(resourceDetails, + // sdncModifierDetails, resourceVersion, + // LifeCycleStatesEnum.STARTCERTIFICATION); + // assertNotNull("check response object is not null after resource request + // start certification", startCert); + // assertEquals("Check response code after checkout resource", 200, + // startCert.getErrorCode().intValue()); + // resourceFromGet = + // ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); + // assertNotNull(resourceFromGet); + // resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), + // ResourceReqDetails.class); + // resourceDetails.setVersion(resourceFromGet.getVersion()); + // + // // certify + // RestResponse certify = + // LifecycleRestUtils.changeResourceState(resourceDetails, + // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CERTIFY); + // assertNotNull("check response object is not null after resource request + // certify", certify); + // assertEquals("Check response code after certify resource", 200, + // certify.getErrorCode().intValue()); + // resourceFromGet = + // ResponseParser.convertResourceResponseToJavaObject(certify.getResponse()); + // assertNotNull(resourceFromGet); + // resourceDetails = ResponseParser.parseToObject(certify.getResponse(), + // ResourceReqDetails.class); + // resourceDetails.setVersion(resourceFromGet.getVersion()); + // + // // clean audit + // DbUtils.cleanAllAudits(); + // + // // change resource details + // + // // import new resource while resource already exist in other state + // importResponse = + // ImportRestUtils.importNewResourceByName("importResource4testUpdateWithoutReqCap", + // UserRoleEnum.ADMIN); + // assertNotNull("check response object is not null after import resource", + // importResponse); + // assertNotNull("check error code exists in response after import + // resource", importResponse.getErrorCode()); + // assertEquals("Check response code after import resource", 200, + // importResponse.getErrorCode().intValue()); + // resourceDetails = + // ResponseParser.parseToObject(importResponse.getResponse(), + // ResourceReqDetails.class); + // resourceVersion = resourceDetails.getVersion(); + // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + // resourceDetails.getUniqueId()); + // assertEquals("Check response code after get resource", 200, + // resourceGetResponse.getErrorCode().intValue()); + // resourceFromGet = + // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + // assertNotNull(resourceFromGet); + // + // // validate response + // Resource resourceFromImport = + // ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse()); + // assertNotNull(resourceFromImport); + // + // resourceDetails = + // ResponseParser.parseToObject(importResponse.getResponse(), + // ResourceReqDetails.class); + // resourceRespJavaObject = + // Convertor.constructFieldsForRespValidation(resourceDetails); + // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + // + // // validate get response + // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + // resourceRespJavaObject.getUniqueId()); + // resourceFromGet = + // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + // assertNotNull(resourceFromGet); + // + // // validate + // ResourceValidationUtils.validateModelObjects(resourceFromImport, + // resourceFromGet); + // + // // validate audit + // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = + // Convertor.constructFieldsForAuditValidation(resourceDetails, + // resourceVersion); + // auditAction="ResourceImport"; + // expectedResourceAuditJavaObject.setAction(auditAction); + // expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + // expectedResourceAuditJavaObject.setPrevVersion(resourceVersion); + // expectedResourceAuditJavaObject.setStatus("200"); + // expectedResourceAuditJavaObject.setDesc("OK"); + // expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName()); + // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, + // auditAction, null, false); + // } + + /*@Test + public void importNewResource_uuidTest() throws Exception { + RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN); + + assertNotNull("check response object is not null after import resource", importResponse); + assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode()); + assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue()); + String oldUuid = ResponseParser.getValueFromJsonResponse(importResponse.getResponse(), "uuid"); + + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceVersion = resourceDetails.getVersion(); + RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + Resource resourceFromGet = ResponseParser + .convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + // add mandatory artifacts + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // resourceGetResponse); + resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId()); + assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + "0.1", LifeCycleStatesEnum.CHECKIN); + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + String newUuid = ResponseParser.getValueFromJsonResponse(checkInResponse.getResponse(), "uuid"); + assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid)); + + // req4cert resource + RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertNotNull("check response object is not null after resource request for certification", request4cert); + assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + String newUuid2 = ResponseParser.getValueFromJsonResponse(request4cert.getResponse(), "uuid"); + assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid2)); + + // startCert + RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertNotNull("check response object is not null after resource request start certification", startCert); + assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue()); + resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse()); + assertNotNull(resourceFromGet); + resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class); + resourceDetails.setVersion(resourceFromGet.getVersion()); + + String newUuid3 = ResponseParser.getValueFromJsonResponse(startCert.getResponse(), "uuid"); + assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid3)); + + RestResponse certify = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, "0.1", + LifeCycleStatesEnum.CERTIFY); + assertNotNull("check response object is not null after import resource", certify); + assertEquals("Check response code after checkout resource", 200, certify.getErrorCode().intValue()); + + String newUuid4 = ResponseParser.getValueFromJsonResponse(certify.getResponse(), "uuid"); + assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid4)); + + RestResponse checkoutResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + "1.0", LifeCycleStatesEnum.CHECKOUT); + assertNotNull("check response object is not null after import resource", checkInResponse); + assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue()); + + String newUuid5 = ResponseParser.getValueFromJsonResponse(checkoutResponse.getResponse(), "uuid"); + assertFalse(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid5)); + }*/ + + @Test + public void importNewResource_propertiesMapInternalUrlCredential() throws Exception { + String folderName = "validateProporties_typeMap_valueUrlCredential"; + RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER); + + Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class); + + List<PropertyDefinition> properties = resource.getProperties(); + assertEquals("check properties size", 3, properties.size()); + + PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test")) + .findFirst().get(); + String defaultValue = propertyDefinition.getDefaultValue(); + + Map mapValue = gson.fromJson(defaultValue, Map.class); + assertEquals("check Map value size", 2, mapValue.size()); + checkMapValues(mapValue, "key", 1, null); + checkMapValues(mapValue, "key", 2, null); + + System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode()); + + } + + @Test + public void importNewResource_propertiesListInternalUrlCredential() throws Exception { + String folderName = "validateProporties_typeList_valueUrlCredential"; + RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER); + + Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class); + + List<PropertyDefinition> properties = resource.getProperties(); + assertEquals("check properties size", 3, properties.size()); + + PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test")) + .findFirst().get(); + String defaultValue = propertyDefinition.getDefaultValue(); + + List listValue = gson.fromJson(defaultValue, List.class); + assertEquals("check List value size", 2, listValue.size()); + checkListValues(listValue.get(0), 1, SPECIAL_CHARACTERS); + checkListValues(listValue.get(1), 2, SPECIAL_CHARACTERS); + + // Verify attributes + List<PropertyDefinition> attributes = resource.getAttributes(); - assertEquals("check properties size", 2, attributes.size()); + assertEquals("check properties size", 2, attributes.size()); - // Verify attribute from type map - 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); - assertEquals("check Map value size", 2, attributeMapValue.size()); - checkMapValues(attributeMapValue, "key", 1, SPECIAL_CHARACTERS); - checkMapValues(attributeMapValue, "key", 2, SPECIAL_CHARACTERS); + // Verify attribute from type map + 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); + assertEquals("check Map value size", 2, attributeMapValue.size()); + checkMapValues(attributeMapValue, "key", 1, SPECIAL_CHARACTERS); + checkMapValues(attributeMapValue, "key", 2, SPECIAL_CHARACTERS); - // Verify attribute from type list - PropertyDefinition attributeListDefinition = attributes.stream() - .filter(p -> p.getName().equals("validation_test_list")).findFirst().get(); - String defaultListValue = attributeListDefinition.getDefaultValue(); + // Verify attribute from type list + PropertyDefinition attributeListDefinition = attributes.stream() + .filter(p -> p.getName().equals("validation_test_list")).findFirst().get(); + String defaultListValue = attributeListDefinition.getDefaultValue(); - List attributeListValue = gson.fromJson(defaultListValue, List.class); - assertEquals("check List value size", 2, attributeListValue.size()); - checkListValues(attributeListValue.get(0), 1, SPECIAL_CHARACTERS); - checkListValues(attributeListValue.get(1), 2, SPECIAL_CHARACTERS); + List attributeListValue = gson.fromJson(defaultListValue, List.class); + assertEquals("check List value size", 2, attributeListValue.size()); + checkListValues(attributeListValue.get(0), 1, SPECIAL_CHARACTERS); + checkListValues(attributeListValue.get(1), 2, SPECIAL_CHARACTERS); - System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode()); + System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode()); - } + } - private void checkListValues(Object object, int index, String suffix) { + private void checkListValues(Object object, int index, String suffix) { - Map map = (Map) object; - assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix), - map.get("protocol")); - assertEquals("check Map token value", "token" + index, map.get("token")); - } + Map map = (Map) object; + assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix), + map.get("protocol")); + assertEquals("check Map token value", "token" + index, map.get("token")); + } - // @Test - public void importNewResource_validateProporties_typeTestDataType() throws Exception { - String folderName = "validateProporties_typeTestDataType"; - RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER); + // @Test + public void importNewResource_validateProporties_typeTestDataType() throws Exception { + String folderName = "validateProporties_typeTestDataType"; + RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER); - Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class); + Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class); - } + } - private void checkMapValues(Map mapValue, String key, int index, String suffix) { + private void checkMapValues(Map mapValue, String key, int index, String suffix) { - Map map1 = (Map) mapValue.get(key + index); - assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix), - map1.get("protocol")); - assertEquals("check Map token value", "token" + index, map1.get("token")); + Map map1 = (Map) mapValue.get(key + index); + assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix), + map1.get("protocol")); + assertEquals("check Map token value", "token" + index, map1.get("token")); - } + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java index 3d7c81abae..4338a1b151 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java @@ -20,29 +20,14 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -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.List; -import java.util.Map; -import java.util.stream.Collectors; - +import com.google.gson.Gson; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.tuple.ImmutablePair; 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.CapabilityDefinition; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.ComponentInstanceProperty; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; @@ -54,7 +39,17 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.testng.annotations.Test; -import com.google.gson.Gson; +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.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; /** * US US730518 Story [BE] - TOSCA capabilities with properties - import "As a diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java index 9899a8c996..7338645f57 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java @@ -20,24 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED; -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_SUCCESS; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import org.apache.http.client.ClientProtocolException; import org.junit.Rule; import org.junit.rules.TestName; @@ -46,18 +28,7 @@ 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.CapReqDef; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.be.model.RelationshipImpl; -import org.openecomp.sdc.be.model.RelationshipInfo; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; @@ -65,11 +36,7 @@ import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; @@ -78,13 +45,7 @@ import org.openecomp.sdc.ci.tests.utils.Decoder; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.general.ImportUtils; -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.ComponentRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.*; import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.api.ToscaNodeTypeInfo; @@ -95,6 +56,13 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.io.File; +import java.io.IOException; +import java.util.*; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*; +import static org.testng.AssertJUnit.*; + /** * * @author Andrey + Pavel + Shay @@ -1269,12 +1237,12 @@ public class ImportToscaResourceTest extends ComponentBaseTest { assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size()); importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse); - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue())*/; RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); @@ -1313,10 +1281,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse createResourceResponse = ResourceRestUtils.createResource(vf, sdncUserDetails); ResourceRestUtils.checkCreateResponse(createResourceResponse); - LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails, +//TODO Andrey should click on certify button + /*LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); LifecycleRestUtils.changeResourceState(importReqDetails2, sdncUserDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); + LifeCycleStatesEnum.CERTIFICATIONREQUEST);*/ + LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails, + LifeCycleStatesEnum.CERTIFY); + LifecycleRestUtils.changeResourceState(importReqDetails2, sdncUserDetails, + LifeCycleStatesEnum.CERTIFY); RestResponse response = ResourceRestUtils.createResourceInstance(importDetails, sdncUserDetails, vf.getUniqueId()); @@ -1378,14 +1351,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size()); importReqDetails.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse); - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, + //TODO Andrey should click on certify button + /*RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String fileName2 = "CaseInsensitiveCapTest_2.yml"; @@ -1439,15 +1413,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +//TODO Andrey should click on certify button +/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String derivedFromResourceName = importReqDetails.getName(); @@ -1524,15 +1498,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +//TODO Andrey should click on certify button + /*RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String derivedFromName = importReqDetails.getName(); @@ -1568,14 +1542,14 @@ public class ImportToscaResourceTest extends ComponentBaseTest { null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, + /*RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String derivedFromName = importReqDetails.getName(); @@ -1611,15 +1585,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +//TODO Andrey should click on certify button +/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue())*/; RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String fatherUniqueId = importReqDetails.getUniqueId(); @@ -1670,15 +1644,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +//TODO Andrey should click on certify button +/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String derivedFromName = importReqDetails.getName(); @@ -1721,15 +1695,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +//TODO Andrey should click on certify button +/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String derivedFromName = importReqDetails.getName(); @@ -1773,15 +1747,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +//TODO Andrey should click on certify button +/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String fatherUniqueId = importReqDetails.getUniqueId(); @@ -1850,15 +1824,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest { RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null); assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue()); - - RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, +//TODO Andrey should click on certify button +/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue()); RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue()); + assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/ RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails, - ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY); + ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue()); String childFileName = "DifferentReqCapFromCompute1.yml"; @@ -1950,8 +1924,8 @@ public class ImportToscaResourceTest extends ComponentBaseTest { LifeCycleStatesEnum.CHECKIN); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); - - // certification request +//TODO Andrey should click on certify button + /*// certification request changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); @@ -1961,10 +1935,10 @@ public class ImportToscaResourceTest extends ComponentBaseTest { changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser, LifeCycleStatesEnum.STARTCERTIFICATION); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); - assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); + assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/ // certify - changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser, + changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFY); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); @@ -1982,19 +1956,19 @@ public class ImportToscaResourceTest extends ComponentBaseTest { assertEquals(STATUS_CODE_SUCCESS, updateResponse.getErrorCode().intValue()); assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, updateResponse)); - // certification request + /* // certification request changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); - +*/ // checkout resource changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CHECKOUT); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); - - // certification request +//TODO Andrey should click on certify button +/* // certification request changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); @@ -2004,16 +1978,16 @@ public class ImportToscaResourceTest extends ComponentBaseTest { changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser, LifeCycleStatesEnum.STARTCERTIFICATION); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); - assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); + assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/ - // cancel certification + /*// cancel certification changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser, LifeCycleStatesEnum.CANCELCERTIFICATION); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); - assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); + assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/ - // start certification - changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser, + /*// start certification + changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, LifeCycleStatesEnum.STARTCERTIFICATION); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); @@ -2022,7 +1996,7 @@ public class ImportToscaResourceTest extends ComponentBaseTest { changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser, LifeCycleStatesEnum.FAILCERTIFICATION); assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue()); - assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState)); + assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/ // upload artifact changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails, diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java index 9e8b94e5a8..473e4f2e36 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java @@ -20,14 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.imports; -import static org.testng.AssertJUnit.assertTrue; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.regex.Pattern; - +import com.google.gson.Gson; import org.apache.commons.codec.binary.Base64; import org.junit.Rule; import org.junit.rules.TestName; @@ -48,7 +41,13 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.common.api.Constants; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.regex.Pattern; + +import static org.testng.AssertJUnit.assertTrue; public class ImportUpdateResourseCsarTest extends ComponentBaseTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java index 560e5389fe..91cf3b0c44 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java @@ -20,28 +20,15 @@ package org.openecomp.sdc.ci.tests.execute.inputs; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import fj.data.Either; import org.apache.commons.lang3.tuple.Pair; import org.junit.Rule; 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.Component; -import org.openecomp.sdc.be.model.ComponentInstInputsMap; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.ComponentInstancePropInput; -import org.openecomp.sdc.be.model.InputDefinition; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; @@ -49,18 +36,18 @@ 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.AtomicOperationUtils; 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.ComponentInstanceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.InputsRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils; import org.testng.annotations.Test; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; -import fj.data.Either; +import static org.testng.AssertJUnit.assertTrue; /** * CI-Tests for inputs @@ -91,7 +78,7 @@ public class InputsApiTests extends ComponentBaseTest { */ @Test public void testCreateResourceInstanceWithInputsFromCsar() throws Exception { - Resource vf = AtomicOperationUtils.importResourceFromCSAR(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar1); + Resource vf = AtomicOperationUtils.importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar1); assertTrue("Success creating VF from CSAR", !vf.getInputs().isEmpty()); } @@ -181,7 +168,7 @@ public class InputsApiTests extends ComponentBaseTest { Service service = createDefaultServiceEither.left().value(); // Create VF from CSAR file - Resource vfWithInputs = AtomicOperationUtils.importResourceFromCSAR(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar2); + Resource vfWithInputs = AtomicOperationUtils.importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar2); // Certify VF Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(vfWithInputs, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java index e15652dddf..358e425cc5 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java @@ -20,12 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.lifecycle; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; - import org.apache.log4j.lf5.util.ResourceUtils; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; @@ -37,153 +31,146 @@ 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.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; 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.ComponentInstanceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.rest.*; import org.testng.annotations.BeforeMethod; +import java.io.IOException; + +import static org.testng.AssertJUnit.*; + /** - * * @author al714h - * - * resourceDetails - create, Add Heat, certify resourceDetails1 - create - * resource, LCS - CheckOut serviceDetails - create, add RI from - * resourceDetails serviceDetails2 - create, add RI from resourceDetails - * serviceDetailsEmpty - create, LCS - CheckOut serviceDetailsEmpty2 - - * create, LCS - CheckOut - * + * <p> + * resourceDetails - create, Add Heat, certify resourceDetails1 - create + * resource, LCS - CheckOut serviceDetails - create, add RI from + * resourceDetails serviceDetails2 - create, add RI from resourceDetails + * serviceDetailsEmpty - create, LCS - CheckOut serviceDetailsEmpty2 - + * create, LCS - CheckOut */ public abstract class LCSbaseTest extends ComponentBaseTest { - protected ResourceReqDetails resourceDetails; - protected ResourceReqDetails resourceDetails1; - protected ServiceReqDetails serviceDetails; - protected ServiceReqDetails serviceDetails2; - protected ServiceReqDetails serviceDetailsEmpty; - protected ServiceReqDetails serviceDetailsEmpty2; - protected ComponentInstanceReqDetails componentInstanceReqDetails; - protected ComponentInstanceReqDetails resourceInstanceReqDetails2; - protected User sdncDesignerDetails1; - protected User sdncDesignerDetails2; - protected static User sdncTesterDeatails1; - protected User sdncAdminDetails1; - protected ArtifactReqDetails heatArtifactDetails; - protected ArtifactReqDetails heatVolArtifactDetails; - protected ArtifactReqDetails heatNetArtifactDetails; - - protected ArtifactReqDetails defaultArtifactDetails; - protected ResourceUtils resourceUtils; - protected ArtifactUtils artifactUtils; - - // protected static ServiceUtils serviceUtils = new ServiceUtils(); - public LCSbaseTest(TestName testName, String className) { - super(testName, className); - } - - @BeforeMethod - public void before() throws Exception { - - initializeMembers(); - - createComponents(); - - } - - public void initializeMembers() throws IOException, Exception { - resourceDetails = ElementFactory.getDefaultResource(); - // resourceDetails = - // ElementFactory.getDefaultResource("myNewResource1234567890", - // NormativeTypesEnum.ROOT, ResourceServiceCategoriesEnum.ROUTERS, - // UserRoleEnum.DESIGNER.getUserId()); - resourceDetails1 = ElementFactory.getDefaultResource("secondResource", NormativeTypesEnum.ROOT); - serviceDetails = ElementFactory.getDefaultService(); - serviceDetails2 = ElementFactory.getDefaultService("newTestService2", ServiceCategoriesEnum.MOBILITY, "al1976"); - serviceDetailsEmpty = ElementFactory.getDefaultService("newEmptyService", ServiceCategoriesEnum.MOBILITY, - "al1976"); - serviceDetailsEmpty2 = ElementFactory.getDefaultService("newEmptyService2", ServiceCategoriesEnum.MOBILITY, - "al1976"); - sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - sdncDesignerDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2); - sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - sdncAdminDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); - heatNetArtifactDetails = ElementFactory - .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType()); - heatVolArtifactDetails = ElementFactory - .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType()); - componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance(); - resourceInstanceReqDetails2 = ElementFactory.getDefaultComponentInstance(); - - } - - protected void createComponents() throws Exception { - - RestResponse response = ResourceRestUtils.createResource(resourceDetails1, sdncDesignerDetails1); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("resource uniqueId is null:", resourceDetails1.getUniqueId()); - - response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails1); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("resource uniqueId is null:", resourceDetails.getUniqueId()); - - response = ServiceRestUtils.createService(serviceDetails, sdncDesignerDetails1); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("service uniqueId is null:", serviceDetails.getUniqueId()); - - ArtifactReqDetails heatArtifactDetails = ElementFactory - .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); - response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, - resourceDetails.getUniqueId()); - assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(), - response.getErrorCode() == 200); - - // certified resource - response = LCSbaseTest.certifyResource(resourceDetails, sdncDesignerDetails1); - assertTrue("certify resource request returned status:" + response.getErrorCode(), - response.getErrorCode() == 200); - - // add resource instance with HEAT deployment artifact to the service - componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId()); - response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1, - serviceDetails.getUniqueId(), ComponentTypeEnum.SERVICE); - assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201); - - response = ServiceRestUtils.createService(serviceDetails2, sdncDesignerDetails1); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("service uniqueId is null:", serviceDetails2.getUniqueId()); - - componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId()); - response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1, - serviceDetails2.getUniqueId(), ComponentTypeEnum.SERVICE); - assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201); - - response = ServiceRestUtils.createService(serviceDetailsEmpty, sdncDesignerDetails1); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("service uniqueId is null:", serviceDetailsEmpty.getUniqueId()); - - response = ServiceRestUtils.createService(serviceDetailsEmpty2, sdncDesignerDetails1); - assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); - assertNotNull("service uniqueId is null:", serviceDetailsEmpty2.getUniqueId()); - - DbUtils.cleanAllAudits(); - - } - - public static RestResponse certifyResource(ResourceReqDetails resourceDetails, User user) throws Exception { - RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(), - LifeCycleStatesEnum.CHECKIN); + protected ResourceReqDetails resourceDetails; + protected ResourceReqDetails resourceDetails1; + protected ServiceReqDetails serviceDetails; + protected ServiceReqDetails serviceDetails2; + protected ServiceReqDetails serviceDetailsEmpty; + protected ServiceReqDetails serviceDetailsEmpty2; + protected ComponentInstanceReqDetails componentInstanceReqDetails; + protected ComponentInstanceReqDetails resourceInstanceReqDetails2; + protected User sdncDesignerDetails1; + protected User sdncDesignerDetails2; + protected static User sdncTesterDeatails1; + protected User sdncAdminDetails1; + protected ArtifactReqDetails heatArtifactDetails; + protected ArtifactReqDetails heatVolArtifactDetails; + protected ArtifactReqDetails heatNetArtifactDetails; + + protected ArtifactReqDetails defaultArtifactDetails; + protected ResourceUtils resourceUtils; + protected ArtifactUtils artifactUtils; + + // protected static ServiceUtils serviceUtils = new ServiceUtils(); + public LCSbaseTest(TestName testName, String className) { + super(testName, className); + } + + @BeforeMethod + public void before() throws Exception { + + initializeMembers(); + + createComponents(); + + } + + public void initializeMembers() throws IOException, Exception { + resourceDetails = ElementFactory.getDefaultResource(); + // resourceDetails = + // ElementFactory.getDefaultResource("myNewResource1234567890", + // NormativeTypesEnum.ROOT, ResourceServiceCategoriesEnum.ROUTERS, + // UserRoleEnum.DESIGNER.getUserId()); + resourceDetails1 = ElementFactory.getDefaultResource("secondResource", NormativeTypesEnum.ROOT); + serviceDetails = ElementFactory.getDefaultService(); + serviceDetails2 = ElementFactory.getDefaultService("newTestService2", ServiceCategoriesEnum.MOBILITY, "al1976", ServiceInstantiationType.A_LA_CARTE.getValue()); + serviceDetailsEmpty = ElementFactory.getDefaultService("newEmptyService", ServiceCategoriesEnum.MOBILITY, + "al1976", ServiceInstantiationType.A_LA_CARTE.getValue()); + serviceDetailsEmpty2 = ElementFactory.getDefaultService("newEmptyService2", ServiceCategoriesEnum.MOBILITY, + "al1976", ServiceInstantiationType.A_LA_CARTE.getValue()); + sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + sdncDesignerDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2); + sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); + sdncAdminDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); + heatNetArtifactDetails = ElementFactory + .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType()); + heatVolArtifactDetails = ElementFactory + .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType()); + componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance(); + resourceInstanceReqDetails2 = ElementFactory.getDefaultComponentInstance(); + + } + + protected void createComponents() throws Exception { + + RestResponse response = ResourceRestUtils.createResource(resourceDetails1, sdncDesignerDetails1); + assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); + assertNotNull("resource uniqueId is null:", resourceDetails1.getUniqueId()); + + response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails1); + assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); + assertNotNull("resource uniqueId is null:", resourceDetails.getUniqueId()); + + response = ServiceRestUtils.createService(serviceDetails, sdncDesignerDetails1); + assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); + assertNotNull("service uniqueId is null:", serviceDetails.getUniqueId()); + + ArtifactReqDetails heatArtifactDetails = ElementFactory + .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); + response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, + resourceDetails.getUniqueId()); + assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(), + response.getErrorCode() == 200); + + // certified resource + response = LCSbaseTest.certifyResource(resourceDetails, sdncDesignerDetails1); + assertTrue("certify resource request returned status:" + response.getErrorCode(), + response.getErrorCode() == 200); + + // add resource instance with HEAT deployment artifact to the service + componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId()); + response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1, + serviceDetails.getUniqueId(), ComponentTypeEnum.SERVICE); + assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201); + + response = ServiceRestUtils.createService(serviceDetails2, sdncDesignerDetails1); + assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); + assertNotNull("service uniqueId is null:", serviceDetails2.getUniqueId()); + + componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId()); + response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1, + serviceDetails2.getUniqueId(), ComponentTypeEnum.SERVICE); + assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201); + + response = ServiceRestUtils.createService(serviceDetailsEmpty, sdncDesignerDetails1); + assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); + assertNotNull("service uniqueId is null:", serviceDetailsEmpty.getUniqueId()); + + response = ServiceRestUtils.createService(serviceDetailsEmpty2, sdncDesignerDetails1); + assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201); + assertNotNull("service uniqueId is null:", serviceDetailsEmpty2.getUniqueId()); + + DbUtils.cleanAllAudits(); + + } + + public static RestResponse certifyResource(ResourceReqDetails resourceDetails, User user) throws Exception { +/* RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(), + LifeCycleStatesEnum.CHECKIN); // if (restResponseResource.getErrorCode() == 200){ restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); @@ -199,76 +186,78 @@ public abstract class LCSbaseTest extends ComponentBaseTest { restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDeatails1.getUserId(), LifeCycleStatesEnum.CERTIFY); } - return restResponseResource; - } - - public static RestResponse certifyService(ServiceReqDetails serviceDetails, User user) throws Exception { - RestResponse restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user, - LifeCycleStatesEnum.CHECKIN); - // if (restResponseService.getErrorCode() == 200){ - restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - // }else - // return restResponseService; - - sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - if (restResponseService.getErrorCode() == 200) { - restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1, - LifeCycleStatesEnum.STARTCERTIFICATION); - } else - return restResponseService; - if (restResponseService.getErrorCode() == 200) { - restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1, - LifeCycleStatesEnum.CERTIFY); - } - return restResponseService; - } - - protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion, - User user) throws Exception { - return raiseResourceToTargetVersion(resourceDetails, targetVersion, null, user); - } - - protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion, - RestResponse prevResponse, User user) throws Exception { - - String[] splitParts = targetVersion.split("\\."); - - int version = Integer.parseInt(splitParts[1]); - String checkinComment = "good checkin"; - String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; - - if (prevResponse != null) { - Resource resourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(prevResponse.getResponse()); - if (resourceRespJavaObject.getLifecycleState().equals(LifecycleStateEnum.CERTIFIED)) { - RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, - user.getUserId(), LifeCycleStatesEnum.CHECKOUT); - } - } - - RestResponse restResponseResource = null; - for (int i = 0; i < (version - 1); i++) { - - restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null, - LifeCycleStatesEnum.CHECKIN, checkinComentJson); - if (restResponseResource.getErrorCode() == 200) { - restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(), - LifeCycleStatesEnum.CHECKOUT); - if (restResponseResource.getErrorCode() == 200) { - - } else - break; - - } else - break; - - } - - restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null, - LifeCycleStatesEnum.CHECKIN, checkinComentJson); - assertEquals("Check response code ", 200, restResponseResource.getErrorCode().intValue()); - return restResponseResource; - } + return restResponseResource;*/ + return LifecycleRestUtils.changeResourceState(resourceDetails, + sdncTesterDeatails1.getUserId(), LifeCycleStatesEnum.CERTIFY); + } + + public static RestResponse certifyService(ServiceReqDetails serviceDetails, User user) throws Exception { + RestResponse restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user, + LifeCycleStatesEnum.CHECKIN); + // if (restResponseService.getErrorCode() == 200){ + restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user, + LifeCycleStatesEnum.CERTIFICATIONREQUEST); + // }else + // return restResponseService; + + sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); + if (restResponseService.getErrorCode() == 200) { + restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1, + LifeCycleStatesEnum.STARTCERTIFICATION); + } else + return restResponseService; + if (restResponseService.getErrorCode() == 200) { + restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1, + LifeCycleStatesEnum.CERTIFY); + } + return restResponseService; + } + + protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion, + User user) throws Exception { + return raiseResourceToTargetVersion(resourceDetails, targetVersion, null, user); + } + + protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion, + RestResponse prevResponse, User user) throws Exception { + + String[] splitParts = targetVersion.split("\\."); + + int version = Integer.parseInt(splitParts[1]); + String checkinComment = "good checkin"; + String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}"; + + if (prevResponse != null) { + Resource resourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(prevResponse.getResponse()); + if (resourceRespJavaObject.getLifecycleState().equals(LifecycleStateEnum.CERTIFIED)) { + RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, + user.getUserId(), LifeCycleStatesEnum.CHECKOUT); + } + } + + RestResponse restResponseResource = null; + for (int i = 0; i < (version - 1); i++) { + + restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null, + LifeCycleStatesEnum.CHECKIN, checkinComentJson); + if (restResponseResource.getErrorCode() == 200) { + restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(), + LifeCycleStatesEnum.CHECKOUT); + if (restResponseResource.getErrorCode() == 200) { + + } else + break; + + } else + break; + + } + + restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null, + LifeCycleStatesEnum.CHECKIN, checkinComentJson); + assertEquals("Check response code ", 200, restResponseResource.getErrorCode().intValue()); + return restResponseResource; + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java index 6a4fa3ba55..99caea6863 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java @@ -20,26 +20,11 @@ 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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; @@ -48,1431 +33,1432 @@ 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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + 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; + 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(); + @Rule + public static TestName name = new TestName(); - public ChangeServiceInstanceVersionTest() { - super(name, ChangeServiceInstanceVersionTest.class.getName()); - } + 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(); - } + @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); + 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); - } + // 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 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 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); + @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)); - } + // 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); - /* + // 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)); - } + // 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)); - } + // 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 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); + @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); + // 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 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 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); - } + @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); + // 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); - } + @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); - } + // 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 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 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 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 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 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); - } + @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 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, + 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; - } + if (restResponse.getErrorCode() == 200) {*/ + restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, + 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); + 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); + createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, computeResource, + sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); + String toCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance); - RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, - sdncDesignerDetails, resource.getUniqueId()); - ResourceRestUtils.checkSuccess(response); + RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, + sdncDesignerDetails, resource.getUniqueId()); + ResourceRestUtils.checkSuccess(response); - String capOwnerId = toCompInstId; - User user = sdncDesignerDetails; - ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE; + String capOwnerId = toCompInstId; + User user = sdncDesignerDetails; + ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE; - fulfillCpRequirement(resource, fromCompInstId, toCompInstId, capOwnerId, user, containerCompType); + fulfillCpRequirement(resource, fromCompInstId, toCompInstId, capOwnerId, user, containerCompType); - RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource); - ResourceRestUtils.checkSuccess(changeResourceStateToCertified); - } + RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource); + ResourceRestUtils.checkSuccess(changeResourceStateToCertified); + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java index 623b29b8e6..1e1a197e40 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java @@ -20,12 +20,8 @@ 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 com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import org.junit.rules.TestName; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.category.CategoryDefinition; @@ -40,8 +36,11 @@ 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; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE; public abstract class ProductBaseTest extends ComponentBaseTest { User productStrategistUser1; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java index 1820315841..94027bd6eb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java @@ -20,8 +20,6 @@ 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; @@ -42,6 +40,8 @@ import org.openecomp.sdc.common.api.Constants; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static org.testng.AssertJUnit.assertEquals; + public class ProductCheckinTest extends ProductLifecycleTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java index ec1f7ad38d..36458d09f9 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java @@ -20,10 +20,6 @@ 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; @@ -43,6 +39,10 @@ import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.io.FileNotFoundException; + +import static org.testng.AssertJUnit.assertEquals; + public class ProductCheckoutTest extends ProductLifecycleTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java index 596825875d..f9ce315ebf 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java @@ -20,20 +20,6 @@ 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; @@ -52,1124 +38,1124 @@ 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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + 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 { - serviceDetails_01.setName(null); - String expectedServiceInstanceName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + " 1"; - String expectedServiceInstancenormalizedName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + "1"; - 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 = "cier-TYUIOP_asd_0987654321.Abcd"; - String ExpectedNormalizName = "ciertyuiop_asd_0987654321abcd"; - 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 = "Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456"; - 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("1024"); - 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() + "1").toLowerCase(), instanceNormalizedName); - assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 1"), 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 (enabled = false) - 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); + 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 { + serviceDetails_01.setName(null); + String expectedServiceInstanceName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + " 1"; + String expectedServiceInstancenormalizedName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + "1"; + 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 = "cier-TYUIOP_asd_0987654321.Abcd"; + String ExpectedNormalizName = "ciertyuiop_asd_0987654321abcd"; + 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 = "Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456"; + 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("1024"); + 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() + "1").toLowerCase(), instanceNormalizedName); + assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 1"), 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(enabled = false) + 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); - } - } + if (restResponse.getErrorCode() == 200) {*/ + RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFY); + if (restResponse.getErrorCode() == 200) { + String newVersion = ResponseParser.getVersionFromResponse(restResponse); + resourceDetails.setVersion(newVersion); + resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED); + resourceDetails.setLastUpdaterUserId(sdncDesignerDetails.getUserId()); + resourceDetails.setLastUpdaterFullName(sdncDesignerDetails.getFullName()); + String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId"); + resourceDetails.setUniqueId(uniqueIdFromRresponse); + } return restResponse; - } +} - private RestResponse changeServiceStateToCertified(ServiceReqDetails serviceDetails) throws Exception { + 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); - - } + 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/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java index 2796fa8403..a0a961dd8e 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java @@ -20,11 +20,6 @@ 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; @@ -48,6 +43,11 @@ import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils; import org.openecomp.sdc.common.api.Constants; import org.testng.annotations.Test; +import java.util.Arrays; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + public class ProductCreateWithValidationsTest extends ProductBaseTest { @Rule public static TestName name = new TestName(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java index 88c0f4d3bb..e22318eda7 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java @@ -20,15 +20,10 @@ 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 com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -45,11 +40,7 @@ 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.ResponseParser; +import org.openecomp.sdc.ci.tests.utils.rest.*; 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; @@ -58,10 +49,14 @@ 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; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; public class ProductCrudTest extends ProductBaseTest { private static Logger log = LoggerFactory.getLogger(ProductCrudTest.class.getName()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java index 26bb3e29e9..7404e8e8a6 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java @@ -20,8 +20,6 @@ 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; @@ -32,6 +30,8 @@ import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.testng.annotations.BeforeMethod; +import static org.testng.AssertJUnit.assertEquals; + public abstract class ProductLifecycleTest extends ProductBaseTest { protected static final String CHECKIN_ACTION = "Checkin"; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java index 479dbb9436..fd59f8ed33 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java @@ -20,12 +20,6 @@ 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; @@ -34,25 +28,18 @@ 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.*; 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; +import org.openecomp.sdc.ci.tests.utils.rest.*; + +import java.io.IOException; + +import static org.junit.Assert.*; public class ProductTestBase extends ProductBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java index 412e6fd92d..0c74f255fd 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java @@ -20,10 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.product; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - +import com.google.gson.Gson; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.model.ArtifactUiDownloadData; @@ -31,7 +28,9 @@ 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; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; public class ProductToscaYamlGenerationTest extends ProductTestBase { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java index d4bfb62377..4bd1dffeff 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java @@ -20,11 +20,6 @@ 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; @@ -44,6 +39,11 @@ import org.openecomp.sdc.common.api.Constants; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.io.FileNotFoundException; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNull; + public class ProductUndoCheckoutTest extends ProductLifecycleTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java index 1cf16978e4..ff9d3e6d42 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java @@ -20,18 +20,9 @@ package org.openecomp.sdc.ci.tests.execute.property; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; import org.json.simple.parser.JSONParser; import org.junit.Rule; import org.junit.rules.TestName; @@ -49,29 +40,25 @@ 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.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest; import org.openecomp.sdc.ci.tests.utils.Utils; 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.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.rest.*; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.*; public class AdditionalInformationServletTest extends ComponentBaseTest { @@ -534,8 +521,9 @@ public class AdditionalInformationServletTest extends ComponentBaseTest { String vendorRelease = "0.1"; String contactId = "al1976"; String icon = "myIcon"; + String instantiationType = ServiceInstantiationType.A_LA_CARTE.getValue(); - return new ServiceReqDetails(serviceName, category, tags, description, contactId, icon); + return new ServiceReqDetails(serviceName, category, tags, description, contactId, icon, instantiationType); } // TODO Tal: Since Cashing change partial resource returned that causes null @@ -549,14 +537,14 @@ public class AdditionalInformationServletTest extends ComponentBaseTest { AssertJUnit.assertEquals("Check response code after create user", 200, checkInResponse.getErrorCode().intValue()); Resource resourceAfterOperation = gson.fromJson(checkInResponse.getResponse(), Resource.class); - // TODO Tal: Since Cashing change partial resource returned that causes + /*// TODO Tal: Since Cashing change partial resource returned that causes // null pointer exception - /* + *//* * AssertJUnit.assertEquals("check size of additional information", 1, resourceAfterOperation.getAdditionalInformation().size()); - */ - /* + *//* + *//* * AssertJUnit.assertEquals("check size of additional information", numberOfAI, resourceAfterOperation.getAdditionalInformation().get(0). getParameters().size()); - */ + *//* RestResponse req4certResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); @@ -566,12 +554,12 @@ public class AdditionalInformationServletTest extends ComponentBaseTest { resourceAfterOperation = gson.fromJson(req4certResponse.getResponse(), Resource.class); // TODO Tal: Since Cashing change partial resource returned that causes // null pointer exception - /* + *//* * AssertJUnit.assertEquals("check size of additional information", 1, resourceAfterOperation.getAdditionalInformation().size()); - */ - /* + *//* + *//* * AssertJUnit.assertEquals("check size of additional information", numberOfAI, resourceAfterOperation.getAdditionalInformation().get(0). getParameters().size()); - */ + *//* // change modifier user.setUserId(UserRoleEnum.TESTER.getUserId()); @@ -584,10 +572,10 @@ public class AdditionalInformationServletTest extends ComponentBaseTest { resourceAfterOperation = gson.fromJson(startCertResourceResponse3.getResponse(), Resource.class); // TODO Tal: Since Cashing change partial resource returned that causes // null pointer exception - /* + *//* * AssertJUnit.assertEquals("check size of additional information", 1, resourceAfterOperation.getAdditionalInformation().size()); - */ - /* + *//* + *//* * AssertJUnit.assertEquals("check size of additional information", numberOfAI, resourceAfterOperation.getAdditionalInformation().get(0). getParameters().size()); */ @@ -1253,9 +1241,9 @@ public class AdditionalInformationServletTest extends ComponentBaseTest { assertNotNull("check error code exists in response after create property", checkInResponse.getErrorCode()); assertEquals("Check response code after create property", 200, checkInResponse.getErrorCode().intValue()); - RestResponse changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST, null); - changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION, null); - changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFY, null); + /*RestResponse changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST, null); + changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION, null);*/ + RestResponse changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFY, null); assertNotNull("check response object is not null after create property", checkInResponse); assertNotNull("check error code exists in response after create property", checkInResponse.getErrorCode()); @@ -1960,11 +1948,11 @@ public class AdditionalInformationServletTest extends ComponentBaseTest { // response = LCSbaseTest.certifyResource(resourceDetails); RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CHECKIN); assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200); - restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + /*restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200); restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterUser, LifeCycleStatesEnum.STARTCERTIFICATION); - assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200); - restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterUser, LifeCycleStatesEnum.CERTIFY); + assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200);*/ + restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CERTIFY); assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200); // add resource instance with HEAT deployment artifact to the service diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java index 6ba1b2ccca..5385eb94f6 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java @@ -20,11 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.property; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.List; - +import fj.data.Either; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; @@ -35,11 +31,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; @@ -49,7 +41,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import fj.data.Either; +import java.util.ArrayList; +import java.util.List; + +import static org.testng.AssertJUnit.assertTrue; // open bug for this class: DE199108 - closed, DE199741 public class ComponentInstancePropertyTest extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java index 7ecdcf457f..8bb637e8dc 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java @@ -20,14 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.property; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -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; @@ -37,11 +29,7 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; @@ -53,6 +41,14 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + public class ComponentProperty extends ComponentBaseTest { @Rule diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java index f6f6f23214..21e188649d 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java @@ -20,14 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.property; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.json.simple.JSONObject; import org.json.simple.JSONValue; import org.junit.Rule; @@ -55,6 +47,10 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.*; + +import static org.testng.AssertJUnit.assertTrue; + public class PropertyApisTest extends SimpleOneRsrcOneServiceTest { protected static final String RESOURCE_CATEGORY = "Generic/Databases"; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java index 85dfe4e13a..6bae08b2bd 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java @@ -20,14 +20,13 @@ package org.openecomp.sdc.ci.tests.execute.resource; +import fj.data.Either; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.common.util.SerializationUtils; -import fj.data.Either; - public class CheckGetResource { public void checkGetVmmsc6() throws Exception { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java index 675a5883bb..4e2a521b3c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java @@ -20,33 +20,12 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - import org.apache.http.client.ClientProtocolException; 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.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.CapReqDef; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.RelationshipImpl; -import org.openecomp.sdc.be.model.RelationshipInfo; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; @@ -55,15 +34,20 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; 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.ComponentInstanceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS; +import static org.testng.AssertJUnit.*; + public class ComponentRelationshipInVfTest extends ComponentBaseTest { public ComponentRelationshipInVfTest() { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java index efa8393548..0549eaa042 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java @@ -20,16 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -41,17 +32,8 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; -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.ResourceRespJavaObject; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; @@ -60,13 +42,7 @@ 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.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.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.rest.*; 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.ResourceValidationUtils; @@ -74,7 +50,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.util.*; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; /** * @author yshlosberg @@ -2021,7 +2001,7 @@ public class CreateResourceApiTest extends ComponentBaseTest { assertEquals(invariantUUIDcreation, invariantUUIDcheckout); assertEquals(version, "0.2"); - // do certification request + /*// do certification request RestResponse restResponseCertificationRequest = LifecycleRestUtils.changeResourceState(resourceDetails, sdncUserDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); BaseRestUtils.checkSuccess(restResponseCertificationRequest); @@ -2041,7 +2021,7 @@ public class CreateResourceApiTest extends ComponentBaseTest { String invariantUUIDStartCertification = startCertificationRequestResource.getInvariantUUID(); version = startCertificationRequestResource.getVersion(); assertEquals(invariantUUIDcreation, invariantUUIDStartCertification); - assertEquals(version, "0.2"); + assertEquals(version, "0.2");*/ // certify RestResponse restResponseCertify = LifecycleRestUtils.changeResourceState(resourceDetails, sdncUserDetails, @@ -2075,7 +2055,8 @@ public class CreateResourceApiTest extends ComponentBaseTest { ResourceReqDetails resourceDetails = ElementFactory.getDefaultResourceByType("VF200", NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, designerUser.getUserId(), ResourceTypeEnum.VF.toString()); ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("newtestservice1", - ServiceCategoriesEnum.MOBILITY, designerUser.getUserId()); + ServiceCategoriesEnum.MOBILITY, designerUser.getUserId(), + ServiceInstantiationType.A_LA_CARTE.getValue()); // ResourceReqDetails resourceDetails = // ElementFactory.getDefaultResource(); @@ -2115,7 +2096,7 @@ public class CreateResourceApiTest extends ComponentBaseTest { assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse)); getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation); - // certification request + /*// certification request restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); @@ -2126,9 +2107,9 @@ public class CreateResourceApiTest extends ComponentBaseTest { LifeCycleStatesEnum.STARTCERTIFICATION); assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse)); - getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation); + getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation);*/ // certify - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUser, LifeCycleStatesEnum.CERTIFY); + restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser, LifeCycleStatesEnum.CERTIFY); assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse)); getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation); @@ -2143,11 +2124,11 @@ public class CreateResourceApiTest extends ComponentBaseTest { assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, updateResponse.getErrorCode().intValue()); getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation); - // certification request + /*// certification request restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); - getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation); + getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);*/ // checkout resource restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser, @@ -2155,7 +2136,7 @@ public class CreateResourceApiTest extends ComponentBaseTest { assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation); - // certification request + /*// certification request restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); @@ -2182,7 +2163,7 @@ public class CreateResourceApiTest extends ComponentBaseTest { restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUser, LifeCycleStatesEnum.FAILCERTIFICATION); assertEquals(STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue()); - getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation); + getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);*/ // upload artifact restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser, diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java index a3372098a0..1b58c4e235 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java @@ -20,13 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - import org.junit.rules.TestName; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; @@ -48,6 +41,13 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + public class GetAllResourceVersions extends ComponentBaseTest { private static Logger logger = LoggerFactory.getLogger(GetAllResourceVersions.class.getName()); @@ -151,14 +151,14 @@ public class GetAllResourceVersions extends ComponentBaseTest { resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); AssertJUnit.assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + /*checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); AssertJUnit.assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION); AssertJUnit.assertEquals("Check response code after checkout resource", 200, - checkoutResource.getErrorCode().intValue()); + checkoutResource.getErrorCode().intValue());*/ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY); AssertJUnit.assertEquals("Check response code after checkout resource", 200, @@ -292,12 +292,12 @@ public class GetAllResourceVersions extends ComponentBaseTest { checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, +/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); @@ -317,12 +317,12 @@ public class GetAllResourceVersions extends ComponentBaseTest { } // resource version 2.0 - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, +/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); @@ -384,9 +384,9 @@ public class GetAllResourceVersions extends ComponentBaseTest { checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + /*checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ // validate get response RestResponse resourceGetResponse = ResourceRestUtils.getResource(designerDetails, @@ -399,7 +399,7 @@ public class GetAllResourceVersions extends ComponentBaseTest { @Test public void getResourceAllVersions_CertifactionInProgress_version05() throws Exception { - Map<String, String> origVersionsMap = new HashMap<String, String>(); + Map<String, String> origVersionsMap = new HashMap<>(); // create resource RestResponse restResponse = createResource(designerDetails, resourceDetails); assertTrue("create request returned status:" + restResponse.getErrorCode(), restResponse.getErrorCode() == 201); @@ -430,12 +430,12 @@ public class GetAllResourceVersions extends ComponentBaseTest { checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, +/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ // validate get response RestResponse resourceGetResponse = ResourceRestUtils.getResource(designerDetails, @@ -476,12 +476,12 @@ public class GetAllResourceVersions extends ComponentBaseTest { checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, +/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); @@ -525,12 +525,12 @@ public class GetAllResourceVersions extends ComponentBaseTest { checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, +/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); @@ -549,12 +549,12 @@ public class GetAllResourceVersions extends ComponentBaseTest { } // get to version 1.0 - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, +/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY); assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java index ccf6142538..126aabdd03 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java @@ -20,16 +20,10 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.model.User; @@ -50,10 +44,10 @@ 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; +import java.util.*; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; public class GetResourceNotAbstractApiTest extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java index df8ff58ba8..1b50e7f1c2 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java @@ -20,14 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - +import com.google.gson.Gson; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -58,7 +51,11 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static org.testng.AssertJUnit.*; public class ResourceApiTest extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java index f4a4fa108a..8b8c6533cb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java @@ -20,14 +20,14 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import java.io.IOException; - import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.testng.ITestContext; import org.testng.annotations.DataProvider; +import java.io.IOException; + public class SampleDataProvider { @DataProvider diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java index 3002523ccb..df72d355be 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java @@ -20,10 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; @@ -35,6 +31,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.testng.annotations.Test; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + public class SimultaneousApiTest extends ComponentBaseTest { protected static ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java index 2b84af9f1d..bfd64c34f7 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java @@ -20,18 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; import org.json.JSONException; import org.json.JSONObject; import org.junit.rules.TestName; @@ -44,12 +33,7 @@ import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; @@ -70,54 +54,57 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.io.FileNotFoundException; +import java.util.*; + +import static org.testng.AssertJUnit.*; public class UpdateResourceMetadataTest extends ComponentBaseTest { - private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName()); - protected List<String> Empty_List = new ArrayList<String>(); - protected String extendedChars; + private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName()); + protected List<String> Empty_List = new ArrayList<String>(); + protected String extendedChars; - protected final String contentTypeHeaderData = "application/json"; - protected final String acceptHeaderDate = "application/json"; - protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1"; + protected final String contentTypeHeaderData = "application/json"; + protected final String acceptHeaderDate = "application/json"; + protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1"; - public static TestName name = new TestName(); - protected User sdncModifierDetails; - protected ResourceReqDetails resourceDetails; + public static TestName name = new TestName(); + protected User sdncModifierDetails; + protected ResourceReqDetails resourceDetails; - public UpdateResourceMetadataTest() { - super(name, UpdateResourceMetadataTest.class.getName()); + public UpdateResourceMetadataTest() { + super(name, UpdateResourceMetadataTest.class.getName()); - } + } - public String extendedCharsStringBuilder() throws Exception { - char[] extendedCharsArray = new char[128]; - char ch = 128; - for (int i = 0; i < extendedCharsArray.length - 1; i++) { - extendedCharsArray[i] = ch; - ch++; - } - extendedChars = new String(extendedCharsArray); - return extendedChars; + public String extendedCharsStringBuilder() throws Exception { + char[] extendedCharsArray = new char[128]; + char ch = 128; + for (int i = 0; i < extendedCharsArray.length - 1; i++) { + extendedCharsArray[i] = ch; + ch++; + } + extendedChars = new String(extendedCharsArray); + return extendedChars; - } + } - @BeforeMethod - public void setup() throws Exception { - sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - resourceDetails = defineResourse(); + @BeforeMethod + public void setup() throws Exception { + sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + resourceDetails = defineResourse(); - } + } - // Keep - @Test - public void UpdateDerivedFromSuccess() throws Exception { + // Keep + @Test + public void UpdateDerivedFromSuccess() throws Exception { - String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName(); - String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName(); + String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName(); + String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName(); - // Getting both derived from resources for validation - /* + // Getting both derived from resources for validation + /* * RestResponse resourceByNameAndVersion = * resourceUtils.getResourceByNameAndVersion(sdncModifierDetails, * oldDerivedFromName, "1.0"); @@ -135,1181 +122,1181 @@ public class UpdateResourceMetadataTest extends ComponentBaseTest { * resourceUtils.parseResourceResp(resourceByNameAndVersion); */ - // Derived from set to Database - List<String> derivedFrom = new ArrayList<>(); - derivedFrom.add(oldDerivedFromName); - resourceDetails.setDerivedFrom(derivedFrom); - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - AssertJUnit.assertEquals("Check response code after create resource", 201, - restResponse.getErrorCode().intValue()); - Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); - - derivedFrom.clear(); - derivedFrom.add(newDerivedFromName); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, currentResource.getUniqueId(), ""); - AssertJUnit.assertEquals("Check response code after create resource", 200, - updatedRestResponse.getErrorCode().intValue()); - - } - - protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) { - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName()); - - updatedResourceDetails.setVersion("mumu"); - updatedResourceDetails.setIsAbstract(true); - updatedResourceDetails.setIsHighestVersion(true); - updatedResourceDetails.setCreatorUserId("df4444"); - updatedResourceDetails.setCreatorFullName("John Doe"); - updatedResourceDetails.setLastUpdaterUserId("gf5646"); - updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy"); - updatedResourceDetails.setCreationDate(new Long(4444)); - updatedResourceDetails.setLastUpdateDate(new Long("534535")); - updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION); - updatedResourceDetails.setCost("6.1"); - updatedResourceDetails.setLicenseType("Installation"); - updatedResourceDetails.setUUID("dfsfsdf"); - return updatedResourceDetails; - } - - public void UpdateResourceNotFoundTest() throws Exception { - // init ADMIN user - User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - - String resourceName = "cisco4"; - // update resource - String description = "updatedDescription"; - ArrayList<String> resourceTags = new ArrayList<String>(); - resourceTags.add("tag2"); - String category = ServiceCategoriesEnum.MOBILITY.getValue(); - ArrayList<String> derivedFrom = new ArrayList<String>(); - derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName()); - String vendorName = "newOracle"; - String vendorRelease = "2.5"; - String contactId = "jh0003"; - String icon = "myICON"; - - ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, - category, derivedFrom, vendorName, vendorRelease, contactId, icon); - updatedResourceDetails.setUniqueId("dummyId"); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, "0.1"); - - // validate response - AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); - AssertJUnit.assertNotNull("check error code exists in response after update resource", - updatedRestResponse.getErrorCode()); - AssertJUnit.assertEquals("Check response code after update resource", 404, - updatedRestResponse.getErrorCode().intValue()); - // String resourceId = - // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1"); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), - updatedRestResponse.getResponse()); - - resourceName = ""; - // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName, - // "0.1"); - updatedResourceDetails = defineUpdatedResourse(resourceName); - updatedResourceDetails.setUniqueId("dummyId"); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - "0.1"); - AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); - AssertJUnit.assertNotNull("check error code exists in response after update resource", - updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), - updatedRestResponse.getResponse()); - - } - - public char[] getInValidChars() throws Exception { - - char[] extendedCharsArray = new char[59]; - char ch = 1; - for (int i = 0; i < 44; i++) { - extendedCharsArray[i] = ch; - ch++; - } - ch = 58; - for (int i = 44; i < 51; i++) { - extendedCharsArray[i] = ch; - ch++; - } - ch = 91; - for (int i = 51; i < 55; i++) { - extendedCharsArray[i] = ch; - ch++; - } - ch = 123; - for (int i = 55; i < 59; i++) { - extendedCharsArray[i] = ch; - ch++; - } - return extendedCharsArray; - } - - public char[] getTagInValidFormatChars() throws Exception { - // Tag format is the same as defined for "Resource Name" : - // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore - // ('_'), dash ('-'), dot ('.') - char[] notValidCharsArray = new char[30]; - char ch = 33; - for (int i = 0; i < 12; i++) { - notValidCharsArray[i] = ch; - ch++; - } - notValidCharsArray[13] = 47; - ch = 58; - for (int i = 14; i < 21; i++) { - notValidCharsArray[i] = ch; - ch++; - } - ch = 91; - for (int i = 21; i < 24; i++) { - notValidCharsArray[i] = ch; - ch++; - } - notValidCharsArray[24] = 96; - ch = 123; - for (int i = 25; i < 30; i++) { - notValidCharsArray[i] = ch; - ch++; - } - return notValidCharsArray; - } - - public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception { - // init ADMIN user - User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - - // define and create resource - ResourceReqDetails resourceDetails = defineResourse(); - ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1"); - ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0"); - ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1"); - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceId = resourceDetails.getUniqueId(); - resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); - - // build Json Object - JSONObject jsonObject = JsonObjectBuilder(resourceDetails); - - List<String> resource = new ArrayList<>(); - resource.add("Resource"); - - // remove Description - UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description", - ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource); - // remove Tags - UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags", - ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List); - // remove Category - UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category", - ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource); - // remove VendorName - UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName", - ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List); - // remove VendorRelease - UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease", - ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List); - // remove AT&T Contact - UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId", - ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1"); - // validate response - AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse); - AssertJUnit.assertNotNull("check error code exists in response after get resource", - getRestResponse.getErrorCode()); - AssertJUnit.assertEquals("Check response code after update resource", 200, - getRestResponse.getErrorCode().intValue()); - - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1"); - ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0"); - ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1"); - } - - // End of validation tests - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - protected ResourceReqDetails defineUpdatedResourse(String resourceName) { - String description = "updatedDescription"; - ArrayList<String> resourceTags = new ArrayList<String>(); - // Duplicate tags are allowed and should be de-duplicated by server side - resourceTags.add(resourceName); - resourceTags.add("tag1"); - resourceTags.add("tag1"); - resourceTags.add("tag2"); - resourceTags.add("tag2"); - String category = ServiceCategoriesEnum.VOIP.getValue(); - ArrayList<String> derivedFrom = new ArrayList<String>(); - derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName()); - String vendorName = "updatedOracle"; - String vendorRelease = "3.5"; - String contactId = "jh0001"; - String icon = "myUpdatedICON"; - - ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category, - derivedFrom, vendorName, vendorRelease, contactId, icon); - resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), - ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory()); - - return resourceDetails; - } - - protected ResourceReqDetails defineResourse() { - String resourceName = "cisco4"; - String description = "description"; - ArrayList<String> resourceTags = new ArrayList<String>(); - resourceTags.add(resourceName); - ArrayList<String> derivedFrom = new ArrayList<String>(); - derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root"); - String vendorName = "Oracle"; - String vendorRelease = "1.5"; - String contactId = "jh0003"; - String icon = "objectStorage"; - - ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null, - derivedFrom, vendorName, vendorRelease, contactId, icon); - resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), - ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory()); - - return resourceDetails; - } - - protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails) - throws Exception { - // clean ES DB - DbUtils.cleanAllAudits(); - - // create resource - RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails); - - // validate response - AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse); - AssertJUnit.assertNotNull("check error code exists in response after create resource", - restResponse.getErrorCode()); - AssertJUnit.assertEquals("Check response code after create resource", 201, - restResponse.getErrorCode().intValue()); - - return restResponse; - } - - protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails, - String uri) throws Exception { - // delete resource - Config config; - RestResponse ResourceResponse; - try { - config = Utils.getConfig(); - Map<String, String> headersMap = new HashMap<String, String>(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); - headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); - HttpRequest http = new HttpRequest(); - String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(), - config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1"); - - if (uri == "GET") { - ResourceResponse = http.httpSendGet(url, headersMap); - } else if (uri == "POST") { - Gson gson = new Gson(); - String userBodyJson = gson.toJson(updatedResourceDetails); - ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap); - } else if (uri == "DELETE") { - ResourceResponse = http.httpSendDelete(url, headersMap); - } else - return null; - - return ResourceResponse; - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - - return null; - - } - - protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException { - // json object: resourceName and icon are must - JSONObject jObject = new JSONObject(); - - List<String> tagsList = Arrays.asList(resourceDetails.getName()); - List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]"); - - jObject.put("name", resourceDetails.getName()); - jObject.put("description", "updatedDescription"); - jObject.put("tags", tagsList); - jObject.put("category", ServiceCategoriesEnum.VOIP.getValue()); - jObject.put("derivedFrom", derivedFromList); - jObject.put("vendorName", "newOracle"); - jObject.put("vendorRelease", "1.5"); - jObject.put("contactId", "jh0003"); - jObject.put("icon", resourceDetails.getIcon()); - - return jObject; - } - - protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) { - jObject.remove(removedPropery); - - return jObject; - } - - // purpose: function for controlling json body fields and validating - // response - protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject, - String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception { - - JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject)); - // remove description from jsonObject - jObject = RemoveFromJsonObject(jObject, removedField); - // update with incomplete body. - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(), - sdncModifierDetails, resourceId); - // validate response - AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); - AssertJUnit.assertNotNull("check error code exists in response after update resource", - updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse()); - - } - - // purpose: function for validating error response - protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails, - String recievedMessage, List<String> variables) throws Exception { - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, "0.1"); - // validate response - AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); - AssertJUnit.assertNotNull("check error code exists in response after update resource", - updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse()); - - } - - protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse) - throws Exception { - // parse response to javaObject - Resource updatedResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); - AssertJUnit.assertTrue( - !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion())); - AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName())); - AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract())); - AssertJUnit.assertTrue( - !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId())); - AssertJUnit.assertTrue( - !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName())); - AssertJUnit.assertTrue( - !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate())); - AssertJUnit - .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate())); - AssertJUnit.assertTrue( - !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId())); - AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName() - .equals(updatedResourceRespJavaObject.getLastUpdaterFullName())); - AssertJUnit.assertTrue( - !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState())); - AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost())); - AssertJUnit - .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType())); - AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID())); - - } - - protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse) - throws Exception { - // parse response to javaObject - Resource updatedResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); - // validate request vs response - ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject); - } - - public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails, - String resourceVersion) { - - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject(); - - expectedResourceAuditJavaObject.setAction("Checkout"); - expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId()); - expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName()); - expectedResourceAuditJavaObject.setStatus("200.0"); - expectedResourceAuditJavaObject.setDesc("OK"); - expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase()); - expectedResourceAuditJavaObject.setResourceType("Resource"); - expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f)); - expectedResourceAuditJavaObject.setCurrVersion(resourceVersion); - expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - - return expectedResourceAuditJavaObject; - - } - - public enum FieldToValidate { - contactId, Tags, VendorName, VendorRelease, Description - } - - @Test - public void UpdateBy_postTest() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // update resource - without changing resourceName - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - - RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST"); - - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, - updatedRestResponse.getResponse()); - - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(resourceDetails, getRestResponse); - - } - - @Test - public void UpdateBy_getTest() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // update resource - without changing resourceName - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET"); - - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, - updatedRestResponse.getResponse()); - - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(resourceDetails, getRestResponse); - - } - - @Test - public void UpdateBy_deleteTest() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // update resource - without changing resourceName - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, - "DELETE"); - - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, - updatedRestResponse.getResponse()); - - RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(resourceDetails, getRestResponse); - - } - - // TODO DE - // @Ignore("") - @Test - public void UpdateWithInvaldJsonBodyTest() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); - String resourceId = resourceDetails.getUniqueId(); - - // update Descirption value - String description = "updatedDescription"; - - // send update with incompleted json, only description string - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails, - resourceId); - - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue()); - - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(resourceDetails, getRestResponse); - - } - - // @Test - // public void UpdateResourceModifierNotOwnerStateTest() throws Exception { - // - // - // RestResponse restResponse = createResource(sdncModifierDetails, - // resourceDetails); - // String resourceName = resourceDetails.getName(); - // - // // new user parameters - // String userFirstName = "Kot"; - // String userLastName = "Matroskin"; - // String role = "ADMIN"; - // User sdncUserDetails = new User(userFirstName, userLastName, - // httpCspUserId, email, role,null); - // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails, - // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN)); - // - // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails, - // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN)); - // - // User updatedSdncModifierDetails = new User(userFirstName, userLastName, - // httpCspUserId, email,role,null); - // ResourceReqDetails updatedResourceDetails = - // defineUpdatedResourse(resourceName); - // RestResponse updatedRestResponse = - // ResourceRestUtils.updateResource(updatedResourceDetails, - // updatedSdncModifierDetails, resourceDetails.getUniqueId(), ""); - // - // // validate response - // assertNotNull("check response object is not null after update resource", - // updatedRestResponse); - // assertNotNull("check error code exists in response after update - // resource", updatedRestResponse.getErrorCode()); - // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), - // Empty_List, updatedRestResponse.getResponse()); - // - // RestResponse getRestResponse = - // ResourceRestUtils.getResource(sdncModifierDetails, - // resourceDetails.getUniqueId()); - // assertNotNull("check response object is not null after update resource", - // getRestResponse); - // parseResponseAndValidate(resourceDetails, getRestResponse); - // - // - // } - - @Test - public void UpdateResourceNameSensitiveTest() throws Exception { - User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - String resourceName = "Ab"; - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - // Delete resources - RestResponse response = null; - response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, - updatedResourceDetails.getName(), "0.1"); - BaseRestUtils.checkDeleteResponse(response); - response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, - updatedResourceDetails.getName(), "0.2"); - BaseRestUtils.checkDeleteResponse(response); - - RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails); - assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue()); - - // check-in Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, - sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - // String resourceCertifyVersion = "0.1"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - updatedResourceDetails.setName("ABC_-bt.aT"); - ArrayList<String> resourceTag = new ArrayList<String>(); - resourceTag.add(0, "ABC_-bt.aT"); - updatedResourceDetails.setTags(resourceTag); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, updatedResourceDetails.getUniqueId(), ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(updatedResourceDetails, updatedRestResponse); - - // Delete resources - response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, - updatedResourceDetails.getName(), "0.1"); - BaseRestUtils.checkDeleteResponse(response); - response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, - updatedResourceDetails.getName(), "0.2"); - BaseRestUtils.checkDeleteResponse(response); - - } - - @Test - public void UpdateIcon_InegativeFlow() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - List<String> resourceList = new ArrayList<String>(); - resourceList.add(0, "Resource"); - // check InValid Characters - char[] notValidCharsArray = new char[59]; - notValidCharsArray = getInValidChars(); - // update metadata details - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - RestResponse updatedRestResponse; - - for (int i = 0; i < notValidCharsArray.length; i++) { - // change icon of metadata - updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]); - // PUT request - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", - updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList, - updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource icon", 400, - updatedRestResponse.getErrorCode().intValue()); - assertEquals("Check response code after updating resource icon", "Bad Request", - updatedRestResponse.getResponseMessage().toString()); - - } - - // empty icon - String updateIcon = ""; - updatedResourceDetails.setIcon(updateIcon); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList, - updatedRestResponse.getResponse()); - - // Icon length more then 25 characters - resourceList.add(1, "25"); - updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN"); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList, - updatedRestResponse.getResponse()); - assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue()); - assertEquals("Check response code after updating resource icon", "Bad Request", - updatedRestResponse.getResponseMessage().toString()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - } - - @Test - public void UpdateResource_NoTagsEqualToResourceName() throws Exception { - - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - ResourceReqDetails updatedResourceDetails = defineResourse(); - updatedResourceDetails.setName("updatedResourceName"); - List<String> tags = updatedResourceDetails.getTags(); - - for (Iterator<String> iter = tags.listIterator(); iter.hasNext();) { - String a = iter.next(); - if (a.equals("updatedResourceName")) { - iter.remove(); - } - } - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - List<String> resourceList = new ArrayList<String>(); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(), - resourceList, updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource icon", 400, - updatedRestResponse.getErrorCode().intValue()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - } - - @Test - public void UpdateResourceName_negativeFlow() throws Exception { - // The validation are done in Tag's validation - User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - - RestResponse updatedRestResponse; - RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails); - assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue()); - String uniqueId = resourceDetails.getUniqueId(); - String resourceName = resourceDetails.getName(); - // check InValid Characters - char[] notValidCharsArray = new char[59]; - notValidCharsArray = getInValidChars(); - ArrayList<String> resource_Name = new ArrayList<String>(); - List<String> resourceList = new ArrayList<String>(); - - ArrayList<String> resourceTags = new ArrayList<String>(); - resourceList.add(0, "Resource"); - - // update metadata details - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) { - if (i != 1 && i != 46 - && /* + // Derived from set to Database + List<String> derivedFrom = new ArrayList<>(); + derivedFrom.add(oldDerivedFromName); + resourceDetails.setDerivedFrom(derivedFrom); + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + AssertJUnit.assertEquals("Check response code after create resource", 201, + restResponse.getErrorCode().intValue()); + Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); + + derivedFrom.clear(); + derivedFrom.add(newDerivedFromName); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, currentResource.getUniqueId(), ""); + AssertJUnit.assertEquals("Check response code after create resource", 200, + updatedRestResponse.getErrorCode().intValue()); + + } + + protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) { + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName()); + + updatedResourceDetails.setVersion("mumu"); + updatedResourceDetails.setIsAbstract(true); + updatedResourceDetails.setIsHighestVersion(true); + updatedResourceDetails.setCreatorUserId("df4444"); + updatedResourceDetails.setCreatorFullName("John Doe"); + updatedResourceDetails.setLastUpdaterUserId("gf5646"); + updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy"); + updatedResourceDetails.setCreationDate(new Long(4444)); + updatedResourceDetails.setLastUpdateDate(new Long("534535")); + updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION); + updatedResourceDetails.setCost("6.1"); + updatedResourceDetails.setLicenseType("Installation"); + updatedResourceDetails.setUUID("dfsfsdf"); + return updatedResourceDetails; + } + + public void UpdateResourceNotFoundTest() throws Exception { + // init ADMIN user + User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + + String resourceName = "cisco4"; + // update resource + String description = "updatedDescription"; + ArrayList<String> resourceTags = new ArrayList<String>(); + resourceTags.add("tag2"); + String category = ServiceCategoriesEnum.MOBILITY.getValue(); + ArrayList<String> derivedFrom = new ArrayList<String>(); + derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName()); + String vendorName = "newOracle"; + String vendorRelease = "2.5"; + String contactId = "jh0003"; + String icon = "myICON"; + + ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, + category, derivedFrom, vendorName, vendorRelease, contactId, icon); + updatedResourceDetails.setUniqueId("dummyId"); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, "0.1"); + + // validate response + AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); + AssertJUnit.assertNotNull("check error code exists in response after update resource", + updatedRestResponse.getErrorCode()); + AssertJUnit.assertEquals("Check response code after update resource", 404, + updatedRestResponse.getErrorCode().intValue()); + // String resourceId = + // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1"); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), + updatedRestResponse.getResponse()); + + resourceName = ""; + // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName, + // "0.1"); + updatedResourceDetails = defineUpdatedResourse(resourceName); + updatedResourceDetails.setUniqueId("dummyId"); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + "0.1"); + AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); + AssertJUnit.assertNotNull("check error code exists in response after update resource", + updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"), + updatedRestResponse.getResponse()); + + } + + public char[] getInValidChars() throws Exception { + + char[] extendedCharsArray = new char[59]; + char ch = 1; + for (int i = 0; i < 44; i++) { + extendedCharsArray[i] = ch; + ch++; + } + ch = 58; + for (int i = 44; i < 51; i++) { + extendedCharsArray[i] = ch; + ch++; + } + ch = 91; + for (int i = 51; i < 55; i++) { + extendedCharsArray[i] = ch; + ch++; + } + ch = 123; + for (int i = 55; i < 59; i++) { + extendedCharsArray[i] = ch; + ch++; + } + return extendedCharsArray; + } + + public char[] getTagInValidFormatChars() throws Exception { + // Tag format is the same as defined for "Resource Name" : + // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore + // ('_'), dash ('-'), dot ('.') + char[] notValidCharsArray = new char[30]; + char ch = 33; + for (int i = 0; i < 12; i++) { + notValidCharsArray[i] = ch; + ch++; + } + notValidCharsArray[13] = 47; + ch = 58; + for (int i = 14; i < 21; i++) { + notValidCharsArray[i] = ch; + ch++; + } + ch = 91; + for (int i = 21; i < 24; i++) { + notValidCharsArray[i] = ch; + ch++; + } + notValidCharsArray[24] = 96; + ch = 123; + for (int i = 25; i < 30; i++) { + notValidCharsArray[i] = ch; + ch++; + } + return notValidCharsArray; + } + + public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception { + // init ADMIN user + User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + + // define and create resource + ResourceReqDetails resourceDetails = defineResourse(); + ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1"); + ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0"); + ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1"); + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceId = resourceDetails.getUniqueId(); + resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); + + // build Json Object + JSONObject jsonObject = JsonObjectBuilder(resourceDetails); + + List<String> resource = new ArrayList<>(); + resource.add("Resource"); + + // remove Description + UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description", + ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource); + // remove Tags + UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags", + ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List); + // remove Category + UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category", + ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource); + // remove VendorName + UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName", + ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List); + // remove VendorRelease + UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease", + ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List); + // remove AT&T Contact + UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId", + ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1"); + // validate response + AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse); + AssertJUnit.assertNotNull("check error code exists in response after get resource", + getRestResponse.getErrorCode()); + AssertJUnit.assertEquals("Check response code after update resource", 200, + getRestResponse.getErrorCode().intValue()); + + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1"); + ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0"); + ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1"); + } + + // End of validation tests + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + protected ResourceReqDetails defineUpdatedResourse(String resourceName) { + String description = "updatedDescription"; + ArrayList<String> resourceTags = new ArrayList<String>(); + // Duplicate tags are allowed and should be de-duplicated by server side + resourceTags.add(resourceName); + resourceTags.add("tag1"); + resourceTags.add("tag1"); + resourceTags.add("tag2"); + resourceTags.add("tag2"); + String category = ServiceCategoriesEnum.VOIP.getValue(); + ArrayList<String> derivedFrom = new ArrayList<String>(); + derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName()); + String vendorName = "updatedOracle"; + String vendorRelease = "3.5"; + String contactId = "jh0001"; + String icon = "myUpdatedICON"; + + ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category, + derivedFrom, vendorName, vendorRelease, contactId, icon); + resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), + ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory()); + + return resourceDetails; + } + + protected ResourceReqDetails defineResourse() { + String resourceName = "cisco4"; + String description = "description"; + ArrayList<String> resourceTags = new ArrayList<String>(); + resourceTags.add(resourceName); + ArrayList<String> derivedFrom = new ArrayList<String>(); + derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root"); + String vendorName = "Oracle"; + String vendorRelease = "1.5"; + String contactId = "jh0003"; + String icon = "objectStorage"; + + ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null, + derivedFrom, vendorName, vendorRelease, contactId, icon); + resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(), + ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory()); + + return resourceDetails; + } + + protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails) + throws Exception { + // clean ES DB + DbUtils.cleanAllAudits(); + + // create resource + RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails); + + // validate response + AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse); + AssertJUnit.assertNotNull("check error code exists in response after create resource", + restResponse.getErrorCode()); + AssertJUnit.assertEquals("Check response code after create resource", 201, + restResponse.getErrorCode().intValue()); + + return restResponse; + } + + protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails, + String uri) throws Exception { + // delete resource + Config config; + RestResponse ResourceResponse; + try { + config = Utils.getConfig(); + Map<String, String> headersMap = new HashMap<String, String>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); + HttpRequest http = new HttpRequest(); + String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(), + config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1"); + + if (uri == "GET") { + ResourceResponse = http.httpSendGet(url, headersMap); + } else if (uri == "POST") { + Gson gson = new Gson(); + String userBodyJson = gson.toJson(updatedResourceDetails); + ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap); + } else if (uri == "DELETE") { + ResourceResponse = http.httpSendDelete(url, headersMap); + } else + return null; + + return ResourceResponse; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + return null; + + } + + protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException { + // json object: resourceName and icon are must + JSONObject jObject = new JSONObject(); + + List<String> tagsList = Arrays.asList(resourceDetails.getName()); + List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]"); + + jObject.put("name", resourceDetails.getName()); + jObject.put("description", "updatedDescription"); + jObject.put("tags", tagsList); + jObject.put("category", ServiceCategoriesEnum.VOIP.getValue()); + jObject.put("derivedFrom", derivedFromList); + jObject.put("vendorName", "newOracle"); + jObject.put("vendorRelease", "1.5"); + jObject.put("contactId", "jh0003"); + jObject.put("icon", resourceDetails.getIcon()); + + return jObject; + } + + protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) { + jObject.remove(removedPropery); + + return jObject; + } + + // purpose: function for controlling json body fields and validating + // response + protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject, + String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception { + + JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject)); + // remove description from jsonObject + jObject = RemoveFromJsonObject(jObject, removedField); + // update with incomplete body. + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(), + sdncModifierDetails, resourceId); + // validate response + AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); + AssertJUnit.assertNotNull("check error code exists in response after update resource", + updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse()); + + } + + // purpose: function for validating error response + protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails, + String recievedMessage, List<String> variables) throws Exception { + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, "0.1"); + // validate response + AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse); + AssertJUnit.assertNotNull("check error code exists in response after update resource", + updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse()); + + } + + protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse) + throws Exception { + // parse response to javaObject + Resource updatedResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); + AssertJUnit.assertTrue( + !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion())); + AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName())); + AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract())); + AssertJUnit.assertTrue( + !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId())); + AssertJUnit.assertTrue( + !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName())); + AssertJUnit.assertTrue( + !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate())); + AssertJUnit + .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate())); + AssertJUnit.assertTrue( + !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId())); + AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName() + .equals(updatedResourceRespJavaObject.getLastUpdaterFullName())); + AssertJUnit.assertTrue( + !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState())); + AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost())); + AssertJUnit + .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType())); + AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID())); + + } + + protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse) + throws Exception { + // parse response to javaObject + Resource updatedResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); + // validate request vs response + ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject); + } + + public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails, + String resourceVersion) { + + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject(); + + expectedResourceAuditJavaObject.setAction("Checkout"); + expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId()); + expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName()); + expectedResourceAuditJavaObject.setStatus("200.0"); + expectedResourceAuditJavaObject.setDesc("OK"); + expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase()); + expectedResourceAuditJavaObject.setResourceType("Resource"); + expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f)); + expectedResourceAuditJavaObject.setCurrVersion(resourceVersion); + expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); + + return expectedResourceAuditJavaObject; + + } + + public enum FieldToValidate { + contactId, Tags, VendorName, VendorRelease, Description + } + + @Test + public void UpdateBy_postTest() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // update resource - without changing resourceName + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + + RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST"); + + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, + updatedRestResponse.getResponse()); + + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(resourceDetails, getRestResponse); + + } + + @Test + public void UpdateBy_getTest() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // update resource - without changing resourceName + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET"); + + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, + updatedRestResponse.getResponse()); + + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(resourceDetails, getRestResponse); + + } + + @Test + public void UpdateBy_deleteTest() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // update resource - without changing resourceName + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, + "DELETE"); + + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List, + updatedRestResponse.getResponse()); + + RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(resourceDetails, getRestResponse); + + } + + // TODO DE + // @Ignore("") + @Test + public void UpdateWithInvaldJsonBodyTest() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); + String resourceId = resourceDetails.getUniqueId(); + + // update Descirption value + String description = "updatedDescription"; + + // send update with incompleted json, only description string + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails, + resourceId); + + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue()); + + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(resourceDetails, getRestResponse); + + } + + // @Test + // public void UpdateResourceModifierNotOwnerStateTest() throws Exception { + // + // + // RestResponse restResponse = createResource(sdncModifierDetails, + // resourceDetails); + // String resourceName = resourceDetails.getName(); + // + // // new user parameters + // String userFirstName = "Kot"; + // String userLastName = "Matroskin"; + // String role = "ADMIN"; + // User sdncUserDetails = new User(userFirstName, userLastName, + // httpCspUserId, email, role,null); + // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails, + // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN)); + // + // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails, + // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN)); + // + // User updatedSdncModifierDetails = new User(userFirstName, userLastName, + // httpCspUserId, email,role,null); + // ResourceReqDetails updatedResourceDetails = + // defineUpdatedResourse(resourceName); + // RestResponse updatedRestResponse = + // ResourceRestUtils.updateResource(updatedResourceDetails, + // updatedSdncModifierDetails, resourceDetails.getUniqueId(), ""); + // + // // validate response + // assertNotNull("check response object is not null after update resource", + // updatedRestResponse); + // assertNotNull("check error code exists in response after update + // resource", updatedRestResponse.getErrorCode()); + // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), + // Empty_List, updatedRestResponse.getResponse()); + // + // RestResponse getRestResponse = + // ResourceRestUtils.getResource(sdncModifierDetails, + // resourceDetails.getUniqueId()); + // assertNotNull("check response object is not null after update resource", + // getRestResponse); + // parseResponseAndValidate(resourceDetails, getRestResponse); + // + // + // } + + @Test + public void UpdateResourceNameSensitiveTest() throws Exception { + User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + String resourceName = "Ab"; + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + // Delete resources + RestResponse response = null; + response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, + updatedResourceDetails.getName(), "0.1"); + BaseRestUtils.checkDeleteResponse(response); + response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, + updatedResourceDetails.getName(), "0.2"); + BaseRestUtils.checkDeleteResponse(response); + + RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails); + assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue()); + + // check-in Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, + sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + // String resourceCertifyVersion = "0.1"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + updatedResourceDetails.setName("ABC_-bt.aT"); + ArrayList<String> resourceTag = new ArrayList<String>(); + resourceTag.add(0, "ABC_-bt.aT"); + updatedResourceDetails.setTags(resourceTag); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, updatedResourceDetails.getUniqueId(), ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(updatedResourceDetails, updatedRestResponse); + + // Delete resources + response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, + updatedResourceDetails.getName(), "0.1"); + BaseRestUtils.checkDeleteResponse(response); + response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, + updatedResourceDetails.getName(), "0.2"); + BaseRestUtils.checkDeleteResponse(response); + + } + + @Test + public void UpdateIcon_InegativeFlow() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + List<String> resourceList = new ArrayList<String>(); + resourceList.add(0, "Resource"); + // check InValid Characters + char[] notValidCharsArray = new char[59]; + notValidCharsArray = getInValidChars(); + // update metadata details + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + RestResponse updatedRestResponse; + + for (int i = 0; i < notValidCharsArray.length; i++) { + // change icon of metadata + updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]); + // PUT request + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", + updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList, + updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource icon", 400, + updatedRestResponse.getErrorCode().intValue()); + assertEquals("Check response code after updating resource icon", "Bad Request", + updatedRestResponse.getResponseMessage().toString()); + + } + + // empty icon + String updateIcon = ""; + updatedResourceDetails.setIcon(updateIcon); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList, + updatedRestResponse.getResponse()); + + // Icon length more then 25 characters + resourceList.add(1, "25"); + updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN"); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList, + updatedRestResponse.getResponse()); + assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue()); + assertEquals("Check response code after updating resource icon", "Bad Request", + updatedRestResponse.getResponseMessage().toString()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + } + + @Test + public void UpdateResource_NoTagsEqualToResourceName() throws Exception { + + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + ResourceReqDetails updatedResourceDetails = defineResourse(); + updatedResourceDetails.setName("updatedResourceName"); + List<String> tags = updatedResourceDetails.getTags(); + + for (Iterator<String> iter = tags.listIterator(); iter.hasNext(); ) { + String a = iter.next(); + if (a.equals("updatedResourceName")) { + iter.remove(); + } + } + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + List<String> resourceList = new ArrayList<String>(); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(), + resourceList, updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource icon", 400, + updatedRestResponse.getErrorCode().intValue()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + } + + @Test + public void UpdateResourceName_negativeFlow() throws Exception { + // The validation are done in Tag's validation + User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + + RestResponse updatedRestResponse; + RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails); + assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue()); + String uniqueId = resourceDetails.getUniqueId(); + String resourceName = resourceDetails.getName(); + // check InValid Characters + char[] notValidCharsArray = new char[59]; + notValidCharsArray = getInValidChars(); + ArrayList<String> resource_Name = new ArrayList<String>(); + List<String> resourceList = new ArrayList<String>(); + + ArrayList<String> resourceTags = new ArrayList<String>(); + resourceList.add(0, "Resource"); + + // update metadata details + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) { + if (i != 1 && i != 46 + && /* * i != 8 && i != 9 && i != 10 && i != 11 && i != 12 && */ i != 31) // space ("") and dot(.) - { - // change resourceName parameter - updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]); - resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]); - updatedResourceDetails.setTags(resource_Name); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncAdminModifierDetails, uniqueId, ""); - // validate response - // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(), - // Empty_List, updatedRestResponse.getResponse()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList, - updatedRestResponse.getResponse()); - - } - } - - // resourceName length more then 50 characters - // Duplicate tags are allowed and should be de-duplicated by server side - resource_Name.add(resourceName); - resource_Name.add("tag1"); - resource_Name.add("tag1"); - resource_Name.add("tag2"); - resource_Name.add("tag2"); - - resourceList.add(1, "1024"); - // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901"); - updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a")); - // resource_Name.add("123456789012345678901234567890123456789012345678901"); - updatedResourceDetails.setTags(resource_Name); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, - uniqueId, ""); - // validate response - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList, - updatedRestResponse.getResponse()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - // delete resource - RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, - updatedResourceDetails.getName(), "0.1"); - BaseRestUtils.checkDeleteResponse(response); - } - - @Test - public void UpdateResourceInformation_NotCheckedOut() throws Exception { - - String resourceBaseVersion = "0.1"; - List<String> resourceList = new ArrayList<String>(); - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // CheckIn Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN - assertNotNull("check response object is not null after checkout resource", checkoutResource); - assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode()); - assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue()); - - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, - updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource icon", 409, - updatedRestResponse.getErrorCode().intValue()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - } - - @Test - public void UpdateResourceInformation_resourceVersion_11() throws Exception { - - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - String resourceCertifyVersion = "1.0"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - List<String> resourceList = new ArrayList<String>(); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, - updatedRestResponse.getResponse()); - // assertEquals("Check response code after updating resource icon", 409, - // updatedRestResponse.getErrorCode().intValue()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - } - - @Test - public void UpdateResourceInformation_resourceVersion_02() throws Exception { - - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - // String resourceCertifyVersion = "0.1"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after updating resource icon", 200, - updatedRestResponse.getErrorCode().intValue()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject); - - // delete resource - RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, - updatedResourceDetails.getName(), "0.1"); - BaseRestUtils.checkDeleteResponse(response); - response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, - updatedResourceDetails.getName(), "0.2"); - BaseRestUtils.checkDeleteResponse(response); - - } - - @Test - public void UpdateResourceIcon_resourceVersion_11() throws Exception { - // Can be changed only if major version is "0". - - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - String resourceCertifyVersion = "1.0"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - // ResourceReqDetails updatedResourceDetails = - // defineUpdatedResourse(resourceName); - ResourceReqDetails updatedResourceDetails = defineResourse(); - // updatedResourceDetails.setVendorName("updatedVandorName"); - updatedResourceDetails.setIcon("updatedIcon"); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - List<String> resourceList = new ArrayList<String>(); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList, - updatedRestResponse.getResponse()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - } - - @Test - public void UpdateResourceVandorName_resourceVersion_11() throws Exception { - // Can be changed only if the major resource version is "0". - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - String resourceCertifyVersion = "1.0"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - // ResourceReqDetails updatedResourceDetails = - // defineUpdatedResourse(resourceName); - ResourceReqDetails updatedResourceDetails = defineResourse(); - - updatedResourceDetails.setVendorName("updatedVandorName"); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - List<String> resourceList = new ArrayList<String>(); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(), - resourceList, updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource icon", 400, - updatedRestResponse.getErrorCode().intValue()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - } - - @Test - public void UpdateResourceName_resourceVersion_11() throws Exception { - // Can be changed only if the major resource version is "0". - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue()); - String resourceName = resourceDetails.getName(); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - String resourceCertifyVersion = "1.0"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + { + // change resourceName parameter + updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]); + resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]); + updatedResourceDetails.setTags(resource_Name); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncAdminModifierDetails, uniqueId, ""); + // validate response + // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(), + // Empty_List, updatedRestResponse.getResponse()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList, + updatedRestResponse.getResponse()); + + } + } + + // resourceName length more then 50 characters + // Duplicate tags are allowed and should be de-duplicated by server side + resource_Name.add(resourceName); + resource_Name.add("tag1"); + resource_Name.add("tag1"); + resource_Name.add("tag2"); + resource_Name.add("tag2"); + + resourceList.add(1, "1024"); + // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901"); + updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a")); + // resource_Name.add("123456789012345678901234567890123456789012345678901"); + updatedResourceDetails.setTags(resource_Name); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, + uniqueId, ""); + // validate response + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList, + updatedRestResponse.getResponse()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + // delete resource + RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, + updatedResourceDetails.getName(), "0.1"); + BaseRestUtils.checkDeleteResponse(response); + } + + @Test + public void UpdateResourceInformation_NotCheckedOut() throws Exception { + + String resourceBaseVersion = "0.1"; + List<String> resourceList = new ArrayList<String>(); + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // CheckIn Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN + assertNotNull("check response object is not null after checkout resource", checkoutResource); + assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode()); + assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue()); + + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, + updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource icon", 409, + updatedRestResponse.getErrorCode().intValue()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + } + + @Test + public void UpdateResourceInformation_resourceVersion_11() throws Exception { + + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + /*logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + String resourceCertifyVersion = "1.0"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + List<String> resourceList = new ArrayList<String>(); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList, + updatedRestResponse.getResponse()); + // assertEquals("Check response code after updating resource icon", 409, + // updatedRestResponse.getErrorCode().intValue()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + } + + @Test + public void UpdateResourceInformation_resourceVersion_02() throws Exception { + + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + // String resourceCertifyVersion = "0.1"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after updating resource icon", 200, + updatedRestResponse.getErrorCode().intValue()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject); + + // delete resource + RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, + updatedResourceDetails.getName(), "0.1"); + BaseRestUtils.checkDeleteResponse(response); + response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, + updatedResourceDetails.getName(), "0.2"); + BaseRestUtils.checkDeleteResponse(response); + + } + + @Test + public void UpdateResourceIcon_resourceVersion_11() throws Exception { + // Can be changed only if major version is "0". + + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + /*logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + String resourceCertifyVersion = "1.0"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + // ResourceReqDetails updatedResourceDetails = + // defineUpdatedResourse(resourceName); + ResourceReqDetails updatedResourceDetails = defineResourse(); + // updatedResourceDetails.setVendorName("updatedVandorName"); + updatedResourceDetails.setIcon("updatedIcon"); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + List<String> resourceList = new ArrayList<String>(); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList, + updatedRestResponse.getResponse()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + } + + @Test + public void UpdateResourceVandorName_resourceVersion_11() throws Exception { + // Can be changed only if the major resource version is "0". + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + /*logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + String resourceCertifyVersion = "1.0"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + // ResourceReqDetails updatedResourceDetails = + // defineUpdatedResourse(resourceName); + ResourceReqDetails updatedResourceDetails = defineResourse(); + + updatedResourceDetails.setVendorName("updatedVandorName"); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + List<String> resourceList = new ArrayList<String>(); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(), + resourceList, updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource icon", 400, + updatedRestResponse.getErrorCode().intValue()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + } + + @Test + public void UpdateResourceName_resourceVersion_11() throws Exception { + // Can be changed only if the major resource version is "0". + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue()); + String resourceName = resourceDetails.getName(); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + /*logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + String resourceCertifyVersion = "1.0"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); /* * //ResourceReqDetails updatedResourceDetails = @@ -1319,1330 +1306,1330 @@ public class UpdateResourceMetadataTest extends ComponentBaseTest { * updatedResourceDetails.setResourceName("updatedResourceName"); * updatedResourceDetails.setIcon("updatedResourceName"); */ - resourceDetails.setName("updatedResourceName"); - List<String> tagList = new ArrayList<String>(); - tagList.add(0, "updatedResourceName"); - resourceDetails.setTags(tagList); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - List<String> resourceList = new ArrayList<String>(); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResourceTag_resourceVersion_11() throws Exception { - // Tag Can be updated when major version is "0". - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - String resourceCertifyVersion = "1.0"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - // ResourceReqDetails updatedResourceDetails = - // defineUpdatedResourse(resourceName); - ResourceReqDetails updatedResourceDetails = defineResourse(); - // updatedResourceDetails.setVendorName("updatedVandorName"); - - ArrayList<String> resourceTags = new ArrayList<String>(); - resourceTags.add("NewTag"); - resourceTags.add(resourceDetails.getName()); - - updatedResourceDetails.setTags(resourceTags); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(updatedResourceDetails, getRestResponse); - - } - - @Test - public void UpdateAllowedParames_resourceVersion_11() throws Exception { - - // Tag, contactId, vendorRelease,tags And description - Can be also - // updated when major version is NOT "0". - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - String resourceCertifyVersion = "1.0"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - // ResourceReqDetails updatedResourceDetails = - // defineUpdatedResourse(resourceName); - ResourceReqDetails updatedResourceDetails = defineResourse(); - // updatedResourceDetails.setVendorName("updatedVandorName"); - - // updated allowed parameters when major resource version is NOT "0" - ArrayList<String> resourceTags = new ArrayList<String>(); - resourceTags.add("NewTag"); - resourceTags.add(resourceDetails.getName()); - updatedResourceDetails.setTags(resourceTags); - updatedResourceDetails.setDescription("UpdatedDescription"); - updatedResourceDetails.setVendorRelease("5.1"); - updatedResourceDetails.setContactId("bt750h"); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(updatedResourceDetails, getRestResponse); - - } - - @Test - public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception { - // DerivedFrom parameter - Can be updated when major version is "0". - User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - String resourceBaseVersion = "0.1"; - - // create resource - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String resourceName = resourceDetails.getName(); - - // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, - // restResponse); - - // Certify Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, - resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - String resourceCertifyVersion = "1.0"; - logger.debug("Changing resource life cycle "); - checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); - - // ResourceReqDetails updatedResourceDetails = - // defineUpdatedResourse(resourceName); - ResourceReqDetails updatedResourceDetails = defineResourse(); - ArrayList<String> drivenFrom = new ArrayList<String>(); - drivenFrom.add(0, "tosca.nodes.Container.Application"); - updatedResourceDetails.setDerivedFrom(drivenFrom); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - // validate response - List<String> resourceList = new ArrayList<String>(); - ResourceRestUtils.checkSuccess(updatedRestResponse); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - } - - @Test - public void UpdateResource_vendorNameValidation() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - String updatedVendorName = ""; - String uniqueId = resourceDetails.getUniqueId(); - resourceDetails.setVendorName(updatedVendorName); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, uniqueId, ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - // update resource vendorName metadata: 1 characters - updatedVendorName = " "; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - // update resource vendorName metadata: 25 characters - updatedVendorName = "Verification and validati"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // update resource vendorName metadata: 26 characters - updatedVendorName = "Verification and validatii"; - // set vendorName - List<String> myList = new ArrayList<String>(); - myList.add(0, "25"); - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList, - updatedRestResponse.getResponse()); - - // update resource VendorRelease metadata: forbidden characters - updatedVendorName = "A1<"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1>"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1:"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1\""; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1/"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1\\"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1|"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1?"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorName = "A1*"; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - // update resource vendorName metadata: null - updatedVendorName = null; - // set vendorName - resourceDetails.setVendorName(updatedVendorName); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResource_vendorReleaseValidation() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - RestResponse updatedRestResponse; - String uniqueId = resourceDetails.getUniqueId(); - String updatedVendorRelease; - // set VendorRelease - - // update resource VendorRelease metadata: 1 characters - updatedVendorRelease = "1"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // update resource VendorRelease metadata: 25 characters - updatedVendorRelease = "(!#1.00000000000000000000"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // update resource VendorRelease metadata: 26 characters - updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(), - Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse()); - - // UpdateAndValidate(sdncModifierDetails, resourceDetails, - // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(), - // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH)); - - // update resource VendorRelease metadata: forbidden characters - updatedVendorRelease = "A1<"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1>"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1:"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1\""; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1/"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1\\"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1|"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1?"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - updatedVendorRelease = "A1*"; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - // update resource VendorRelease metadata: null - updatedVendorRelease = null; - // set VendorRelease - resourceDetails.setVendorRelease(updatedVendorRelease); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1} - // (6 - // characters - // now, - // may - // be - // expanded - // up - // to - // 8 - // characters - // in - // the - // future). - // Convert - // Upper - // case - // character - // to - // lower - // case - RestResponse updatedRestResponse; - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - String uniqueId = resourceDetails.getUniqueId(); - - List<String> myList = new ArrayList<String>(); - myList.add(0, "Resource"); - String updatedcontactId = ""; - resourceDetails.setContactId(updatedcontactId); - - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "ab12345"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = " "; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "ab 50h"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "ab123c"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - updatedcontactId = "cd789E"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - - resourceDetails.setContactId(updatedcontactId.toLowerCase()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - updatedcontactId = "ef4567"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - updatedcontactId = "AA012A"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - - resourceDetails.setContactId(updatedcontactId.toLowerCase()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - updatedcontactId = "CD012c"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - - resourceDetails.setContactId(updatedcontactId.toLowerCase()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - updatedcontactId = "EF0123"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - - resourceDetails.setContactId(updatedcontactId.toLowerCase()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - ////////////////////////////// **************////////////////////////////// - List<String> resource = Arrays.asList("Resource"); - updatedcontactId = "01345a"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "0y000B"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "Y1000b"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "abxyzC"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "cdXYZc"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "efXY1D"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "EFabcD"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "EFABCD"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "EFABC1"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "efui1D"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "efui1!"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "ef555!"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = ",f555"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - updatedcontactId = "EF55.5"; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - // update resource contactId metadata: extended character set (128–255) - resourceDetails.setContactId(extendedCharsStringBuilder()); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - // update resource contactId metadata: null - updatedcontactId = null; - resourceDetails.setContactId(updatedcontactId); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResource_TagsFieldValidation() throws Exception { - RestResponse updatedRestResponse; - // define and create resource - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - String uniqueId = resourceDetails.getUniqueId(); - - String updatedTagField = ""; - ArrayList<String> resourceTags = new ArrayList<String>(); - resourceTags.add(updatedTagField); - // set description - resourceDetails.setTags(resourceTags); - List<String> variables = Arrays.asList("Resource", "tag"); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, - updatedRestResponse.getResponse()); - - // update resource tags metadata: empty - resourceTags = new ArrayList<String>(); - // set Tags - resourceDetails.setTags(resourceTags); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List, - updatedRestResponse.getResponse()); - - // update resource description metadata: 1 characters - updatedTagField = "A"; - resourceTags = new ArrayList<String>(); - resourceTags.add(updatedTagField); - resourceTags.add(resourceDetails.getName()); - // set description - resourceDetails.setTags(resourceTags); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // OK - tag up to 50 chars - updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds"; - resourceTags.add(updatedTagField); - resourceDetails.setTags(resourceTags); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name) - String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01"; - String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02"; - String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03"; - String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04"; - String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05"; - String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06"; - String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07"; - String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08"; - String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09"; - String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10"; - String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11"; - String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12"; - String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13"; - String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14"; - String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15"; - String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16"; - String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17"; - String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18"; - String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa"; - - resourceTags = new ArrayList<String>(); - resourceTags.add(updatedTagField); - resourceTags.add(updatedTagField1); - resourceTags.add(updatedTagField2); - resourceTags.add(updatedTagField3); - resourceTags.add(updatedTagField4); - resourceTags.add(updatedTagField5); - resourceTags.add(updatedTagField6); - resourceTags.add(updatedTagField7); - resourceTags.add(updatedTagField8); - resourceTags.add(updatedTagField9); - resourceTags.add(updatedTagField10); - resourceTags.add(updatedTagField11); - resourceTags.add(updatedTagField12); - resourceTags.add(updatedTagField13); - resourceTags.add(updatedTagField14); - resourceTags.add(updatedTagField15); - resourceTags.add(updatedTagField16); - resourceTags.add(updatedTagField17); - resourceTags.add(updatedTagField18); - resourceTags.add(updatedTagField19); - resourceTags.add(resourceDetails.getName()); - // set description - resourceDetails.setTags(resourceTags); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // Add another tag-exceeds limit - resourceTags.add("d"); - resourceDetails.setTags(resourceTags); - ArrayList<String> myArray = new ArrayList<String>(); - myArray.add(0, "1024"); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray, - updatedRestResponse.getResponse()); - - // Tag exceeds limit - 51 - resourceTags = new ArrayList<String>(); - updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw"; - resourceTags.add(updatedTagField); - resourceTags.add(resourceDetails.getName()); - // set description - resourceDetails.setTags(resourceTags); - myArray.remove(0); - myArray.add(0, "50"); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResource_DesriptionFieldValidation() throws Exception { - // define and create resource - RestResponse updatedRestResponse; - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - String uniqueId = resourceDetails.getUniqueId(); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - List<String> resource = new ArrayList<>(); - resource.add("Resource"); - // update resource description metadata: 0 characters - String updatedDescription = ""; - // set description - resourceDetails.setDescription(updatedDescription); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, - updatedRestResponse.getResponse()); - - // update resource description metadata: null - updatedDescription = null; - // set description - resourceDetails.setDescription(updatedDescription); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, - updatedRestResponse.getResponse()); - - // update resource description metadata: 1 characters - updatedDescription = "A"; - // set description - resourceDetails.setDescription(updatedDescription); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // update resource description metadata: 1024 characters - updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines." - + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East." - + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests." - + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills." - + "The longest quills grow from its shoulders to about a third of the animal's length." - + "Its tail is covered in short, hollow quills that can rattle when threatened." - + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail." - + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills." - + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury"; - // set description - resourceDetails.setDescription(updatedDescription); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - parseResponseAndValidate(resourceDetails, updatedRestResponse); - - // update resource description metadata: 1025 characters - updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines." - + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East." - + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests." - + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills." - + "The longest quills grow from its shoulders to about a third of the animal's length." - + "Its tail is covered in short, hollow quills that can rattle when threatened." - + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail." - + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills." - + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury."; - // set description - resourceDetails.setDescription(updatedDescription); - resource.add(1, "1024"); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, - ""); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResource_TagsFormatValidation() throws Exception { - char[] notValidCharsArray = getTagInValidFormatChars(); - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue()); - String resourceName = resourceDetails.getName(); - - // update tag details - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - ArrayList<String> resourceTags = new ArrayList<String>(); - - String updatedTagField; - RestResponse updatedRestResponse; - List<String> variables = Arrays.asList("Resource", "tag"); - - for (int i = 0; i < notValidCharsArray.length; i++) { - updatedTagField = "UpdatedTag" + notValidCharsArray[i]; - resourceTags = new ArrayList<String>(); - resourceTags.add(updatedTagField); - resourceTags.add(resourceDetails.getName()); - // set description - updatedResourceDetails.setTags(resourceTags); - - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", - updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, - updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource icon", 400, - updatedRestResponse.getErrorCode().intValue()); - assertEquals("Check response code after updating resource icon", "Bad Request", - updatedRestResponse.getResponseMessage().toString()); - - } - - } - - @Test - public void UpdateResourceCategory_negativeFlow() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue()); - Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); - String uniqueID = resourceDetails.getUniqueId(); - - // Update resource Category Successfully - ResourceReqDetails updatedResourceDetails = resourceDetails; - - updatedResourceDetails.removeAllCategories(); - updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(), - ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory()); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - - // validate response - List<String> resourceList = new ArrayList<String>(); - resourceList.add(0, "Resource"); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, - updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue()); - - // Updating resource category - updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate); - updatedResourceDetails.addCategory(""); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - // validate response - resourceList = new ArrayList<String>(); - resourceList.add(0, "Resource"); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList, - updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue()); - - // Updating resource category - updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate); - updatedResourceDetails.addCategory("XXXXXX"); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - // validate response - resourceList = new ArrayList<String>(); - resourceList.add(0, "Resource"); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, - updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue()); - - // CheckIn Resource - logger.debug("Changing resource life cycle "); - RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN - assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue()); - - // Update resource Category - updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate); - updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue()); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, - resourceDetails.getUniqueId(), ""); - // verify response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List, - updatedRestResponse.getResponse()); - assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue()); - - // CheckIn Resource - logger.debug("Changing resource life cycle "); - RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN - assertNotNull("check response object is not null after checkout resource", checkoutResource); - assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode()); - assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue()); - - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(resourceDetails, getRestResponse); - - } - - @Test - public void UpdateResourceCategorySuccessfully() throws Exception { - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue()); - Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); - - // Update resource Category Successfully - ResourceReqDetails updatedResourceDetails = resourceDetails; - - updatedResourceDetails.removeAllCategories(); - updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(), - ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory()); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncModifierDetails, resourceDetails.getUniqueId(), ""); - - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); - // parseResponseAndValidateNonUpdatable(updatedResourceDetails, - // updatedRestResponse); - parseResponseAndValidate(updatedResourceDetails, updatedRestResponse); - - // validate category updated - assertTrue(updatedResourceDetails.getCategories().get(0).getName() - .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory())); - - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, - resourceDetails.getUniqueId()); - assertNotNull("check response object is not null after update resource", getRestResponse); - parseResponseAndValidate(updatedResourceDetails, getRestResponse); - - ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1"); - } - - // Benny - - @Test - public void Validation_UpdateIcon() throws Exception { - // Fields to update (Forbidden) - String _updatedIcon = "mySecondIcon.Jpg"; - - // administrator permissions - User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - - // define and create resource - ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1"); - - RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - String resourceName = resourceDetails.getName(); - - // update metadata details - ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); - // change icon of metadata - updatedResourceDetails.setIcon(_updatedIcon); - // PUT request - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, - sdncAdminModifierDetails, resourceDetails.getUniqueId(), ""); - - // validate response - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), - Arrays.asList("Resource"), updatedRestResponse.getResponse()); - - // empty icon - _updatedIcon = ""; - updatedResourceDetails.setIcon(_updatedIcon); - updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, - resourceDetails.getUniqueId(), ""); - assertNotNull("check response object is not null after update resource", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), - Arrays.asList("Resource"), updatedRestResponse.getResponse()); - - // get resource with original name. original metadata should be returned - RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, - resourceDetails.getUniqueId()); - // validate response - assertNotNull("check response object is not null after get resource", getRestResponse); - assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); - - // parse updated response to javaObject - Resource getResourceRespJavaObject = ResponseParser - .convertResourceResponseToJavaObject(getRestResponse.getResponse()); - // validate that metadata was not changed - ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); - - ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), - "0.1"); - - } - - @Test - public void UpdateResourceTypeSuccess() throws Exception { - // LCS is CheckOut - String newResourceType = ResourceTypeEnum.VL.toString(); - String currentResourceType = resourceDetails.getResourceType(); - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - Resource currentResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); - - resourceDetails.setResourceType(newResourceType); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); - assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue()); - Resource updatedResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(updatedRestResponse.getResponse()); - // assertTrue("Check resource type after update resource", - // updatedResourceJavaObject.getResourceType().toString().equals(resourceType)); - assertTrue("Check resource type after update resource", - updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType)); - - } - - @Test - public void UpdateResourceTypeAndNameSuccess() throws Exception { - // LCS is CheckOut - String newResourceType = ResourceTypeEnum.VL.toString(); - String currentResourceType = resourceDetails.getResourceType(); - String newResourceName = "new Name"; - - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - Resource currentResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); - - resourceDetails.setResourceType(newResourceType); - resourceDetails.setName(newResourceName); - List<String> tags = resourceDetails.getTags(); - tags.add(newResourceName); - resourceDetails.setTags(tags); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); - assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue()); - Resource updatedResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(updatedRestResponse.getResponse()); - assertTrue("Check resource type after update resource", - updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType)); - assertTrue("Check resource name after update resource", - updatedResourceJavaObject.getName().equals(newResourceName)); - - } - - @Test - public void UpdateResourceTypeAfterResourceCertification() throws Exception { - - String newResourceType = ResourceTypeEnum.VF.toString(); - String currentResourceType = resourceDetails.getResourceType(); - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - Resource currentResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); - - resourceDetails.setResourceType(newResourceType); - restResponse = LifecycleRestUtils.certifyResource(resourceDetails); - assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - LifeCycleStatesEnum.CHECKOUT); - assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); - currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); - assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue()); - Resource updatedResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(updatedRestResponse.getResponse()); - // assertTrue("Check resource type after update resource", - // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType)); - assertTrue("Check resource type after update resource", - updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType)); - - } - - @Test - public void UpdateResourceTypeCheckInLCS() throws Exception { - - String resourceType = ResourceTypeEnum.VL.toString(); - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - Resource currentResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); - - resourceDetails.setResourceType(resourceType); - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, - LifeCycleStatesEnum.CHECKIN); - assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); - - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); - - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); - - assertNotNull("check response object is not null after create resouce", updatedRestResponse); - assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after create resource", errorInfo.getCode(), - updatedRestResponse.getErrorCode()); - - List<String> variables = new ArrayList<>(); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResourceTypeCertifiedLCS() throws Exception { - - String resourceType = ResourceTypeEnum.VL.toString(); - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - Resource currentResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); - - restResponse = LifecycleRestUtils.certifyResource(resourceDetails); - assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); - - resourceDetails.setResourceType(resourceType); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); - - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); - - assertNotNull("check response object is not null after create resouce", updatedRestResponse); - assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after create resource", errorInfo.getCode(), - updatedRestResponse.getErrorCode()); - - List<String> variables = new ArrayList<>(); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, - updatedRestResponse.getResponse()); - - } - - @Test - public void UpdateResourceTypeInvalidType() throws Exception { - - String resourceType = "INVALID TYPE"; - RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); - assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); - Resource currentResourceJavaObject = ResponseParser - .convertResourceResponseToJavaObject(restResponse.getResponse()); + resourceDetails.setName("updatedResourceName"); + List<String> tagList = new ArrayList<String>(); + tagList.add(0, "updatedResourceName"); + resourceDetails.setTags(tagList); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + List<String> resourceList = new ArrayList<String>(); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResourceTag_resourceVersion_11() throws Exception { + // Tag Can be updated when major version is "0". + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + /*logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + String resourceCertifyVersion = "1.0"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + // ResourceReqDetails updatedResourceDetails = + // defineUpdatedResourse(resourceName); + ResourceReqDetails updatedResourceDetails = defineResourse(); + // updatedResourceDetails.setVendorName("updatedVandorName"); + + ArrayList<String> resourceTags = new ArrayList<String>(); + resourceTags.add("NewTag"); + resourceTags.add(resourceDetails.getName()); + + updatedResourceDetails.setTags(resourceTags); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(updatedResourceDetails, getRestResponse); + + } + + @Test + public void UpdateAllowedParames_resourceVersion_11() throws Exception { + + // Tag, contactId, vendorRelease,tags And description - Can be also + // updated when major version is NOT "0". + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + /*logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + String resourceCertifyVersion = "1.0"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + // ResourceReqDetails updatedResourceDetails = + // defineUpdatedResourse(resourceName); + ResourceReqDetails updatedResourceDetails = defineResourse(); + // updatedResourceDetails.setVendorName("updatedVandorName"); + + // updated allowed parameters when major resource version is NOT "0" + ArrayList<String> resourceTags = new ArrayList<String>(); + resourceTags.add("NewTag"); + resourceTags.add(resourceDetails.getName()); + updatedResourceDetails.setTags(resourceTags); + updatedResourceDetails.setDescription("UpdatedDescription"); + updatedResourceDetails.setVendorRelease("5.1"); + updatedResourceDetails.setContactId("bt750h"); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(updatedResourceDetails, getRestResponse); + + } + + @Test + public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception { + // DerivedFrom parameter - Can be updated when major version is "0". + User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + String resourceBaseVersion = "0.1"; + + // create resource + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String resourceName = resourceDetails.getName(); + + // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails, + // restResponse); + + // Certify Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + /*logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/ + + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails, + resourceBaseVersion, LifeCycleStatesEnum.CERTIFY); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + String resourceCertifyVersion = "1.0"; + logger.debug("Changing resource life cycle "); + checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue()); + + // ResourceReqDetails updatedResourceDetails = + // defineUpdatedResourse(resourceName); + ResourceReqDetails updatedResourceDetails = defineResourse(); + ArrayList<String> drivenFrom = new ArrayList<String>(); + drivenFrom.add(0, "tosca.nodes.Container.Application"); + updatedResourceDetails.setDerivedFrom(drivenFrom); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + // validate response + List<String> resourceList = new ArrayList<String>(); + ResourceRestUtils.checkSuccess(updatedRestResponse); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + } + + @Test + public void UpdateResource_vendorNameValidation() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + String updatedVendorName = ""; + String uniqueId = resourceDetails.getUniqueId(); + resourceDetails.setVendorName(updatedVendorName); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, uniqueId, ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + // update resource vendorName metadata: 1 characters + updatedVendorName = " "; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + // update resource vendorName metadata: 25 characters + updatedVendorName = "Verification and validati"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // update resource vendorName metadata: 26 characters + updatedVendorName = "Verification and validatii"; + // set vendorName + List<String> myList = new ArrayList<String>(); + myList.add(0, "25"); + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList, + updatedRestResponse.getResponse()); + + // update resource VendorRelease metadata: forbidden characters + updatedVendorName = "A1<"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1>"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1:"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1\""; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1/"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1\\"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1|"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1?"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorName = "A1*"; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + // update resource vendorName metadata: null + updatedVendorName = null; + // set vendorName + resourceDetails.setVendorName(updatedVendorName); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResource_vendorReleaseValidation() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + RestResponse updatedRestResponse; + String uniqueId = resourceDetails.getUniqueId(); + String updatedVendorRelease; + // set VendorRelease + + // update resource VendorRelease metadata: 1 characters + updatedVendorRelease = "1"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // update resource VendorRelease metadata: 25 characters + updatedVendorRelease = "(!#1.00000000000000000000"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // update resource VendorRelease metadata: 26 characters + updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(), + Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse()); + + // UpdateAndValidate(sdncModifierDetails, resourceDetails, + // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(), + // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH)); + + // update resource VendorRelease metadata: forbidden characters + updatedVendorRelease = "A1<"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1>"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1:"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1\""; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1/"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1\\"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1|"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1?"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + updatedVendorRelease = "A1*"; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + // update resource VendorRelease metadata: null + updatedVendorRelease = null; + // set VendorRelease + resourceDetails.setVendorRelease(updatedVendorRelease); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1} + // (6 + // characters + // now, + // may + // be + // expanded + // up + // to + // 8 + // characters + // in + // the + // future). + // Convert + // Upper + // case + // character + // to + // lower + // case + RestResponse updatedRestResponse; + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + String uniqueId = resourceDetails.getUniqueId(); + + List<String> myList = new ArrayList<String>(); + myList.add(0, "Resource"); + String updatedcontactId = ""; + resourceDetails.setContactId(updatedcontactId); + + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "ab12345"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = " "; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "ab 50h"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "ab123c"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + updatedcontactId = "cd789E"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + + resourceDetails.setContactId(updatedcontactId.toLowerCase()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + updatedcontactId = "ef4567"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + updatedcontactId = "AA012A"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + + resourceDetails.setContactId(updatedcontactId.toLowerCase()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + updatedcontactId = "CD012c"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + + resourceDetails.setContactId(updatedcontactId.toLowerCase()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + updatedcontactId = "EF0123"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + + resourceDetails.setContactId(updatedcontactId.toLowerCase()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + ////////////////////////////// **************////////////////////////////// + List<String> resource = Arrays.asList("Resource"); + updatedcontactId = "01345a"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "0y000B"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "Y1000b"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "abxyzC"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "cdXYZc"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "efXY1D"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "EFabcD"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "EFABCD"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "EFABC1"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "efui1D"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "efui1!"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "ef555!"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = ",f555"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + updatedcontactId = "EF55.5"; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + // update resource contactId metadata: extended character set (128–255) + resourceDetails.setContactId(extendedCharsStringBuilder()); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + // update resource contactId metadata: null + updatedcontactId = null; + resourceDetails.setContactId(updatedcontactId); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResource_TagsFieldValidation() throws Exception { + RestResponse updatedRestResponse; + // define and create resource + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + String uniqueId = resourceDetails.getUniqueId(); + + String updatedTagField = ""; + ArrayList<String> resourceTags = new ArrayList<String>(); + resourceTags.add(updatedTagField); + // set description + resourceDetails.setTags(resourceTags); + List<String> variables = Arrays.asList("Resource", "tag"); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, + updatedRestResponse.getResponse()); + + // update resource tags metadata: empty + resourceTags = new ArrayList<String>(); + // set Tags + resourceDetails.setTags(resourceTags); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List, + updatedRestResponse.getResponse()); + + // update resource description metadata: 1 characters + updatedTagField = "A"; + resourceTags = new ArrayList<String>(); + resourceTags.add(updatedTagField); + resourceTags.add(resourceDetails.getName()); + // set description + resourceDetails.setTags(resourceTags); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // OK - tag up to 50 chars + updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds"; + resourceTags.add(updatedTagField); + resourceDetails.setTags(resourceTags); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name) + String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01"; + String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02"; + String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03"; + String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04"; + String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05"; + String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06"; + String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07"; + String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08"; + String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09"; + String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10"; + String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11"; + String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12"; + String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13"; + String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14"; + String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15"; + String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16"; + String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17"; + String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18"; + String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa"; + + resourceTags = new ArrayList<String>(); + resourceTags.add(updatedTagField); + resourceTags.add(updatedTagField1); + resourceTags.add(updatedTagField2); + resourceTags.add(updatedTagField3); + resourceTags.add(updatedTagField4); + resourceTags.add(updatedTagField5); + resourceTags.add(updatedTagField6); + resourceTags.add(updatedTagField7); + resourceTags.add(updatedTagField8); + resourceTags.add(updatedTagField9); + resourceTags.add(updatedTagField10); + resourceTags.add(updatedTagField11); + resourceTags.add(updatedTagField12); + resourceTags.add(updatedTagField13); + resourceTags.add(updatedTagField14); + resourceTags.add(updatedTagField15); + resourceTags.add(updatedTagField16); + resourceTags.add(updatedTagField17); + resourceTags.add(updatedTagField18); + resourceTags.add(updatedTagField19); + resourceTags.add(resourceDetails.getName()); + // set description + resourceDetails.setTags(resourceTags); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // Add another tag-exceeds limit + resourceTags.add("d"); + resourceDetails.setTags(resourceTags); + ArrayList<String> myArray = new ArrayList<String>(); + myArray.add(0, "1024"); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray, + updatedRestResponse.getResponse()); + + // Tag exceeds limit - 51 + resourceTags = new ArrayList<String>(); + updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw"; + resourceTags.add(updatedTagField); + resourceTags.add(resourceDetails.getName()); + // set description + resourceDetails.setTags(resourceTags); + myArray.remove(0); + myArray.add(0, "50"); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResource_DesriptionFieldValidation() throws Exception { + // define and create resource + RestResponse updatedRestResponse; + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + String uniqueId = resourceDetails.getUniqueId(); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + List<String> resource = new ArrayList<>(); + resource.add("Resource"); + // update resource description metadata: 0 characters + String updatedDescription = ""; + // set description + resourceDetails.setDescription(updatedDescription); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, + updatedRestResponse.getResponse()); + + // update resource description metadata: null + updatedDescription = null; + // set description + resourceDetails.setDescription(updatedDescription); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource, + updatedRestResponse.getResponse()); + + // update resource description metadata: 1 characters + updatedDescription = "A"; + // set description + resourceDetails.setDescription(updatedDescription); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // update resource description metadata: 1024 characters + updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines." + + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East." + + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests." + + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills." + + "The longest quills grow from its shoulders to about a third of the animal's length." + + "Its tail is covered in short, hollow quills that can rattle when threatened." + + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail." + + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills." + + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury"; + // set description + resourceDetails.setDescription(updatedDescription); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + parseResponseAndValidate(resourceDetails, updatedRestResponse); + + // update resource description metadata: 1025 characters + updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines." + + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East." + + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests." + + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills." + + "The longest quills grow from its shoulders to about a third of the animal's length." + + "Its tail is covered in short, hollow quills that can rattle when threatened." + + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail." + + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills." + + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury."; + // set description + resourceDetails.setDescription(updatedDescription); + resource.add(1, "1024"); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId, + ""); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResource_TagsFormatValidation() throws Exception { + char[] notValidCharsArray = getTagInValidFormatChars(); + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue()); + String resourceName = resourceDetails.getName(); + + // update tag details + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + ArrayList<String> resourceTags = new ArrayList<String>(); + + String updatedTagField; + RestResponse updatedRestResponse; + List<String> variables = Arrays.asList("Resource", "tag"); + + for (int i = 0; i < notValidCharsArray.length; i++) { + updatedTagField = "UpdatedTag" + notValidCharsArray[i]; + resourceTags = new ArrayList<String>(); + resourceTags.add(updatedTagField); + resourceTags.add(resourceDetails.getName()); + // set description + updatedResourceDetails.setTags(resourceTags); + + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", + updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables, + updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource icon", 400, + updatedRestResponse.getErrorCode().intValue()); + assertEquals("Check response code after updating resource icon", "Bad Request", + updatedRestResponse.getResponseMessage().toString()); + + } + + } + + @Test + public void UpdateResourceCategory_negativeFlow() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue()); + Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); + String uniqueID = resourceDetails.getUniqueId(); + + // Update resource Category Successfully + ResourceReqDetails updatedResourceDetails = resourceDetails; + + updatedResourceDetails.removeAllCategories(); + updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(), + ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory()); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + + // validate response + List<String> resourceList = new ArrayList<String>(); + resourceList.add(0, "Resource"); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, + updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue()); + + // Updating resource category + updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate); + updatedResourceDetails.addCategory(""); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + // validate response + resourceList = new ArrayList<String>(); + resourceList.add(0, "Resource"); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList, + updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue()); + + // Updating resource category + updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate); + updatedResourceDetails.addCategory("XXXXXX"); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + // validate response + resourceList = new ArrayList<String>(); + resourceList.add(0, "Resource"); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList, + updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue()); + + // CheckIn Resource + logger.debug("Changing resource life cycle "); + RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN + assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue()); + + // Update resource Category + updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate); + updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue()); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails, + resourceDetails.getUniqueId(), ""); + // verify response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List, + updatedRestResponse.getResponse()); + assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue()); + + // CheckIn Resource + logger.debug("Changing resource life cycle "); + RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN + assertNotNull("check response object is not null after checkout resource", checkoutResource); + assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode()); + assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue()); + + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(resourceDetails, getRestResponse); + + } + + @Test + public void UpdateResourceCategorySuccessfully() throws Exception { + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue()); + Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); + + // Update resource Category Successfully + ResourceReqDetails updatedResourceDetails = resourceDetails; + + updatedResourceDetails.removeAllCategories(); + updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(), + ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory()); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncModifierDetails, resourceDetails.getUniqueId(), ""); + + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue()); + // parseResponseAndValidateNonUpdatable(updatedResourceDetails, + // updatedRestResponse); + parseResponseAndValidate(updatedResourceDetails, updatedRestResponse); + + // validate category updated + assertTrue(updatedResourceDetails.getCategories().get(0).getName() + .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory())); + + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, + resourceDetails.getUniqueId()); + assertNotNull("check response object is not null after update resource", getRestResponse); + parseResponseAndValidate(updatedResourceDetails, getRestResponse); + + ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1"); + } + + // Benny + + @Test + public void Validation_UpdateIcon() throws Exception { + // Fields to update (Forbidden) + String _updatedIcon = "mySecondIcon.Jpg"; + + // administrator permissions + User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + + // define and create resource + ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1"); + + RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + String resourceName = resourceDetails.getName(); + + // update metadata details + ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName); + // change icon of metadata + updatedResourceDetails.setIcon(_updatedIcon); + // PUT request + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, + sdncAdminModifierDetails, resourceDetails.getUniqueId(), ""); + + // validate response + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), + Arrays.asList("Resource"), updatedRestResponse.getResponse()); + + // empty icon + _updatedIcon = ""; + updatedResourceDetails.setIcon(_updatedIcon); + updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails, + resourceDetails.getUniqueId(), ""); + assertNotNull("check response object is not null after update resource", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), + Arrays.asList("Resource"), updatedRestResponse.getResponse()); + + // get resource with original name. original metadata should be returned + RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails, + resourceDetails.getUniqueId()); + // validate response + assertNotNull("check response object is not null after get resource", getRestResponse); + assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue()); + + // parse updated response to javaObject + Resource getResourceRespJavaObject = ResponseParser + .convertResourceResponseToJavaObject(getRestResponse.getResponse()); + // validate that metadata was not changed + ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject); + + ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(), + "0.1"); + + } + + @Test + public void UpdateResourceTypeSuccess() throws Exception { + // LCS is CheckOut + String newResourceType = ResourceTypeEnum.VL.toString(); + String currentResourceType = resourceDetails.getResourceType(); + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + Resource currentResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); + + resourceDetails.setResourceType(newResourceType); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); + assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue()); + Resource updatedResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(updatedRestResponse.getResponse()); + // assertTrue("Check resource type after update resource", + // updatedResourceJavaObject.getResourceType().toString().equals(resourceType)); + assertTrue("Check resource type after update resource", + updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType)); + + } + + @Test + public void UpdateResourceTypeAndNameSuccess() throws Exception { + // LCS is CheckOut + String newResourceType = ResourceTypeEnum.VL.toString(); + String currentResourceType = resourceDetails.getResourceType(); + String newResourceName = "new Name"; + + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + Resource currentResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); + + resourceDetails.setResourceType(newResourceType); + resourceDetails.setName(newResourceName); + List<String> tags = resourceDetails.getTags(); + tags.add(newResourceName); + resourceDetails.setTags(tags); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); + assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue()); + Resource updatedResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(updatedRestResponse.getResponse()); + assertTrue("Check resource type after update resource", + updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType)); + assertTrue("Check resource name after update resource", + updatedResourceJavaObject.getName().equals(newResourceName)); + + } + + @Test + public void UpdateResourceTypeAfterResourceCertification() throws Exception { + + String newResourceType = ResourceTypeEnum.VF.toString(); + String currentResourceType = resourceDetails.getResourceType(); + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + Resource currentResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); + + resourceDetails.setResourceType(newResourceType); + restResponse = LifecycleRestUtils.certifyResource(resourceDetails); + assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); + restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + LifeCycleStatesEnum.CHECKOUT); + assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); + currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse()); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); + assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue()); + Resource updatedResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(updatedRestResponse.getResponse()); + // assertTrue("Check resource type after update resource", + // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType)); + assertTrue("Check resource type after update resource", + updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType)); + + } + + @Test + public void UpdateResourceTypeCheckInLCS() throws Exception { + + String resourceType = ResourceTypeEnum.VL.toString(); + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + Resource currentResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); + + resourceDetails.setResourceType(resourceType); + restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, + LifeCycleStatesEnum.CHECKIN); + assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); + + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); + + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); + + assertNotNull("check response object is not null after create resouce", updatedRestResponse); + assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after create resource", errorInfo.getCode(), + updatedRestResponse.getErrorCode()); + + List<String> variables = new ArrayList<>(); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResourceTypeCertifiedLCS() throws Exception { + + String resourceType = ResourceTypeEnum.VL.toString(); + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + Resource currentResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); + + restResponse = LifecycleRestUtils.certifyResource(resourceDetails); + assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue()); + + resourceDetails.setResourceType(resourceType); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); + + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); + + assertNotNull("check response object is not null after create resouce", updatedRestResponse); + assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after create resource", errorInfo.getCode(), + updatedRestResponse.getErrorCode()); + + List<String> variables = new ArrayList<>(); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables, + updatedRestResponse.getResponse()); + + } + + @Test + public void UpdateResourceTypeInvalidType() throws Exception { + + String resourceType = "INVALID TYPE"; + RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails); + assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue()); + Resource currentResourceJavaObject = ResponseParser + .convertResourceResponseToJavaObject(restResponse.getResponse()); - resourceDetails.setResourceType(resourceType); - RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, - sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); - - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name()); - - assertNotNull("check response object is not null after update resouce", updatedRestResponse); - assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); - assertEquals("Check response code after update resource", errorInfo.getCode(), - updatedRestResponse.getErrorCode()); + resourceDetails.setResourceType(resourceType); + RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, + sdncModifierDetails, currentResourceJavaObject.getUniqueId(), ""); + + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name()); + + assertNotNull("check response object is not null after update resouce", updatedRestResponse); + assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode()); + assertEquals("Check response code after update resource", errorInfo.getCode(), + updatedRestResponse.getErrorCode()); - List<String> variables = new ArrayList<>(); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables, - updatedRestResponse.getResponse()); + List<String> variables = new ArrayList<>(); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables, + updatedRestResponse.getResponse()); - } + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java index 895390f764..82a894f4eb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java @@ -20,14 +20,8 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import com.google.gson.Gson; +import fj.data.Either; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -49,19 +43,18 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; 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.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -import fj.data.Either; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; public class VFResourceInstanceNameCRUD extends ComponentBaseTest { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java index 37e7539fd9..c731b59184 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java @@ -20,11 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.List; - +import fj.data.Either; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; @@ -36,12 +32,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; 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.AssocType; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; @@ -51,7 +42,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import fj.data.Either; +import java.util.List; + +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertTrue; public class ValidateExtendedVfData extends ComponentBaseTest { @@ -217,7 +211,7 @@ public class ValidateExtendedVfData extends ComponentBaseTest { callAllCheckMethods(resource); } - @Test + /*@Test public void lifeCycleRequestForCertification() throws Exception { RestResponse response = LifecycleRestUtils.changeComponentState(resourceDetailsVF, sdncUserDetails, @@ -232,7 +226,7 @@ public class ValidateExtendedVfData extends ComponentBaseTest { Resource resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse()); callAllCheckMethods(resource); - } + }*/ @Test public void lifeCycleCertificationRequest() throws Exception { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java index dddab57873..e966b4aae9 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java @@ -20,56 +20,31 @@ package org.openecomp.sdc.ci.tests.execute.resource; -import static org.junit.Assert.assertTrue; -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_DELETE; -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_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; - -import java.io.IOException; -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.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.CapReqDef; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.RelationshipImpl; -import org.openecomp.sdc.be.model.RelationshipInfo; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; 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.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; 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.ComponentRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.BaseValidationUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertTrue; +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*; + public class VfComponentInstanceCRUDTest extends ComponentInstanceBaseTest { @Rule @@ -1728,7 +1703,7 @@ public class VfComponentInstanceCRUDTest extends ComponentInstanceBaseTest { } - @Test + /*@Test public void testUnsatisfiedCpReqInVF() throws Exception { // Certify all the needed atomic resources @@ -1766,7 +1741,7 @@ public class VfComponentInstanceCRUDTest extends ComponentInstanceBaseTest { submitForTesting = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST); BaseValidationUtils.checkSuccess(submitForTesting); - } + }*/ private void getVfResourceReqCapUsingAPI(int numberOfRIs, int numberOfRelations, User user) throws IOException, Exception { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java index c8a20cf44a..5bb01d5dd6 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java @@ -20,23 +20,11 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -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.ResourceTypeEnum; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.DistributionStatusEnum; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; @@ -59,6 +47,12 @@ import org.openecomp.sdc.ci.tests.utils.validation.ServiceValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.testng.AssertJUnit.*; + public class ChangeServiceDistributionStatusApiTest extends ComponentBaseTest { protected ResourceReqDetails resourceDetails; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java index 56cfeb54ea..071624676f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java @@ -20,14 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - +import com.fasterxml.jackson.annotation.JsonIgnore; import org.json.JSONObject; import org.junit.Rule; import org.junit.rules.TestName; @@ -56,12 +49,7 @@ import org.openecomp.sdc.ci.tests.utils.DbUtils; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; 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.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.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; 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.ServiceValidationUtils; @@ -69,7 +57,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Test; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; public class CreateServiceMetadataApiTest extends ComponentBaseTest { private static Logger logger = LoggerFactory.getLogger(CreateServiceMetadataApiTest.class.getName()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java index 760d002856..a0091f9a7a 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java @@ -20,14 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -54,6 +46,14 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + public class GetAllServiceVersions extends ComponentBaseTest { protected ResourceReqDetails resourceDetails; protected ServiceReqDetails serviceDetails; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java index 0417d565e3..544a7b1b63 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java @@ -20,14 +20,9 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import fj.data.Either; import org.apache.http.HttpStatus; import org.junit.Rule; import org.junit.rules.TestName; @@ -50,23 +45,21 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.general.FileUtils; -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.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.rest.*; import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; import org.openecomp.sdc.common.datastructure.Wrapper; import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import fj.data.Either; +import static org.testng.AssertJUnit.assertTrue; public class GetComponentAuditApiTest extends ComponentBaseTest { @@ -140,7 +133,7 @@ public class GetComponentAuditApiTest extends ComponentBaseTest { List<String> actions = new ArrayList<>(); JsonArray jsonArray = element.getAsJsonArray(); for( int i =0 ; i < jsonArray.size(); i++){ - actions.add(jsonArray.get(i).getAsJsonObject().get(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName()).getAsString()); + actions.add(jsonArray.get(i).getAsJsonObject().get(AuditingFieldsKey.AUDIT_ACTION.getDisplayName()).getAsString()); } long checkinCount = actions.stream().filter( e -> e.equals(AuditingActionEnum.CHECKIN_RESOURCE.getName())).count(); assertTrue(checkinCount == 5); @@ -161,13 +154,13 @@ public class GetComponentAuditApiTest extends ComponentBaseTest { } protected void certifyResource(ResourceReqDetails defaultResource) throws IOException { - RestResponse response = LifecycleRestUtils.changeResourceState(defaultResource, sdncDesignerUser, +/* RestResponse response = LifecycleRestUtils.changeResourceState(defaultResource, sdncDesignerUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST); AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK); response = LifecycleRestUtils.changeResourceState(defaultResource, sdncTesterUser, LifeCycleStatesEnum.STARTCERTIFICATION); - AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK); - response = LifecycleRestUtils.changeResourceState(defaultResource, sdncTesterUser, LifeCycleStatesEnum.CERTIFY); + AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK);*/ + RestResponse response = LifecycleRestUtils.changeResourceState(defaultResource, sdncTesterUser, LifeCycleStatesEnum.CERTIFY); AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java index 19bed4d380..fc99946b91 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java @@ -20,13 +20,9 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.List; - +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -39,646 +35,638 @@ 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.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.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; 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.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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; +import java.util.ArrayList; +import java.util.List; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION; +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertTrue; public class GetServiceLatestVersionTest extends ComponentInstanceBaseTest { - protected ArtifactReqDetails heatArtifactDetails; - - @Rule - public static TestName name = new TestName(); - - public GetServiceLatestVersionTest() { - super(name, GetServiceLatestVersionTest.class.getName()); - } - - @BeforeMethod - public void before() throws Exception { - initMembers(); - createAtomicResource(resourceDetailsVFC_01); - changeResourceStateToCertified(resourceDetailsVFC_01); - createAtomicResource(resourceDetailsCP_01); - changeResourceStateToCertified(resourceDetailsCP_01); - createAtomicResource(resourceDetailsVL_01); - changeResourceStateToCertified(resourceDetailsVL_01); - createVF(resourceDetailsVF_01); - certifyVf(resourceDetailsVF_01); - createService(serviceDetails_01); - createService(serviceDetails_02); - createService(serviceDetails_03); - createProduct(productDetails_01); - createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // create - // certified - // VF - // instance - // in - // service - /* - * RestResponse restResponse = + protected ArtifactReqDetails heatArtifactDetails; + + @Rule + public static TestName name = new TestName(); + + public GetServiceLatestVersionTest() { + super(name, GetServiceLatestVersionTest.class.getName()); + } + + @BeforeMethod + public void before() throws Exception { + initMembers(); + createAtomicResource(resourceDetailsVFC_01); + changeResourceStateToCertified(resourceDetailsVFC_01); + createAtomicResource(resourceDetailsCP_01); + changeResourceStateToCertified(resourceDetailsCP_01); + createAtomicResource(resourceDetailsVL_01); + changeResourceStateToCertified(resourceDetailsVL_01); + createVF(resourceDetailsVF_01); + certifyVf(resourceDetailsVF_01); + createService(serviceDetails_01); + createService(serviceDetails_02); + createService(serviceDetails_03); + createProduct(productDetails_01); + createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // create + // certified + // VF + // instance + // in + // service + /* + * RestResponse restResponse = * LifecycleRestUtils.changeServiceState(serviceDetails_01, * sdncDesignerDetails, LifeCycleStates.CHECKIN); * ResourceRestUtils.checkSuccess(restResponse); */ - } - - public void initMembers() throws Exception { - heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); - sdncPsDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST1); - sdncPmDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); - sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - sdncTesterDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - resourceDetailsVFC_01 = ElementFactory.getDefaultResourceByType("VFC100", NormativeTypesEnum.COMPUTE, - ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), - ResourceTypeEnum.VFC.toString()); // resourceType = VFC - resourceDetailsVF_01 = ElementFactory.getDefaultResourceByType("VF100", NormativeTypesEnum.ROOT, - ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), - ResourceTypeEnum.VF.toString()); - resourceDetailsCP_01 = ElementFactory.getDefaultResourceByType("CP100", NormativeTypesEnum.PORT, - ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), - ResourceTypeEnum.CP.toString()); - resourceDetailsVL_01 = ElementFactory.getDefaultResourceByType("VL100", NormativeTypesEnum.NETWORK, - ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), - ResourceTypeEnum.VL.toString()); - serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY, - sdncDesignerDetails.getUserId()); - serviceDetails_02 = ElementFactory.getDefaultService("newtestservice2", ServiceCategoriesEnum.MOBILITY, - sdncDesignerDetails.getUserId()); - serviceDetails_03 = ElementFactory.getDefaultService("newtestservice3", ServiceCategoriesEnum.MOBILITY, - sdncDesignerDetails.getUserId()); - productDetails_01 = ElementFactory.getDefaultProduct("product01"); - } - - @Test - public void getServicesLatestVersionServiceInCheckOutState() throws Exception { - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertNull("No Service returned, one service in checkout state 0.1", servcieFromList); - } - - @Test - public void getServicesLatestVersionServiceInCheckInState() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.1")); - } - - @Test - public void getServicesLatestVersionByPm() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPmDetails1); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.1")); - } - - @Test - public void getServicesLatestVersionByAdmin() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncAdminDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.1")); - } - - @Test - public void getServicesLatestVersionService02CheckOutState() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - String serviceUniqueID = ResponseParser.getUniqueIdFromResponse(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueID); - assertTrue(servcieFromList.getVersion().equals("0.1")); - servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertNull(servcieFromList); - } - - @Test - public void getServicesLatestVersionService02CheckInState() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.2")); - } - - @Test - public void getServicesLatestVersionServiceWaitingForCertification() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.2")); - } - - @Test - public void getServicesLatestVersionServiceCertificationInProgress() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, - LifeCycleStatesEnum.STARTCERTIFICATION); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.2")); - } - - @Test - public void getServicesLatestVersionServiceCertificationFail() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, - LifeCycleStatesEnum.STARTCERTIFICATION); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, - LifeCycleStatesEnum.FAILCERTIFICATION); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.2")); - } - - @Test - public void getServicesLatestVersionServiceCertifed() throws Exception { - certifyService(serviceDetails_01); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("1.0")); - } - - @Test - public void getLatestVersionServiceHasSeveralCertifedVersion_01() throws Exception { - RestResponse certifyServiceResponse; - String serviceUniqueIdFromResponse = null; - int numberOfCertifiedService = 3; - for (int i = 0; i < numberOfCertifiedService; i++) { - certifyServiceResponse = certifyService(serviceDetails_01); - ServiceRestUtils.checkSuccess(certifyServiceResponse); - if (i == (numberOfCertifiedService - 1)) { - serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(certifyServiceResponse); - } - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - } - // We have service with following versions : 1.0, 2.0 ,3.0 and - // 3.1(checkedOut) - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse); - assertTrue(servcieFromList.getVersion().equals("3.0")); - } - - @Test - public void getLatestVersionServiceHasSeveralCertifedVersions02() throws Exception { - RestResponse certifyServiceResponse; - certifyServiceResponse = certifyService(serviceDetails_01); - ServiceRestUtils.checkSuccess(certifyServiceResponse); - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - certifyServiceResponse = certifyService(serviceDetails_01); - ServiceRestUtils.checkSuccess(certifyServiceResponse); - // We have service with following versions : 1.0, 2.0 - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("2.0")); - } - - @Test - public void getLatestVersionServiceCertifedWasCheckedOutAndCheckedin() throws Exception { - RestResponse certifyServiceResponse; - int numberOfCertifiedService = 3; - for (int i = 0; i < numberOfCertifiedService; i++) { - certifyServiceResponse = certifyService(serviceDetails_01); - ServiceRestUtils.checkSuccess(certifyServiceResponse); - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - } - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - // We have service with following versions : 1.0, 2.0 and 2.1(checkedIn) - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("3.1")); - } - - @Test - public void getLatestVersionServiceCheckOutCertifedService() throws Exception { - RestResponse restResponse; - String serviceUniqueIdFromResponse = null; - RestResponse certifyServiceResponse = certifyService(serviceDetails_01); - ServiceRestUtils.checkSuccess(certifyServiceResponse); - for (int i = 0; i < 11; i++) { - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - if (i == (10)) { - serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); - } - } - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - // We have service with following versions : 1.0 and 1.11(Check-out) - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse); - assertTrue(servcieFromList.getVersion().equals("1.11")); - } - - @Test - public void getLatestVersionServiceCheckOutCheckInCertifedService() throws Exception { - RestResponse restResponse; - String serviceUniqueIdFromResponse = null; - RestResponse certifyServiceResponse = certifyService(serviceDetails_01); - ServiceRestUtils.checkSuccess(certifyServiceResponse); - for (int i = 0; i < 12; i++) { - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - if (i == (11)) { - serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); - } - } - // We have service with following versions : 1.0 and 1.11(Check-out) - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse); - assertTrue(servcieFromList.getVersion().equals("1.12")); - } - - @Test - public void getLatestVersionServiceCertifedCheckedOutAndInWaitingForCertificationState() throws Exception { - certifyService(serviceDetails_01); // 1.0 - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ServiceRestUtils.checkSuccess(restResponse); - // We have service with following versions : 1.0 and 1.1(Waiting For - // Certification) - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("1.1")); - } - - @Test - public void getLatestVersionServiceCertifedCheckedOutAndInCertificationInProgressState() throws Exception { - certifyService(serviceDetails_01); // 1.0 - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, - LifeCycleStatesEnum.STARTCERTIFICATION); - ServiceRestUtils.checkSuccess(restResponse); - // We have service with following versions : 1.0 and 1.1(Certification - // In Progress) - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("1.1")); - } - - // DE190818 - @Test(enabled = false) - public void getLatestVersionByNonAsdcUser() throws Exception { - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - nonAsdcUser.setUserId("gg750g"); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser); - assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), - getServicesLatestVersion.getResponse()); - } - - // DE190818 - @Test(enabled = false) - public void getLatestVersionUserIdIsEmpty() throws Exception { - User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - nonAsdcUser.setUserId(""); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser); - assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), - getServicesLatestVersion.getResponse()); - } - - @Test - public void getServicesLatestVersionByTester() throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncTesterDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 1); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.1")); - } - - @Test - public void getLatestVersionSeveralServicesInDifferentVersion() throws Exception { - RestResponse restResponse = certifyService(serviceDetails_01); // 1.0 - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = certifyService(serviceDetails_01); - ServiceRestUtils.checkSuccess(restResponse); - String service1_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_01 - // version is 2.1 - // (check-out) - - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_02 - // version 0.2 - // (Check-in) - - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - String service3_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_03 - // version 0.2 - // (Check-out) - - RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); - ServiceRestUtils.checkSuccess(getServicesLatestVersion); - List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); - assertTrue(serviceList.size() == 3); - Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service1_UniqueIdFromResponse); - assertTrue(servcieFromList.getVersion().equals("2.0")); - servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_02.getUniqueId()); - assertTrue(servcieFromList.getVersion().equals("0.2")); - servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service3_UniqueIdFromResponse); - assertTrue(servcieFromList.getVersion().equals("0.1")); - } - - /////////////////////////////////////////////////////////////// - private RestResponse certifyService(ServiceReqDetails serviceDetails) throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKOUT); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, - LifeCycleStatesEnum.CERTIFICATIONREQUEST); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, - LifeCycleStatesEnum.STARTCERTIFICATION); - ServiceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, - LifeCycleStatesEnum.CERTIFY); - ServiceRestUtils.checkSuccess(restResponse); - return restResponse; - } - - protected List<Service> restResponseToResourceObjectList(RestResponse restResponse) { - JsonElement jelement = new JsonParser().parse(restResponse.getResponse()); - JsonArray jsonArray = jelement.getAsJsonArray(); - List<Service> restResponseArray = new ArrayList<>(); - Service service = null; - for (int i = 0; i < jsonArray.size(); i++) { - String serviceString = (String) jsonArray.get(i).toString(); - service = ResponseParser.convertServiceResponseToJavaObject(serviceString); - restResponseArray.add(service); - } - return restResponseArray; - } - - protected Service getResourceObjectFromResourceListByUid(List<Service> serviceList, String uid) { - if (serviceList != null && serviceList.size() > 0) { - for (Service service : serviceList) { - if (service.getUniqueId().equals(uid)) - return service; - } - } else - return null; - return null; - } - - private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception { - RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, - LifeCycleStatesEnum.CHECKIN); - ResourceRestUtils.checkSuccess(restResponse); - restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, + } + + public void initMembers() throws Exception { + heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()); + sdncPsDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST1); + sdncPmDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); + sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + sdncTesterDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); + resourceDetailsVFC_01 = ElementFactory.getDefaultResourceByType("VFC100", NormativeTypesEnum.COMPUTE, + ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), + ResourceTypeEnum.VFC.toString()); // resourceType = VFC + resourceDetailsVF_01 = ElementFactory.getDefaultResourceByType("VF100", NormativeTypesEnum.ROOT, + ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), + ResourceTypeEnum.VF.toString()); + resourceDetailsCP_01 = ElementFactory.getDefaultResourceByType("CP100", NormativeTypesEnum.PORT, + ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), + ResourceTypeEnum.CP.toString()); + resourceDetailsVL_01 = ElementFactory.getDefaultResourceByType("VL100", NormativeTypesEnum.NETWORK, + ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), + ResourceTypeEnum.VL.toString()); + serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY, + sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue()); + serviceDetails_02 = ElementFactory.getDefaultService("newtestservice2", ServiceCategoriesEnum.MOBILITY, + sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue()); + serviceDetails_03 = ElementFactory.getDefaultService("newtestservice3", ServiceCategoriesEnum.MOBILITY, + sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue()); + productDetails_01 = ElementFactory.getDefaultProduct("product01"); + } + + @Test + public void getServicesLatestVersionServiceInCheckOutState() throws Exception { + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertNull("No Service returned, one service in checkout state 0.1", servcieFromList); + } + + @Test + public void getServicesLatestVersionServiceInCheckInState() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.1")); + } + + @Test + public void getServicesLatestVersionByPm() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPmDetails1); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.1")); + } + + @Test + public void getServicesLatestVersionByAdmin() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncAdminDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.1")); + } + + @Test + public void getServicesLatestVersionService02CheckOutState() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + String serviceUniqueID = ResponseParser.getUniqueIdFromResponse(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueID); + assertTrue(servcieFromList.getVersion().equals("0.1")); + servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertNull(servcieFromList); + } + + @Test + public void getServicesLatestVersionService02CheckInState() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.2")); + } + + @Test + public void getServicesLatestVersionServiceWaitingForCertification() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CERTIFICATIONREQUEST); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.2")); + } + + @Test + public void getServicesLatestVersionServiceCertificationInProgress() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CERTIFICATIONREQUEST); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, + LifeCycleStatesEnum.STARTCERTIFICATION); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.2")); + } + + @Test + public void getServicesLatestVersionServiceCertificationFail() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CERTIFICATIONREQUEST); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, + LifeCycleStatesEnum.STARTCERTIFICATION); + ResourceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, + LifeCycleStatesEnum.FAILCERTIFICATION); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.2")); + } + + @Test + public void getServicesLatestVersionServiceCertifed() throws Exception { + certifyService(serviceDetails_01); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("1.0")); + } + + @Test + public void getLatestVersionServiceHasSeveralCertifedVersion_01() throws Exception { + RestResponse certifyServiceResponse; + String serviceUniqueIdFromResponse = null; + int numberOfCertifiedService = 3; + for (int i = 0; i < numberOfCertifiedService; i++) { + certifyServiceResponse = certifyService(serviceDetails_01); + ServiceRestUtils.checkSuccess(certifyServiceResponse); + if (i == (numberOfCertifiedService - 1)) { + serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(certifyServiceResponse); + } + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + } + // We have service with following versions : 1.0, 2.0 ,3.0 and + // 3.1(checkedOut) + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse); + assertTrue(servcieFromList.getVersion().equals("3.0")); + } + + @Test + public void getLatestVersionServiceHasSeveralCertifedVersions02() throws Exception { + RestResponse certifyServiceResponse; + certifyServiceResponse = certifyService(serviceDetails_01); + ServiceRestUtils.checkSuccess(certifyServiceResponse); + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + certifyServiceResponse = certifyService(serviceDetails_01); + ServiceRestUtils.checkSuccess(certifyServiceResponse); + // We have service with following versions : 1.0, 2.0 + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("2.0")); + } + + @Test + public void getLatestVersionServiceCertifedWasCheckedOutAndCheckedin() throws Exception { + RestResponse certifyServiceResponse; + int numberOfCertifiedService = 3; + for (int i = 0; i < numberOfCertifiedService; i++) { + certifyServiceResponse = certifyService(serviceDetails_01); + ServiceRestUtils.checkSuccess(certifyServiceResponse); + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + } + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + // We have service with following versions : 1.0, 2.0 and 2.1(checkedIn) + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("3.1")); + } + + @Test + public void getLatestVersionServiceCheckOutCertifedService() throws Exception { + RestResponse restResponse; + String serviceUniqueIdFromResponse = null; + RestResponse certifyServiceResponse = certifyService(serviceDetails_01); + ServiceRestUtils.checkSuccess(certifyServiceResponse); + for (int i = 0; i < 11; i++) { + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + if (i == (10)) { + serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); + } + } + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + // We have service with following versions : 1.0 and 1.11(Check-out) + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse); + assertTrue(servcieFromList.getVersion().equals("1.11")); + } + + @Test + public void getLatestVersionServiceCheckOutCheckInCertifedService() throws Exception { + RestResponse restResponse; + String serviceUniqueIdFromResponse = null; + RestResponse certifyServiceResponse = certifyService(serviceDetails_01); + ServiceRestUtils.checkSuccess(certifyServiceResponse); + for (int i = 0; i < 12; i++) { + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + if (i == (11)) { + serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); + } + } + // We have service with following versions : 1.0 and 1.11(Check-out) + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse); + assertTrue(servcieFromList.getVersion().equals("1.12")); + } + + @Test + public void getLatestVersionServiceCertifedCheckedOutAndInWaitingForCertificationState() throws Exception { + certifyService(serviceDetails_01); // 1.0 + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CERTIFICATIONREQUEST); + ServiceRestUtils.checkSuccess(restResponse); + // We have service with following versions : 1.0 and 1.1(Waiting For + // Certification) + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("1.1")); + } + + @Test + public void getLatestVersionServiceCertifedCheckedOutAndInCertificationInProgressState() throws Exception { + certifyService(serviceDetails_01); // 1.0 + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CERTIFICATIONREQUEST); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails, + LifeCycleStatesEnum.STARTCERTIFICATION); + ServiceRestUtils.checkSuccess(restResponse); + // We have service with following versions : 1.0 and 1.1(Certification + // In Progress) + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("1.1")); + } + + // DE190818 + @Test(enabled = false) + public void getLatestVersionByNonAsdcUser() throws Exception { + User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + nonAsdcUser.setUserId("gg750g"); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser); + assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), + getServicesLatestVersion.getResponse()); + } + + // DE190818 + @Test(enabled = false) + public void getLatestVersionUserIdIsEmpty() throws Exception { + User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + nonAsdcUser.setUserId(""); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser); + assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), + getServicesLatestVersion.getResponse()); + } + + @Test + public void getServicesLatestVersionByTester() throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ResourceRestUtils.checkSuccess(restResponse); + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncTesterDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 1); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.1")); + } + + @Test + public void getLatestVersionSeveralServicesInDifferentVersion() throws Exception { + RestResponse restResponse = certifyService(serviceDetails_01); // 1.0 + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = certifyService(serviceDetails_01); + ServiceRestUtils.checkSuccess(restResponse); + String service1_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_01 + // version is 2.1 + // (check-out) + + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_02 + // version 0.2 + // (Check-in) + + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + String service3_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_03 + // version 0.2 + // (Check-out) + + RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails); + ServiceRestUtils.checkSuccess(getServicesLatestVersion); + List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion); + assertTrue(serviceList.size() == 3); + Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service1_UniqueIdFromResponse); + assertTrue(servcieFromList.getVersion().equals("2.0")); + servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_02.getUniqueId()); + assertTrue(servcieFromList.getVersion().equals("0.2")); + servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service3_UniqueIdFromResponse); + assertTrue(servcieFromList.getVersion().equals("0.1")); + } + + /////////////////////////////////////////////////////////////// + private RestResponse certifyService(ServiceReqDetails serviceDetails) throws Exception { + RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKOUT); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, + LifeCycleStatesEnum.CHECKIN); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, + LifeCycleStatesEnum.CERTIFICATIONREQUEST); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, + LifeCycleStatesEnum.STARTCERTIFICATION); + ServiceRestUtils.checkSuccess(restResponse); + restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, + LifeCycleStatesEnum.CERTIFY); + ServiceRestUtils.checkSuccess(restResponse); + return restResponse; + } + + protected List<Service> restResponseToResourceObjectList(RestResponse restResponse) { + JsonElement jelement = new JsonParser().parse(restResponse.getResponse()); + JsonArray jsonArray = jelement.getAsJsonArray(); + List<Service> restResponseArray = new ArrayList<>(); + Service service = null; + for (int i = 0; i < jsonArray.size(); i++) { + String serviceString = (String) jsonArray.get(i).toString(); + service = ResponseParser.convertServiceResponseToJavaObject(serviceString); + restResponseArray.add(service); + } + return restResponseArray; + } + + protected Service getResourceObjectFromResourceListByUid(List<Service> serviceList, String uid) { + if (serviceList != null && serviceList.size() > 0) { + for (Service service : serviceList) { + if (service.getUniqueId().equals(uid)) + return service; + } + } else + return null; + return 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) throws Exception { - // RestResponse createAtomicResourceInstance = - // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_01, - // sdncDesignerDetails); - // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - // createAtomicResourceInstance = - // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01, - // sdncDesignerDetails); - // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - // createAtomicResourceInstance = - // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01, - // sdncDesignerDetails); - // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); - // //createVFInstanceDuringSetup(service, resource, sdncDesignerDetails); - // RestResponse response = - // ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, - // sdncDesignerDetails, resource.getUniqueId()); - // ResourceRestUtils.checkSuccess(response); - // RestResponse changeResourceStateToCertified = - // changeResourceStateToCertified(resource); - // ResourceRestUtils.checkSuccess(changeResourceStateToCertified); - // } - - 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_01, - 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); - } + 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) throws Exception { + // RestResponse createAtomicResourceInstance = + // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_01, + // sdncDesignerDetails); + // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); + // createAtomicResourceInstance = + // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01, + // sdncDesignerDetails); + // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); + // createAtomicResourceInstance = + // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01, + // sdncDesignerDetails); + // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); + // //createVFInstanceDuringSetup(service, resource, sdncDesignerDetails); + // RestResponse response = + // ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, + // sdncDesignerDetails, resource.getUniqueId()); + // ResourceRestUtils.checkSuccess(response); + // RestResponse changeResourceStateToCertified = + // changeResourceStateToCertified(resource); + // ResourceRestUtils.checkSuccess(changeResourceStateToCertified); + // } + + 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_01, + 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); + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java index fdec8346fc..6db27b9e4f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java @@ -20,57 +20,34 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; - import org.apache.http.client.ClientProtocolException; 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.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.CapReqDef; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.RelationshipImpl; -import org.openecomp.sdc.be.model.RelationshipInfo; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -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.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; 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.general.ImportUtils; -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.ComponentRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS; +import static org.testng.AssertJUnit.*; + public class ReqCapOccurrencesTest extends ComponentInstanceBaseTest { private ImportReqDetails importReqDetails1; // atomic resource @@ -164,7 +141,7 @@ public class ReqCapOccurrencesTest extends ComponentInstanceBaseTest { ResourceRestUtils.checkCreateResponse(createResourceVF200); // Create Service serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY, - sdncDesignerDetails.getUserId()); + sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue()); RestResponse createServiceRestResponse = ServiceRestUtils.createService(serviceDetails_01, sdncDesignerDetails); ResourceRestUtils.checkCreateResponse(createServiceRestResponse); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java index b2728ea0da..60ca71d676 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java @@ -20,45 +20,20 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.codehaus.jettison.json.JSONException; import org.json.JSONArray; 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.CapReqDef; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; 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.ComponentReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.*; 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.ComponentRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -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.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.slf4j.Logger; @@ -67,6 +42,15 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest { private static Logger log = LoggerFactory.getLogger(ServiceComponentInstanceCRUDTest.class.getName()); private static final String SPACE_STRING = " "; @@ -115,9 +99,9 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest } private void certifyResource(ResourceReqDetails resource) throws Exception { - changeResourceLifecycleState(resource, sdncDesignerDetails.getUserId(), + /*changeResourceLifecycleState(resource, sdncDesignerDetails.getUserId(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); - changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.STARTCERTIFICATION); + changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.STARTCERTIFICATION);*/ changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.CERTIFY); } @@ -444,7 +428,7 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest getComponentAndValidateRIs(serviceDetails_01, 2, 0); } - @Test + /*@Test public void createResourceInstance_ResourceInCertificationRequestStateTest() throws Exception { changeResourceLifecycleState(resourceDetailsVF_01, sdncDesignerDetails.getUserId(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); @@ -453,9 +437,9 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01); getComponentAndValidateRIs(serviceDetails_01, 2, 0); - } + }*/ - @Test + /*@Test public void createResourceInstance_startCertificationStateTest() throws Exception { changeResourceLifecycleState(resourceDetailsVF_01, sdncDesignerDetails.getUserId(), LifeCycleStatesEnum.CERTIFICATIONREQUEST); @@ -471,7 +455,7 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest sdncDesignerDetails); getComponentAndValidateRIs(serviceDetails_01, 2, 0); - } + }*/ @Test public void createResourceInstance_certifiedStateTest() throws Exception { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java index 304f61d280..18c2614040 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java @@ -20,13 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.service; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.apache.commons.lang3.StringUtils; import org.codehaus.jettison.json.JSONException; import org.junit.Rule; @@ -59,6 +52,13 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + public class UpdateServiceMetadataTest extends ComponentBaseTest { protected ArrayList<String> listForMessage = new ArrayList<String>(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java index 28cf1b787f..df1e6b2a6e 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java @@ -20,18 +20,8 @@ package org.openecomp.sdc.ci.tests.execute.user; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - +import com.google.gson.*; +import com.google.gson.reflect.TypeToken; import org.apache.http.HttpStatus; import org.junit.Rule; import org.junit.rules.TestName; @@ -54,11 +44,7 @@ import org.openecomp.sdc.ci.tests.users.UserResponseMessageEnum; import org.openecomp.sdc.ci.tests.utils.DbUtils; 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.CatalogRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils; -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.UserRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; 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.ResourceValidationUtils; @@ -69,12 +55,10 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; +import java.util.*; +import java.util.Map.Entry; + +import static org.testng.AssertJUnit.*; /** * @author alitvinsky diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java index 2f979f3d15..d509966490 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java @@ -20,11 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.user; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.io.IOException; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -47,6 +42,11 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.IOException; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + public class CreateUserApiTest extends ComponentBaseTest { protected User sdncAdminUser; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java index c7c2fdd998..5a56af5d4c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java @@ -20,14 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.user; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.List; - import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.junit.Rule; @@ -50,17 +42,18 @@ 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.AtomicOperationUtils; 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.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ServiceValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.IOException; +import java.util.List; + +import static org.testng.AssertJUnit.*; + public class GovernorWorkspaceApiTest extends ComponentBaseTest { private static Logger logger = LoggerFactory.getLogger(GovernorWorkspaceApiTest.class.getName()); |