aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2019-10-15 10:23:08 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-01-26 09:17:08 +0000
commitcb7a00bf89efca5b784120e990f79c475347e89d (patch)
tree2e434c227f7ac2bf3ba024f9496ded1f399554b9
parentc113cc3f10f72013a66c2eb5a52ab8460da196f9 (diff)
Increase junit TCs
1. Re-enable disabled TCs (enable = true) 2. Enable @Ignored TCs 3. Add some Assert when missing 4. Remove old unused TCs (covered in UI) Change-Id: I900e52f4860b1fdc5bd1e529a1fe7f5c3491465b Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-2672
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMockTest.java244
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java541
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java2636
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnum.java51
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java76
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java749
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java1786
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java631
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java2289
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java138
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java356
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java435
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java1418
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java1719
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java1511
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java2871
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java281
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java1464
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java1161
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java2540
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java1792
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java1397
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java320
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java1770
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java1294
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java672
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java1171
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java1608
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java2157
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java1693
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java310
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java2
-rw-r--r--test-apis-ci/src/main/resources/ci/conf/testngLifeCycle.xml18
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/artifacts.xml24
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/category.xml3
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/ciFull.xml330
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/general.xml4
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/imports.xml7
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/product.xml4
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/productAPIs.xml9
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/resource.xml467
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/sanity.xml614
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/service.xml13
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/testngLifeCycle.xml20
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/user.xml11
-rw-r--r--test-apis-ci/testng.xml8
-rw-r--r--test-apis-ci/testngLifeCycle.xml18
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java2
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java6
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java2
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java8
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java2
53 files changed, 2311 insertions, 36344 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMockTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMockTest.java
index ec63f90491..4c6f4482fe 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMockTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMockTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,7 @@
package org.openecomp.sdc.asdctool.migration.config.mocks;
+import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.openecomp.sdc.be.components.distribution.engine.INotificationData;
@@ -29,122 +30,129 @@ import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
-@Ignore ("This class does not test anything, there is not a single assertion and the code with reflection fails")
+@Ignore("This class does not test anything, there is not a single assertion and the code with reflection fails")
public class DistributionEngineMockTest {
- private DistributionEngineMock createTestSubject() {
- return new DistributionEngineMock();
- }
-
- @Test
- public void testIsActive() throws Exception {
- DistributionEngineMock testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isActive();
- }
-
- @Test
- public void testNotifyService() throws Exception {
- DistributionEngineMock testSubject;
- String distributionId = "";
- Service service = null;
- INotificationData notificationData = null;
- String envName = "";
- String userId = "";
- ActionStatus result;
- User modifierName=new User();
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.notifyService(distributionId, service, notificationData, envName, userId, modifierName);
- }
-
- @Test
- public void testNotifyService_1() throws Exception {
- DistributionEngineMock testSubject;
- String distributionId = "";
- Service service = null;
- INotificationData notificationData = null;
- String envId = "";
- String envName = "";
- String userId = "";
- User modifierName = new User();
- ActionStatus result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.notifyService(distributionId, service, notificationData, envId, envName,
- modifierName);
- }
-
- @Test
- public void testIsEnvironmentAvailable() throws Exception {
- DistributionEngineMock testSubject;
- String envName = "";
- StorageOperationStatus result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isEnvironmentAvailable(envName);
- }
-
- @Test
- public void testIsEnvironmentAvailable_1() throws Exception {
- DistributionEngineMock testSubject;
- StorageOperationStatus result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isEnvironmentAvailable();
- }
-
- @Test
- public void testDisableEnvironment() throws Exception {
- DistributionEngineMock testSubject;
- String envName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.disableEnvironment(envName);
- }
-
- @Ignore
- @Test
- public void testIsReadyForDistribution() throws Exception {
- DistributionEngineMock testSubject;
- Service service = null;
- String envName = "";
- StorageOperationStatus result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isReadyForDistribution(envName);
- }
-
- @Test
- public void testBuildServiceForDistribution() throws Exception {
- DistributionEngineMock testSubject;
- Service service = null;
- String distributionId = "";
- String workloadContext = "";
- INotificationData result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.buildServiceForDistribution(service, distributionId, workloadContext);
- }
-
- @Test
- public void testGetEnvironmentById() throws Exception {
- DistributionEngineMock testSubject;
- String opEnvId = "";
- OperationalEnvironmentEntry result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getEnvironmentById(opEnvId);
- }
+ private DistributionEngineMock createTestSubject() {
+ return new DistributionEngineMock();
+ }
+
+ @Test
+ public void testIsActive() throws Exception {
+ DistributionEngineMock testSubject;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isActive();
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testNotifyService() throws Exception {
+ DistributionEngineMock testSubject;
+ String distributionId = "";
+ Service service = null;
+ INotificationData notificationData = null;
+ String envName = "";
+ String userId = "";
+ ActionStatus result;
+ User modifierName = new User();
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.notifyService(distributionId, service, notificationData, envName, userId, modifierName);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testNotifyService_1() throws Exception {
+ DistributionEngineMock testSubject;
+ String distributionId = "";
+ Service service = null;
+ INotificationData notificationData = null;
+ String envId = "";
+ String envName = "";
+ String userId = "";
+ User modifierName = new User();
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.notifyService(distributionId, service, notificationData, envId, envName,
+ modifierName);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testIsEnvironmentAvailable() throws Exception {
+ DistributionEngineMock testSubject;
+ String envName = "";
+ StorageOperationStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isEnvironmentAvailable(envName);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testIsEnvironmentAvailable_1() throws Exception {
+ DistributionEngineMock testSubject;
+ StorageOperationStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isEnvironmentAvailable();
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testDisableEnvironment() throws Exception {
+ DistributionEngineMock testSubject;
+ String envName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.disableEnvironment(envName);
+ }
+
+ @Test
+ public void testIsReadyForDistribution() throws Exception {
+ DistributionEngineMock testSubject;
+ Service service = null;
+ String envName = "";
+ StorageOperationStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isReadyForDistribution(envName);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testBuildServiceForDistribution() throws Exception {
+ DistributionEngineMock testSubject;
+ Service service = null;
+ String distributionId = "";
+ String workloadContext = "";
+ INotificationData result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.buildServiceForDistribution(service, distributionId, workloadContext);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testGetEnvironmentById() throws Exception {
+ DistributionEngineMock testSubject;
+ String opEnvId = "";
+ OperationalEnvironmentEntry result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getEnvironmentById(opEnvId);
+ Assert.assertNotNull(result);
+ }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index 75bf5a43ea..1bbe0fac88 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -20,7 +20,27 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anySet;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import mockit.Deencapsulation;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.assertj.core.util.Lists;
@@ -59,6 +79,7 @@ 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.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -86,27 +107,6 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anySet;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
/**
* The test suite designed for test functionality of ComponentInstanceBusinessLogic class
*/
@@ -119,6 +119,7 @@ public class ComponentInstanceBusinessLogicTest {
private final static String ORIGIN_COMPONENT_ID = "originComponentId";
private final static String COMPONENT_INST_ID = "componentInstId";
private final static String TO_INSTANCE_ID = "toInstanceId";
+ private final static String TO_INSTANCE_NAME = "toInstanceName";
private final static String COMPONENT_INSTANCE_ID = "componentInstanceId";
private final static String FROM_INSTANCE_ID = "fromInstanceId";
private final static String RELATION_ID = "relationId";
@@ -137,13 +138,16 @@ public class ComponentInstanceBusinessLogicTest {
private final static String PROP_NAME = "propName";
private final static String NON_EXIST_NAME = "nonExistName";
- static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
- "src/test/resources/config/catalog-be");
+ static ConfigurationSource configurationSource = new FSConfigurationSource(
+ ExternalConfiguration.getChangeListener(),
+ "src/test/resources/config/catalog-be");
static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
@InjectMocks
private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
@Mock
+ private ComponentInstancePropInput componentInstancePropInput;
+ @Mock
ArtifactsBusinessLogic artifactsBusinessLogic;
@Mock
private ComponentsUtils componentsUtils;
@@ -180,7 +184,6 @@ public class ComponentInstanceBusinessLogicTest {
private RequirementDataDefinition requirement;
private RequirementCapabilityRelDef relation;
-
@Before
public void init() {
MockitoAnnotations.initMocks(componentInstanceBusinessLogic);
@@ -220,7 +223,7 @@ public class ComponentInstanceBusinessLogicTest {
assertFalse(componentInstanceBusinessLogic.isCloudSpecificArtifact(ARTIFACT_5));
}
- private void getforwardingPathOnVersionChange(){
+ private void getforwardingPathOnVersionChange() {
String containerComponentParam = "services";
String containerComponentID = "121-cont";
String componentInstanceID = "121-cont-1-comp";
@@ -249,22 +252,22 @@ public class ComponentInstanceBusinessLogicTest {
//Mock for getting component
when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
- .thenReturn(Either.left(component));
+ .thenReturn(Either.left(component));
when(toscaOperationFacade.validateComponentExists(any(String.class))).thenReturn(Either.left(Boolean.TRUE));
when(toscaOperationFacade.getToscaFullElement(eq(new_Comp_UID))).thenReturn(Either.left(component2));
Either<Set<String>, ResponseFormat> resultOp = componentInstanceBusinessLogic
- .forwardingPathOnVersionChange(containerComponentParam,
- containerComponentID, componentInstanceID,
- newComponentInstance);
+ .forwardingPathOnVersionChange(containerComponentParam,
+ containerComponentID, componentInstanceID,
+ newComponentInstance);
assertEquals(1, resultOp.left().value().size());
assertEquals("FP-ID-1", resultOp.left().value().iterator().next());
}
@Test
- public void testCreateOrUpdatePropertiesValues2(){
- String containerComponentID="containerId";
+ public void testCreateOrUpdatePropertiesValues2() {
+ String containerComponentID = "containerId";
String resourceInstanceId = "resourceId";
String componentInstanceID = "componentInstance";
List<ComponentInstanceProperty> properties = new ArrayList<>();
@@ -294,35 +297,40 @@ public class ComponentInstanceBusinessLogicTest {
ComponentInstance ci = createComponentInstance("ci1");
ci.setUniqueId("resourceId");
component.setComponentInstances(Arrays.asList(ci, createComponentInstance("ci2"),
- createComponentInstance(componentInstanceID)));
+ createComponentInstance(componentInstanceID)));
HashMap<String, DataTypeDefinition> dataTypeDefinitionHashMap = new HashMap<>();
DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
dataTypeDefinition.setName("string");
dataTypeDefinitionHashMap.put("string", dataTypeDefinition);
//when(userValidations.validateUserExists(user.getUserId(), false)).thenReturn(user);
- when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(component));
- when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll))
+ .thenReturn(Either.left(component));
+ when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
+ .thenReturn(StorageOperationStatus.OK);
when(dataTypeCache.getAll()).thenReturn(Either.left(types));
when(propertyOperation.validateAndUpdatePropertyValue(property.getType(), "newVal", true, null, types))
- .thenReturn(Either.left("newVal"));
+ .thenReturn(Either.left("newVal"));
when(propertyOperation.validateAndUpdateRules("string", property.getRules(),
- null, types, true)).thenReturn(ImmutablePair.of("string", null));
+ null, types, true)).thenReturn(ImmutablePair.of("string", null));
when(toscaOperationFacade.updateComponentInstanceProperty(component, ci.getUniqueId(),
- origProperty)).thenReturn(StorageOperationStatus.OK);
+ origProperty)).thenReturn(StorageOperationStatus.OK);
origProperties.get(0).setValue("newVal");
- when(toscaOperationFacade.updateComponentInstanceMetadataOfTopologyTemplate(component)).thenReturn(Either.left(component));
- when (janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
- when(graphLockOperation.unlockComponent(containerComponentID, NodeTypeEnum.ResourceInstance)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade.updateComponentInstanceMetadataOfTopologyTemplate(component))
+ .thenReturn(Either.left(component));
+ when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
+ when(graphLockOperation.unlockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
+ .thenReturn(StorageOperationStatus.OK);
- Either<List<ComponentInstanceProperty>, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic.createOrUpdatePropertiesValues(
+ Either<List<ComponentInstanceProperty>, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic
+ .createOrUpdatePropertiesValues(
ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
assertThat(responseFormatEither.left().value()).isEqualTo(properties);
}
@Test
- public void testCreateOrUpdatePropertiesValuesPropertyNotExists(){
- String containerComponentID="containerId";
+ public void testCreateOrUpdatePropertiesValuesPropertyNotExists() {
+ String containerComponentID = "containerId";
String resourceInstanceId = "resourceId";
String componentInstanceID = "componentInstance";
List<ComponentInstanceProperty> properties = new ArrayList<>();
@@ -347,32 +355,34 @@ public class ComponentInstanceBusinessLogicTest {
ComponentInstance ci = createComponentInstance("ci1");
ci.setUniqueId("resourceId");
component.setComponentInstances(Arrays.asList(ci, createComponentInstance("ci2"),
- createComponentInstance(componentInstanceID)));
+ createComponentInstance(componentInstanceID)));
HashMap<String, DataTypeDefinition> dataTypeDefinitionHashMap = new HashMap<>();
DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
dataTypeDefinition.setName("string");
dataTypeDefinitionHashMap.put("string", dataTypeDefinition);
//when(userValidations.validateUserExists(user.getUserId(), false)).thenReturn(user);
- when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(component));
- when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll))
+ .thenReturn(Either.left(component));
+ when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
+ .thenReturn(StorageOperationStatus.OK);
//when(dataTypeCache.getAll()).thenReturn(Either.left(types));
//when (janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
- when(graphLockOperation.unlockComponent(containerComponentID, NodeTypeEnum.ResourceInstance)).thenReturn(StorageOperationStatus.OK);
+ when(graphLockOperation.unlockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
+ .thenReturn(StorageOperationStatus.OK);
try {
componentInstanceBusinessLogic.createOrUpdatePropertiesValues(
- ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
+ ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
} catch (ComponentException e) {
assertThat(e.getActionStatus()).isEqualTo(ActionStatus.PROPERTY_NOT_FOUND);
}
}
-
@Test
- public void testCreateOrUpdatePropertiesValuesValidationFailure(){
- String containerComponentID="containerId";
+ public void testCreateOrUpdatePropertiesValuesValidationFailure() {
+ String containerComponentID = "containerId";
String resourceInstanceId = "resourceId";
String componentInstanceID = "componentInstance";
List<ComponentInstanceProperty> properties = new ArrayList<>();
@@ -402,24 +412,27 @@ public class ComponentInstanceBusinessLogicTest {
ComponentInstance ci = createComponentInstance("ci1");
ci.setUniqueId("resourceId");
component.setComponentInstances(Arrays.asList(ci, createComponentInstance("ci2"),
- createComponentInstance(componentInstanceID)));
+ createComponentInstance(componentInstanceID)));
HashMap<String, DataTypeDefinition> dataTypeDefinitionHashMap = new HashMap<>();
DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
dataTypeDefinition.setName("string");
dataTypeDefinitionHashMap.put("string", dataTypeDefinition);
//when(userValidations.validateUserExists(user.getUserId(), false)).thenReturn(user);
- when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(component));
- when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll))
+ .thenReturn(Either.left(component));
+ when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
+ .thenReturn(StorageOperationStatus.OK);
when(dataTypeCache.getAll()).thenReturn(Either.left(types));
when(propertyOperation.validateAndUpdatePropertyValue(property.getType(), "newVal", true, null, types))
- .thenReturn(Either.right(false));
- when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST)).thenReturn(ActionStatus.INVALID_CONTENT);
+ .thenReturn(Either.right(false));
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST))
+ .thenReturn(ActionStatus.INVALID_CONTENT);
- try{
+ try {
componentInstanceBusinessLogic.createOrUpdatePropertiesValues(
- ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
- } catch(ComponentException e){
+ ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
+ } catch (ComponentException e) {
assertThat(e.getActionStatus()).isEqualTo(ActionStatus.INVALID_CONTENT);
return;
}
@@ -427,8 +440,8 @@ public class ComponentInstanceBusinessLogicTest {
}
@Test
- public void testCreateOrUpdatePropertiesValuesMissingFieldFailure(){
- String containerComponentID="containerId";
+ public void testCreateOrUpdatePropertiesValuesMissingFieldFailure() {
+ String containerComponentID = "containerId";
String resourceInstanceId = "resourceId";
String componentInstanceID = "componentInstance";
List<ComponentInstanceProperty> properties = new ArrayList<>();
@@ -453,7 +466,7 @@ public class ComponentInstanceBusinessLogicTest {
ComponentInstance ci = createComponentInstance("ci1");
ci.setUniqueId("resourceId");
component.setComponentInstances(Arrays.asList(ci, createComponentInstance("ci2"),
- createComponentInstance(componentInstanceID)));
+ createComponentInstance(componentInstanceID)));
HashMap<String, DataTypeDefinition> dataTypeDefinitionHashMap = new HashMap<>();
DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
@@ -461,13 +474,15 @@ public class ComponentInstanceBusinessLogicTest {
dataTypeDefinitionHashMap.put("string", dataTypeDefinition);
//when(userValidations.validateUserExists(user.getUserId(), false)).thenReturn(user);
- when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(component));
- when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade.getToscaElement(containerComponentID, JsonParseFlagEnum.ParseAll))
+ .thenReturn(Either.left(component));
+ when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
+ .thenReturn(StorageOperationStatus.OK);
- try{
+ try {
componentInstanceBusinessLogic.createOrUpdatePropertiesValues(
- ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
- } catch(ComponentException e){
+ ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
+ } catch (ComponentException e) {
assertThat(e.getActionStatus()).isEqualTo(ActionStatus.MISSING_PROPERTY_NAME);
}
}
@@ -479,20 +494,22 @@ public class ComponentInstanceBusinessLogicTest {
String containerComponentID = "Service-comp";
String componentInstanceID = "NodeA1";
Service component = new Service();
- component.setComponentInstances(Arrays.asList(createComponentInstance("NodeA2"), createComponentInstance("NodeB2"),
- createComponentInstance(componentInstanceID)));
+ component
+ .setComponentInstances(Arrays.asList(createComponentInstance("NodeA2"), createComponentInstance("NodeB2"),
+ createComponentInstance(componentInstanceID)));
component.addForwardingPath(createPath("path1", componentInstanceID, "NodeB1", "1"));
component.addForwardingPath(createPath("Path2", "NodeA2", "NodeB2", "2"));
when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
- .thenReturn(Either.left(component));
+ .thenReturn(Either.left(component));
when(toscaOperationFacade.getToscaElement(eq(containerComponentID))).thenReturn(Either.left(component));
when(forwardingPathOperation.deleteForwardingPath(any(Service.class), anySet()))
- .thenReturn(Either.left(new HashSet<>()));
+ .thenReturn(Either.left(new HashSet<>()));
final ComponentInstance ci = new ComponentInstance();
ci.setName(componentInstanceID);
- ComponentInstance responseFormatEither = componentInstanceBusinessLogic.deleteForwardingPathsRelatedTobeDeletedComponentInstance(
- containerComponentID, containerComponentType, ci);
+ ComponentInstance responseFormatEither = componentInstanceBusinessLogic
+ .deleteForwardingPathsRelatedTobeDeletedComponentInstance(
+ containerComponentID, containerComponentType, ci);
assertThat(!responseFormatEither.isEmpty()).isEqualTo(true);
}
@@ -508,14 +525,18 @@ public class ComponentInstanceBusinessLogicTest {
Map<String, ArtifactDefinition> artifacts = new HashMap<>();
ArtifactDefinition deploymentArtifact1 = getArtifact("deploymentArtifact1", ArtifactTypeEnum.HEAT.getType());
artifacts.put(deploymentArtifact1.getArtifactLabel(), deploymentArtifact1);
- ArtifactDefinition deploymentArtifact2 = getArtifact("deploymentArtifact2", ArtifactTypeEnum.HEAT_ENV.getType());
+ ArtifactDefinition deploymentArtifact2 = getArtifact("deploymentArtifact2",
+ ArtifactTypeEnum.HEAT_ENV.getType());
artifacts.put(deploymentArtifact2.getArtifactLabel(), deploymentArtifact2);
- ArtifactDefinition deploymentArtifact3 = getArtifact("deploymentArtifact3", ArtifactTypeEnum.HEAT_VOL.getType());
+ ArtifactDefinition deploymentArtifact3 = getArtifact("deploymentArtifact3",
+ ArtifactTypeEnum.HEAT_VOL.getType());
artifacts.put(deploymentArtifact3.getArtifactLabel(), deploymentArtifact3);
ArtifactDefinition heatEnvPlaceHolder = getArtifact("deploymentArtifact4", ArtifactTypeEnum.HEAT_ENV.getType());
- ArtifactDefinition heatEnvPlaceHolder2 = getArtifact("deploymentArtifact5", ArtifactTypeEnum.HEAT_ENV.getType());
+ ArtifactDefinition heatEnvPlaceHolder2 = getArtifact("deploymentArtifact5",
+ ArtifactTypeEnum.HEAT_ENV.getType());
- Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getResourceDeploymentArtifacts = Either.left(artifacts);
+ Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getResourceDeploymentArtifacts = Either
+ .left(artifacts);
Map<String, ArtifactDefinition> finalDeploymentArtifacts = new HashMap<>();
finalDeploymentArtifacts.put(deploymentArtifact1.getArtifactLabel(), deploymentArtifact1);
@@ -523,26 +544,28 @@ public class ComponentInstanceBusinessLogicTest {
finalDeploymentArtifacts.put(heatEnvPlaceHolder.getArtifactLabel(), heatEnvPlaceHolder);
finalDeploymentArtifacts.put(heatEnvPlaceHolder2.getArtifactLabel(), heatEnvPlaceHolder2);
-
when(artifactsBusinessLogic.getArtifacts(componentInstance.getComponentUid(), NodeTypeEnum.Resource,
- ArtifactGroupTypeEnum.DEPLOYMENT, null)).thenReturn(getResourceDeploymentArtifacts);
+ ArtifactGroupTypeEnum.DEPLOYMENT, null)).thenReturn(getResourceDeploymentArtifacts);
when(artifactsBusinessLogic.createHeatEnvPlaceHolder(new ArrayList<>(),
- deploymentArtifact1, ArtifactsBusinessLogic.HEAT_ENV_NAME, componentInstance.getUniqueId(),
- NodeTypeEnum.ResourceInstance, componentInstance.getName(), user, containerComponent,
- null)).thenReturn(heatEnvPlaceHolder);
+ deploymentArtifact1, ArtifactsBusinessLogic.HEAT_ENV_NAME, componentInstance.getUniqueId(),
+ NodeTypeEnum.ResourceInstance, componentInstance.getName(), user, containerComponent,
+ null)).thenReturn(heatEnvPlaceHolder);
when(artifactsBusinessLogic.createHeatEnvPlaceHolder(new ArrayList<>(),
- deploymentArtifact3, ArtifactsBusinessLogic.HEAT_ENV_NAME, componentInstance.getUniqueId(),
- NodeTypeEnum.ResourceInstance, componentInstance.getName(), user, containerComponent,
- null)).thenReturn(heatEnvPlaceHolder2);
-
-
- when(toscaOperationFacade.addDeploymentArtifactsToInstance(containerComponent.getUniqueId(), componentInstance, finalDeploymentArtifacts)).thenReturn(StorageOperationStatus.OK);
- when(toscaOperationFacade.addGroupInstancesToComponentInstance(containerComponent, componentInstance, null, new HashMap<>())).thenReturn(StorageOperationStatus.OK);
- when(toscaOperationFacade.addInformationalArtifactsToInstance(containerComponent.getUniqueId(), componentInstance, null)).thenReturn(StorageOperationStatus.OK);
-
+ deploymentArtifact3, ArtifactsBusinessLogic.HEAT_ENV_NAME, componentInstance.getUniqueId(),
+ NodeTypeEnum.ResourceInstance, componentInstance.getName(), user, containerComponent,
+ null)).thenReturn(heatEnvPlaceHolder2);
+
+ when(toscaOperationFacade.addDeploymentArtifactsToInstance(containerComponent.getUniqueId(), componentInstance,
+ finalDeploymentArtifacts)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade
+ .addGroupInstancesToComponentInstance(containerComponent, componentInstance, null, new HashMap<>()))
+ .thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade
+ .addInformationalArtifactsToInstance(containerComponent.getUniqueId(), componentInstance, null))
+ .thenReturn(StorageOperationStatus.OK);
ActionStatus status = componentInstanceBusinessLogic.addComponentInstanceArtifacts(containerComponent,
- componentInstance, originComponent, user, null);
+ componentInstance, originComponent, user, null);
assertThat(status).isEqualTo(ActionStatus.OK);
@@ -551,7 +574,7 @@ public class ComponentInstanceBusinessLogicTest {
private Component fillOriginComponent(Resource originComponent) {
originComponent.setUniqueId("resourceId");
originComponent.setUniqueId(ORIGIN_COMPONENT_ID);
- originComponent.setComponentInstances(Lists.newArrayList(toInstance,fromInstance));
+ originComponent.setComponentInstances(Lists.newArrayList(toInstance, fromInstance));
originComponent.setComponentType(ComponentTypeEnum.RESOURCE);
originComponent.setState(LifecycleStateEnum.CERTIFIED);
return originComponent;
@@ -578,16 +601,15 @@ public class ComponentInstanceBusinessLogicTest {
forwardingPath.setDestinationPortNumber("port");
forwardingPath.setUniqueId(uniqueId);
ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition =
- new ListDataDefinition<>();
+ new ListDataDefinition<>();
forwardingPathElementListDataDefinition
- .add(new ForwardingPathElementDataDefinition(fromNode, toNode, "nodeAcpType", "nodeBcpType",
- "nodeDcpName", "nodeBcpName"));
+ .add(new ForwardingPathElementDataDefinition(fromNode, toNode, "nodeAcpType", "nodeBcpType",
+ "nodeDcpName", "nodeBcpName"));
forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
return forwardingPath;
}
-
private Map<String, ForwardingPathDataDefinition> generateForwardingPath(String componentInstanceID) {
ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition("fpName");
String protocol = "protocol";
@@ -597,31 +619,32 @@ public class ComponentInstanceBusinessLogicTest {
ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition =
new ListDataDefinition<>();
forwardingPathElementListDataDefinition
- .add(new ForwardingPathElementDataDefinition(componentInstanceID, "nodeB", "nodeA_FORWARDER_CAPABILITY",
- "nodeBcpType", "nodeDcpName", "nodeBcpName"));
+ .add(new ForwardingPathElementDataDefinition(componentInstanceID, "nodeB", "nodeA_FORWARDER_CAPABILITY",
+ "nodeBcpType", "nodeDcpName", "nodeBcpName"));
forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
forwardingPaths.put("1122", forwardingPath);
return forwardingPaths;
}
- @SuppressWarnings("unchecked")
- private void getServiceRelationByIdSuccess(Component component){
+ @SuppressWarnings("unchecked")
+ private void getServiceRelationByIdSuccess(Component component) {
Either<Component, StorageOperationStatus> getComponentRes = Either.left(component);
when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
- .thenReturn(getComponentRes);
+ .thenReturn(getComponentRes);
Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
- .getRelationById(COMPONENT_ID,
- RELATION_ID, USER_ID,
- component.getComponentType());
+ .getRelationById(COMPONENT_ID,
+ RELATION_ID, USER_ID,
+ component.getComponentType());
assertTrue(response.isLeft());
}
private void getServiceRelationByIdUserValidationFailure(Component component) {
- when(userValidations.validateUserExists(eq(USER_ID))).thenThrow(new ByActionStatusComponentException(ActionStatus.USER_NOT_FOUND));
+ when(userValidations.validateUserExists(eq(USER_ID)))
+ .thenThrow(new ByActionStatusComponentException(ActionStatus.USER_NOT_FOUND));
try {
componentInstanceBusinessLogic
- .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
+ .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
} catch (ByActionStatusComponentException e) {
assertSame(e.getActionStatus(), ActionStatus.USER_NOT_FOUND);
}
@@ -631,19 +654,20 @@ public class ComponentInstanceBusinessLogicTest {
Either<User, ActionStatus> eitherCreator = Either.left(user);
Either<Component, StorageOperationStatus> getComponentRes = Either.right(StorageOperationStatus.NOT_FOUND);
when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
- .thenReturn(getComponentRes);
+ .thenReturn(getComponentRes);
Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
- .getRelationById(COMPONENT_ID,
- RELATION_ID, USER_ID,
- component.getComponentType());
+ .getRelationById(COMPONENT_ID,
+ RELATION_ID, USER_ID,
+ component.getComponentType());
assertTrue(response.isRight());
}
private void stubMethods() {
when(userValidations.validateUserExists(eq(USER_ID))).thenReturn(user);
- when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.GENERAL_ERROR),any(ComponentTypeEnum.class)))
- .thenReturn(ActionStatus.GENERAL_ERROR);
+ when(componentsUtils
+ .convertFromStorageResponse(eq(StorageOperationStatus.GENERAL_ERROR), any(ComponentTypeEnum.class)))
+ .thenReturn(ActionStatus.GENERAL_ERROR);
}
private void createComponents() {
@@ -664,7 +688,6 @@ public class ComponentInstanceBusinessLogicTest {
resource.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
}
-
private void createService() {
service = new Service();
service.setUniqueId(COMPONENT_ID);
@@ -676,10 +699,10 @@ public class ComponentInstanceBusinessLogicTest {
service.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
}
-
private void createInstances() {
toInstance = new ComponentInstance();
toInstance.setUniqueId(TO_INSTANCE_ID);
+ toInstance.setName(TO_INSTANCE_NAME);
fromInstance = new ComponentInstance();
fromInstance.setUniqueId(FROM_INSTANCE_ID);
@@ -690,7 +713,11 @@ public class ComponentInstanceBusinessLogicTest {
capability.setName(CAPABILITY_NAME);
Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
- capabilities.put(capability.getName(), Lists.newArrayList(new CapabilityDefinition(capability)));
+ final CapabilityDefinition capabilityDefinition = new CapabilityDefinition(capability);
+ final ArrayList<ComponentInstanceProperty> properties = new ArrayList<>();
+ properties.add(componentInstancePropInput);
+ capabilityDefinition.setProperties(properties);
+ capabilities.put(capability.getName(), Lists.newArrayList(capabilityDefinition));
requirement = new RequirementDataDefinition();
requirement.setOwnerId(REQUIREMENT_OWNER_ID);
@@ -698,7 +725,6 @@ public class ComponentInstanceBusinessLogicTest {
requirement.setName(REQUIREMENT_NAME);
requirement.setRelationship(RELATIONSHIP_TYPE);
-
Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
requirements.put(requirement.getCapability(), Lists.newArrayList(new RequirementDefinition(requirement)));
@@ -706,7 +732,6 @@ public class ComponentInstanceBusinessLogicTest {
fromInstance.setRequirements(requirements);
}
-
private void createRelation() {
relation = new RequirementCapabilityRelDef();
@@ -734,7 +759,6 @@ public class ComponentInstanceBusinessLogicTest {
return componentInstanceBusinessLogic;
}
-
@Test
public void testChangeServiceProxyVersion() {
ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
@@ -744,9 +768,9 @@ public class ComponentInstanceBusinessLogicTest {
// default test
componentInstanceBusinessLogic = createTestSubject();
result = componentInstanceBusinessLogic.changeServiceProxyVersion();
+ Assert.assertNotNull(result);
}
-
@Test
public void testCreateServiceProxy() {
ComponentInstanceBusinessLogic testSubject;
@@ -755,12 +779,9 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.createServiceProxy();
+ Assert.assertNotNull(result);
}
-
-
-
-
@Test
public void testDeleteServiceProxy() {
ComponentInstanceBusinessLogic testSubject;
@@ -770,9 +791,9 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.deleteServiceProxy();
+ Assert.assertNotNull(result);
}
-
@Test
public void testGetComponentInstanceInputsByInputId() {
ComponentInstanceBusinessLogic testSubject;
@@ -783,9 +804,9 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.getComponentInstanceInputsByInputId(component, inputId);
+ Assert.assertNotNull(result);
}
-
@Test
public void testGetComponentInstancePropertiesByInputId() {
ComponentInstanceBusinessLogic testSubject;
@@ -796,9 +817,9 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.getComponentInstancePropertiesByInputId(component, inputId);
+ Assert.assertNotNull(result);
}
-
@Test
public void testGetRelationById() {
ComponentInstanceBusinessLogic testSubject;
@@ -811,10 +832,11 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = testSubject.getRelationById(componentId, relationId, userId, componentTypeEnum);
+ Assert.assertNotNull(result);
}
- @Test
- public void testValidateParent() {
+ @Test
+ public void testValidateParent() {
ComponentInstanceBusinessLogic testSubject;
createResource();
String nodeTemplateId = "";
@@ -822,10 +844,10 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "validateParent", new Object[] {resource, nodeTemplateId});
+ result = Deencapsulation.invoke(testSubject, "validateParent", new Object[]{resource, nodeTemplateId});
+ Assert.assertNotNull(result);
}
-
@Test
public void testGetComponentType() {
ComponentInstanceBusinessLogic testSubject;
@@ -833,10 +855,10 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "getComponentType", new Object[] {ComponentTypeEnum.class});
+ result = Deencapsulation.invoke(testSubject, "getComponentType", new Object[]{ComponentTypeEnum.class});
+ Assert.assertNotNull(result);
}
-
@Test
public void testGetNewGroupName() {
ComponentInstanceBusinessLogic testSubject;
@@ -848,10 +870,10 @@ public class ComponentInstanceBusinessLogicTest {
// test 1
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "getNewGroupName",
- new Object[] {oldPrefix, newNormailzedPrefix, qualifiedGroupInstanceName});
+ new Object[]{oldPrefix, newNormailzedPrefix, qualifiedGroupInstanceName});
+ Assert.assertNotNull(result);
}
-
@Test
public void testUpdateComponentInstanceMetadata_3() {
ComponentInstanceBusinessLogic testSubject;
@@ -862,7 +884,8 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation
- .invoke(testSubject, "updateComponentInstanceMetadata", new Object[] {toInstance, toInstance});
+ .invoke(testSubject, "updateComponentInstanceMetadata", new Object[]{toInstance, toInstance});
+ Assert.assertNotNull(result);
}
@Test
@@ -875,10 +898,9 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "findRelation",
- new Object[] {relationId, requirementCapabilityRelations});
+ new Object[]{relationId, requirementCapabilityRelations});
}
-
@Test
public void testCreateOrUpdatePropertiesValues() throws Exception {
ComponentInstanceBusinessLogic testSubject;
@@ -890,29 +912,28 @@ public class ComponentInstanceBusinessLogicTest {
String userId = user.getUserId();
Either<List<ComponentInstanceProperty>, ResponseFormat> result;
-
when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll))
- .thenReturn(Either.left(resource));
+ .thenReturn(Either.left(resource));
// test 1
testSubject = createTestSubject();
result = testSubject
- .createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
- userId);
+ .createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
+ userId);
+ Assert.assertNotNull(result);
componentTypeEnum = null;
result = testSubject
- .createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
- userId);
+ .createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
+ userId);
+ Assert.assertNotNull(result);
- // when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
result = testSubject
- .createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
- userId);
-
+ .createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties,
+ userId);
+ Assert.assertNotNull(result);
}
-
@Test
public void testUpdateCapabilityPropertyOnContainerComponent() throws Exception {
ComponentInstanceBusinessLogic testSubject;
@@ -927,10 +948,9 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent",
- new Object[] {property, newValue, resource, toInstance, capabilityType, capabilityName});
+ new Object[]{property, newValue, resource, toInstance, capabilityType, capabilityName});
}
-
@Test
public void testCreateOrUpdateInstanceInputValues() throws Exception {
ComponentInstanceBusinessLogic testSubject;
@@ -943,27 +963,26 @@ public class ComponentInstanceBusinessLogicTest {
Either<List<ComponentInstanceInput>, ResponseFormat> result;
when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll))
- .thenReturn(Either.left(resource));
+ .thenReturn(Either.left(resource));
// test 1
testSubject = createTestSubject();
result = testSubject
- .createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
- userId);
+ .createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
+ userId);
+ Assert.assertNotNull(result);
componentTypeEnum = null;
result = testSubject
- .createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
- userId);
-
+ .createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
+ userId);
+ Assert.assertNotNull(result);
- // when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
result = testSubject
- .createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
- userId);
-
+ .createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs,
+ userId);
+ Assert.assertNotNull(result);
}
-
@Test
public void testCreateOrUpdateGroupInstancePropertyValue() throws Exception {
ComponentInstanceBusinessLogic testSubject;
@@ -976,27 +995,27 @@ public class ComponentInstanceBusinessLogicTest {
String userId = user.getUserId();
Either<ComponentInstanceProperty, ResponseFormat> result;
-
when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata))
- .thenReturn(Either.left(resource));
+ .thenReturn(Either.left(resource));
// test 1
testSubject = createTestSubject();
result = testSubject
- .createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
- groupInstanceId, property, userId);
+ .createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
+ groupInstanceId, property, userId);
+ Assert.assertNotNull(result);
componentTypeEnum = null;
result = testSubject
- .createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
- groupInstanceId, property, userId);
+ .createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
+ groupInstanceId, property, userId);
+ Assert.assertNotNull(result);
- // when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
result = testSubject
- .createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
- groupInstanceId, property, userId);
+ .createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId,
+ groupInstanceId, property, userId);
+ Assert.assertNotNull(result);
}
-
@Test
public void testDeletePropertyValue() throws Exception {
ComponentInstanceBusinessLogic testSubject;
@@ -1009,19 +1028,21 @@ public class ComponentInstanceBusinessLogicTest {
Either<ComponentInstanceProperty, ResponseFormat> result;
when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata))
- .thenReturn(Either.left(service));
+ .thenReturn(Either.left(service));
// test 1
testSubject = createTestSubject();
result = testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId,
- userId);
+ userId);
+ Assert.assertNotNull(result);
componentTypeEnum = null;
result = testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId,
- userId);
+ userId);
+ Assert.assertNotNull(result);
- // when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
result = testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId,
- userId);
+ userId);
+ Assert.assertNotNull(result);
}
@Test
@@ -1032,6 +1053,7 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "getComponentParametersViewForForwardingPath");
+ Assert.assertNotNull(result);
}
@Test
@@ -1043,7 +1065,8 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "getResourceInstanceById", new Object[] {resource, instanceId});
+ result = Deencapsulation.invoke(testSubject, "getResourceInstanceById", new Object[]{resource, instanceId});
+ Assert.assertNotNull(result);
}
@Test
@@ -1059,16 +1082,17 @@ public class ComponentInstanceBusinessLogicTest {
String userId = user.getUserId();
Either<List<ComponentInstanceProperty>, ResponseFormat> result;
-
when(toscaOperationFacade.getToscaFullElement(containerComponentId))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
// test 1
testSubject = createTestSubject();
result = testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId,
- componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
+ componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
+ Assert.assertNotNull(result);
when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(resource));
result = testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId,
- componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
+ componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
+ Assert.assertNotNull(result);
}
@Test
@@ -1084,19 +1108,19 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> leftServiceOp = Either.left(service);
when(toscaOperationFacade.getToscaElement(containerComponentId)).thenReturn(leftServiceOp);
when(toscaOperationFacade.getToscaElement(eq(containerComponentId), any(ComponentParametersView.class)))
- .thenReturn(leftServiceOp);
+ .thenReturn(leftServiceOp);
when(janusGraphDao.rollback()).thenReturn(JanusGraphOperationStatus.OK);
when(graphLockOperation.unlockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
result = componentInstanceBusinessLogic
- .copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId,
- USER_ID);
+ .copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId,
+ USER_ID);
+ Assert.assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
-
assertThat(result.isRight());
}
@@ -1112,15 +1136,16 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> leftServiceOp = Either.left(service);
when(toscaOperationFacade.getToscaElement(containerComponentId)).thenReturn(leftServiceOp);
when(toscaOperationFacade.getToscaElement(eq(containerComponentId), any(ComponentParametersView.class)))
- .thenReturn(leftServiceOp);
+ .thenReturn(leftServiceOp);
when(janusGraphDao.rollback()).thenReturn(JanusGraphOperationStatus.OK);
when(graphLockOperation.unlockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
Either<Component, StorageOperationStatus> getComponentRes = Either.left(resource);
result = componentInstanceBusinessLogic
- .copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId, USER_ID);
+ .copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId, USER_ID);
+ Assert.assertNotNull(result);
service.setLastUpdaterUserId(oldServiceLastUpdatedUserId);
assertThat(result.isRight());
}
@@ -1139,21 +1164,22 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> leftServiceOp = Either.left(service);
when(toscaOperationFacade.getToscaElement(containerComponentId)).thenReturn(leftServiceOp);
when(toscaOperationFacade.getToscaElement(eq(containerComponentId), any(ComponentParametersView.class)))
- .thenReturn(leftServiceOp);
+ .thenReturn(leftServiceOp);
when(graphLockOperation.unlockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
Either<Component, StorageOperationStatus> getComponentRes = Either.left(resource);
ImmutablePair<Component, String> pair = new ImmutablePair<>(resource, TO_INSTANCE_ID);
Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.left(pair);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getResourceDeploymentArtifacts = Either
- .left(new HashMap<String, ArtifactDefinition>());
+ .left(new HashMap<String, ArtifactDefinition>());
StorageOperationStatus artStatus = StorageOperationStatus.OK;
result = componentInstanceBusinessLogic
- .copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId,
- USER_ID);
+ .copyComponentInstance(inputComponentInstance, containerComponentId, componentInstanceId,
+ USER_ID);
+ Assert.assertNotNull(result);
service.setLastUpdaterUserId(oldServiceLastUpdatedUserId);
resource.setLifecycleState(oldResourceLifeCycle);
@@ -1175,7 +1201,7 @@ public class ComponentInstanceBusinessLogicTest {
service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
Map<String, List<ComponentInstanceProperty>> instAttrsMap =
- new HashMap<String, List<ComponentInstanceProperty>>();
+ new HashMap<String, List<ComponentInstanceProperty>>();
List<ComponentInstanceProperty> instAttrsList = new ArrayList<ComponentInstanceProperty>();
ComponentInstanceProperty prop = new ComponentInstanceProperty();
prop.setUniqueId(attribute.getUniqueId());
@@ -1185,20 +1211,21 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> serviceEitherLeft = Either.left(service);
when(toscaOperationFacade.getToscaElement(serviceComponentInstance.getUniqueId(), JsonParseFlagEnum.ParseAll))
- .thenReturn(serviceEitherLeft);
+ .thenReturn(serviceEitherLeft);
when(toscaOperationFacade.updateComponentInstanceAttribute(service, toInstance.getUniqueId(), attribute))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.updateComponentInstanceMetadataOfTopologyTemplate(service))
- .thenReturn(serviceEitherLeft);
+ .thenReturn(serviceEitherLeft);
Either<ComponentInstanceProperty, ResponseFormat> result = Deencapsulation
- .invoke(componentInstanceBusinessLogic,
- "createOrUpdateAttributeValueForCopyPaste",
- ComponentTypeEnum.SERVICE,
- serviceComponentInstance
- .getUniqueId(),
- toInstance.getUniqueId(), attribute,
- USER_ID);
+ .invoke(componentInstanceBusinessLogic,
+ "createOrUpdateAttributeValueForCopyPaste",
+ ComponentTypeEnum.SERVICE,
+ serviceComponentInstance
+ .getUniqueId(),
+ toInstance.getUniqueId(), attribute,
+ USER_ID);
+ Assert.assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
service.setLifecycleState(oldLifeCycleState);
@@ -1220,14 +1247,14 @@ public class ComponentInstanceBusinessLogicTest {
when(toscaOperationFacade.getToscaElement(containerComponentId)).thenReturn(getComponent);
StorageOperationStatus status = StorageOperationStatus.OK;
when(toscaOperationFacade.updateComponentInstanceProperty(service, componentInstanceId, property))
- .thenReturn(status);
+ .thenReturn(status);
Either<Component, StorageOperationStatus> updateContainerRes = Either.left(service);
when(toscaOperationFacade.updateComponentInstanceMetadataOfTopologyTemplate(service))
- .thenReturn(updateContainerRes);
+ .thenReturn(updateContainerRes);
Either<String, ResponseFormat> result = Deencapsulation.invoke(componentInstanceBusinessLogic,
- "updateComponentInstanceProperty", containerComponentId, componentInstanceId, property);
-
+ "updateComponentInstanceProperty", containerComponentId, componentInstanceId, property);
+ Assert.assertNotNull(result);
assertTrue(result.isLeft());
}
@@ -1245,7 +1272,7 @@ public class ComponentInstanceBusinessLogicTest {
service.setInputs(newInputs);
Either<String, ResponseFormat> result =
- Deencapsulation.invoke(componentInstanceBusinessLogic, "getInputListDefaultValue", component, inputId);
+ Deencapsulation.invoke(componentInstanceBusinessLogic, "getInputListDefaultValue", component, inputId);
service.setInputs(oldInputs);
@@ -1266,20 +1293,20 @@ public class ComponentInstanceBusinessLogicTest {
deleteErrorIds.add(componentInstanceId);
deleteErrorMap.put("deleteFailedIds", deleteErrorIds);
Either<Component, StorageOperationStatus> cont = Either.left(service);
- when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.NOT_FOUND),eq(null)))
- .thenReturn(ActionStatus.GENERAL_ERROR);
+ when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.NOT_FOUND), eq(null)))
+ .thenReturn(ActionStatus.GENERAL_ERROR);
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
- .thenReturn(cont);
+ .thenReturn(cont);
- try{
- result = componentInstanceBusinessLogic
+ try {
+ result = componentInstanceBusinessLogic
.batchDeleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceIdList,
- userId);
- }catch (ComponentException e){
- assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
- }
-
-// assertEquals(deleteErrorMap, result);
+ userId);
+ Assert.assertNotNull(result);
+ assertEquals(deleteErrorMap, result);
+ } catch (ComponentException e) {
+ assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
+ }
}
@Test
@@ -1298,16 +1325,17 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> err = Either.right(StorageOperationStatus.GENERAL_ERROR);
when(toscaOperationFacade.getToscaElement(eq(containerComponentId), any(ComponentParametersView.class)))
- .thenReturn(err);
+ .thenReturn(err);
try {
result = componentInstanceBusinessLogic
- .batchDeleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceIdList,
- userId);
- }catch (ComponentException e){
+ .batchDeleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceIdList,
+ userId);
+ Assert.assertNotNull(result);
+ assertEquals(deleteErrorMap, result);
+ } catch (ComponentException e) {
assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
}
-// assertEquals(deleteErrorMap, result);
}
@Test
@@ -1329,20 +1357,21 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> cont = Either.left(service);
when(graphLockOperation.unlockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
ImmutablePair<Component, String> pair = new ImmutablePair<>(resource, TO_INSTANCE_ID);
Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.left(pair);
when(toscaOperationFacade.deleteComponentInstanceFromTopologyTemplate(service, componentInstanceId))
- .thenReturn(result2);
+ .thenReturn(result2);
when(toscaOperationFacade.getToscaElement(eq(service.getUniqueId()), any(ComponentParametersView.class)))
- .thenReturn(cont);
+ .thenReturn(cont);
when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
result = componentInstanceBusinessLogic
- .batchDeleteComponentInstance(containerComponentParam, containerComponentId,
- componentInstanceIdList, userId);
+ .batchDeleteComponentInstance(containerComponentParam, containerComponentId,
+ componentInstanceIdList, userId);
+ Assert.assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
service.setLifecycleState(oldLifeCycleState);
@@ -1375,28 +1404,29 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> cont = Either.left(service);
when(toscaOperationFacade.getToscaElement(eq(service.getUniqueId()), any(ComponentParametersView.class)))
- .thenReturn(cont);
+ .thenReturn(cont);
when(graphLockOperation.unlockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
Either<RequirementCapabilityRelDef, StorageOperationStatus> resultEither;
resultEither = Either.right(StorageOperationStatus.OK);
- when(componentsUtils.convertFromStorageResponseForResourceInstance(eq(StorageOperationStatus.OK),eq(true)))
- .thenReturn(ActionStatus.GENERAL_ERROR);
+ when(componentsUtils.convertFromStorageResponseForResourceInstance(eq(StorageOperationStatus.OK), eq(true)))
+ .thenReturn(ActionStatus.GENERAL_ERROR);
when(toscaOperationFacade.dissociateResourceInstances(componentId, ref)).thenReturn(resultEither);
- try{
- result = componentInstanceBusinessLogic
- .batchDissociateRIFromRI(componentId, userId, requirementDefList, componentTypeEnum);
- }catch (ComponentException e){
- assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
- }
+ try {
+ result = componentInstanceBusinessLogic
+ .batchDissociateRIFromRI(componentId, userId, requirementDefList, componentTypeEnum);
+ Assert.assertNotNull(result);
+ assertEquals(new ArrayList<>(), result);
+ } catch (ComponentException e) {
+ assertEquals(e.getActionStatus().toString(), StorageOperationStatus.GENERAL_ERROR.toString());
+ }
service.setLastUpdaterUserId(oldLastUpdatedUserId);
service.setLifecycleState(oldLifeCycleState);
-// assertEquals(new ArrayList<>(), result);
}
@Test
@@ -1416,17 +1446,18 @@ public class ComponentInstanceBusinessLogicTest {
Either<Component, StorageOperationStatus> cont = Either.left(service);
when(toscaOperationFacade.getToscaElement(eq(service.getUniqueId()), any(ComponentParametersView.class)))
- .thenReturn(cont);
+ .thenReturn(cont);
when(graphLockOperation.unlockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Service)))
- .thenReturn(StorageOperationStatus.OK);
+ .thenReturn(StorageOperationStatus.OK);
Either<RequirementCapabilityRelDef, StorageOperationStatus> resultEither;
resultEither = Either.left(ref);
when(toscaOperationFacade.dissociateResourceInstances(componentId, ref)).thenReturn(resultEither);
result = componentInstanceBusinessLogic
- .batchDissociateRIFromRI(componentId, userId, requirementDefList, componentTypeEnum);
+ .batchDissociateRIFromRI(componentId, userId, requirementDefList, componentTypeEnum);
+ Assert.assertNotNull(result);
service.setLastUpdaterUserId(oldLastUpdatedUserId);
service.setLifecycleState(oldLifeCycleState);
@@ -1437,7 +1468,7 @@ public class ComponentInstanceBusinessLogicTest {
@Test
public void testGetComponentInstancePropertyByPolicyId_success() {
Optional<ComponentInstanceProperty> propertyCandidate =
- getComponentInstanceProperty(PROP_NAME);
+ getComponentInstanceProperty(PROP_NAME);
Assert.assertTrue(propertyCandidate.isPresent());
Assert.assertEquals(propertyCandidate.get().getName(), PROP_NAME);
@@ -1446,7 +1477,7 @@ public class ComponentInstanceBusinessLogicTest {
@Test
public void testGetComponentInstancePropertyByPolicyId_failure() {
Optional<ComponentInstanceProperty> propertyCandidate =
- getComponentInstanceProperty(NON_EXIST_NAME);
+ getComponentInstanceProperty(NON_EXIST_NAME);
Assert.assertEquals(propertyCandidate, Optional.empty());
}
@@ -1459,7 +1490,7 @@ public class ComponentInstanceBusinessLogicTest {
componentInstanceProperty.setGetPolicyValues(policyDefinition.getGetPolicyValues());
service.setComponentInstancesProperties(
- Collections.singletonMap(COMPONENT_INST_ID, Collections.singletonList(componentInstanceProperty)));
+ Collections.singletonMap(COMPONENT_INST_ID, Collections.singletonList(componentInstanceProperty)));
return componentInstanceBusinessLogic.getComponentInstancePropertyByPolicyId(service, policyDefinition);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 7d604bbc50..ca4f569cf3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,14 +20,28 @@
package org.openecomp.sdc.be.tosca;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+
import fj.data.Either;
+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 java.util.stream.Collectors;
import mockit.Deencapsulation;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Triple;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -81,1290 +95,1336 @@ import org.openecomp.sdc.be.tosca.model.ToscaTemplateRequirement;
import org.openecomp.sdc.be.tosca.model.ToscaTopolgyTemplate;
import org.openecomp.sdc.be.tosca.utils.InputConverter;
-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 java.util.stream.Collectors;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
public class ToscaExportHandlerTest extends BeConfDependentTest {
- private static final String COMPONENT_PROPERTY_NAME = "prop1";
- private static final String COMPONENT_PROPERTY_TYPE = "string";
- private static final String COMPONENT_INPUT_NAME = "input1";
- private static final String COMPONENT_INPUT_TYPE = "integer";
- private static final String RESOURCE_NAME = "resource";
- private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1";
-
- @InjectMocks
- ToscaExportHandler testSubject;
-
- @Mock
- ApplicationDataTypeCache dataTypeCache;
-
- @Mock
- ToscaOperationFacade toscaOperationFacade;
-
- @Mock
- CapabilityRequirementConverter capabiltyRequirementConvertor;
-
- @Mock
- InputConverter inputConverter;
-
- @Mock
- GroupExportParser groupExportParser;
-
- @Mock
- GroupExportParserImpl groupExportParserImpl;
-
- @Mock
- InterfaceLifecycleOperation interfaceLifecycleOperation;
-
- @Before
- public void setUpMock() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- private Resource getNewResource() {
- Resource resource = new Resource();
- List<CategoryDefinition> categories = new ArrayList<>();
- CategoryDefinition category = new CategoryDefinition();
- List<SubCategoryDefinition> subcategories = new ArrayList<>();
- SubCategoryDefinition subcategory = new SubCategoryDefinition();
- List<DataTypeDefinition> dataTypes = new ArrayList<>();
- DataTypeDefinition dataType = new DataTypeDefinition();
- dataType.setName("dataTypeName");
- dataType.setDerivedFromName("tosca.datatypes.Root");
- PropertyDataDefinition propData = new PropertyDataDefinitionBuilder()
- .setName("property")
- .setType("type")
- .build();
- List<PropertyDataDefinition> propDataList = Arrays.asList(propData);
- dataType.setPropertiesData(propDataList);
- List<PropertyDefinition> propList = propDataList.stream().map(PropertyDefinition::new)
- .collect(Collectors.toList());
- dataType.setProperties(propList);
- dataTypes.add(dataType);
-
- subcategory.setName("name");
- subcategories.add(subcategory);
- category.setName("name");
- category.setSubcategories(subcategories);
- categories.add(category);
-
- resource.setCategories(categories);
- resource.setVersion("version");
- resource.setVendorName("vendorName");
- resource.setVendorRelease("vendorRelease");
- resource.setResourceVendorModelNumber("resourceVendorModelNumber");
- resource.setDataTypes(dataTypes);
-
- return resource;
- }
-
- private Service getNewService() {
- Service service = new Service();
- List<CategoryDefinition> categories = new ArrayList<>();
- CategoryDefinition category = new CategoryDefinition();
- List<SubCategoryDefinition> subcategories = new ArrayList<>();
- SubCategoryDefinition subcategory = new SubCategoryDefinition();
-
- subcategory.setName("name");
- subcategories.add(subcategory);
- category.setName("name");
- category.setSubcategories(subcategories);
- categories.add(category);
-
- service.setCategories(categories);
- service.setComponentType(ComponentTypeEnum.SERVICE);
- service.setServiceType("serviceType");
- service.setServiceRole("serviceRole");
- service.setEnvironmentContext("environmentContext");
-
- return service;
- }
-
- @Test
- public void testExportComponent() throws Exception {
- Component component = getNewResource();
- Either<ToscaRepresentation, ToscaError> result;
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
- Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class), Mockito.any(Resource.class),
- Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
- Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
- .thenReturn(Either.left(Collections.emptyMap()));
-
- // default test when component is Resource
- result = testSubject.exportComponent(component);
-
- component = getNewService();
- Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Service.class),
- Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
-
- // default test when component is Service
- result = testSubject.exportComponent(component);
- }
-
- @Test
- public void testExportComponentInterface() throws Exception {
- Component component = getNewResource();
- Either<ToscaRepresentation, ToscaError> result;
-
- ((Resource) component).setInterfaces(new HashMap<>());
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
- Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(Collections.emptyMap()));
- // default test when convertInterfaceNodeType is right
- result = testSubject.exportComponentInterface(component, false);
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
- Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Resource.class),
- Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
-
- // default test when convertInterfaceNodeType is left
- result = testSubject.exportComponentInterface(component, false);
-
- }
-
- @Test
- public void testConvertInterfaceNodeTypeProperties() throws Exception {
-
- Resource component = getNewResource();
-
- component.setInterfaces(new HashMap<>());
- InputDefinition input = new InputDefinition();
- input.setName(COMPONENT_INPUT_NAME);
- input.setType(COMPONENT_INPUT_TYPE);
- component.setInputs(Collections.singletonList(input));
- PropertyDefinition property = new PropertyDefinition();
- property.setName(COMPONENT_PROPERTY_NAME);
- property.setType(COMPONENT_PROPERTY_TYPE);
- component.setProperties(Collections.singletonList(property));
- component.setName(RESOURCE_NAME);
- component.setToscaResourceName(RESOURCE_NAME);
-
- Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
- .thenReturn(Either.left(Collections.emptyMap()));
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
- // when convertRequirements is called, make it return the same value as 3rd (index=2) argument.
- Mockito
- .when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class), Mockito.any(Resource.class),
- Mockito.any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
-
- Either<ToscaTemplate, ToscaError> result = (Either<ToscaTemplate, ToscaError>) Deencapsulation
- .invoke(testSubject, "convertInterfaceNodeType", new HashMap<String, Component>(), component,
- new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
- assertThat(result.isLeft(), is(true));
- Map<String, ToscaNodeType> nodeTypeMap = result.left().value().getNode_types();
- assertThat(nodeTypeMap.size(), is(1));
- ToscaNodeType toscaNodeType = nodeTypeMap.values().iterator().next();
- Map<String, ToscaProperty> propertyMap = toscaNodeType.getProperties();
- // Check if inputs and properties in component are merged properly
- assertThat(propertyMap.size(), is(2));
- assertThat(propertyMap.containsKey(COMPONENT_INPUT_NAME), is(true));
- assertThat(propertyMap.containsKey(COMPONENT_PROPERTY_NAME), is(true));
- }
-
- @Test
- public void testCreateToscaRepresentation() throws Exception {
- ToscaTemplate toscaTemplate = new ToscaTemplate("");
- ToscaRepresentation result;
-
- // default test
- result = testSubject.createToscaRepresentation(toscaTemplate);
- }
-
- @Test
- public void testGetDependencies() throws Exception {
-
- Component component = new Resource();
- Either<ToscaTemplate, ToscaError> result;
-
- // default test
- result = testSubject.getDependencies(component);
- }
-
- @Test
- public void testConvertToscaTemplate() throws Exception {
-
- Component component = getNewResource();
- ToscaTemplate toscaNode = new ToscaTemplate("");
- Either<ToscaTemplate, ToscaError> result;
- List<ComponentInstance> resourceInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
-
- instance.setOriginType(OriginTypeEnum.SERVICE);
- instance.setSourceModelUid("targetModelUid");
- resourceInstances.add(instance);
-
- component.setComponentInstances(resourceInstances);
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
- Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class),
- Mockito.any(ComponentInstance.class))).thenReturn(Either.right(false));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
- }
-
- @Ignore("need to solve problem with groupExportParser injection")
- @Test
- public void testConvertToscaTemplateWhenComponentContainsGroup() {
- Component component = getNewResource();
- ToscaTemplate toscaNode = new ToscaTemplate("");
- Either<ToscaTemplate, ToscaError> result;
- component.setComponentInstances(new ArrayList<>());
-
- List<GroupDefinition> groups = new ArrayList<>();
- GroupDefinition group = new GroupDefinition();
- List<String> artifacts = new ArrayList<>();
- artifacts.add("artifact");
- group.setType("org.openecomp.groups.VfModule");
- group.setArtifacts(artifacts);
- groups.add(group);
- component.setGroups(groups);
-
- Map<String, String[]> substitutionMappingMap = new HashMap<>();
- String[] array = { "value1", "value2" };
- substitutionMappingMap.put("key", array);
-
- Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingCapabilities(Mockito.any(Map.class),
- Mockito.any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
-
- Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingRequirements(Mockito.any(Map.class),
- Mockito.any(Component.class), Mockito.any(SubstitutionMapping.class)))
- .thenReturn(Either.left(new SubstitutionMapping()));
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
-
- Mockito.when(inputConverter.convertInputs(Mockito.any(List.class),Mockito.any(Map.class)))
- .thenReturn(new HashMap<>());
-
- Mockito.when(groupExportParser.getGroups(component))
- .thenReturn(null);
-
- // test component contains group
- result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
- }
-
- @Ignore("need to solve problem with groupExportParser injection")
- @Test
- public void testConvertToscaTemplateWhenComponentIsService() throws Exception {
- Component component = getNewService();
- ToscaTemplate toscaNode = new ToscaTemplate("");
- Either<ToscaTemplate, ToscaError> result;
- component.setComponentInstances(new ArrayList<>());
-
- List<GroupDefinition> groups = new ArrayList<>();
- GroupDefinition group = new GroupDefinition();
- List<String> artifacts = new ArrayList<>();
- artifacts.add("artifact");
- group.setType("org.openecomp.groups.VfModule");
- group.setArtifacts(artifacts);
- groups.add(group);
- component.setGroups(groups);
-
- Map<String, String[]> substitutionMappingMap = new HashMap<>();
- String[] array = { "value1", "value2" };
- substitutionMappingMap.put("key", array);
-
- Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingCapabilities(Mockito.any(Map.class),
- Mockito.any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
-
- Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingRequirements(Mockito.any(Map.class),
- Mockito.any(Component.class), Mockito.any(SubstitutionMapping.class)))
- .thenReturn(Either.left(new SubstitutionMapping()));
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
-
- Mockito.when(inputConverter.convertInputs(Mockito.any(List.class),Mockito.any(Map.class)))
- .thenReturn(new HashMap<>());
- // test component contains group
- result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
- }
-
- @Test
- public void testConvertMetadata_1() throws Exception {
-
- Component component = getNewResource();
- boolean isInstance = true;
- ComponentInstance componentInstance = new ComponentInstance();
- componentInstance.setOriginType(OriginTypeEnum.ServiceProxy);
- componentInstance.setSourceModelInvariant("targetModelInvariant");
-
- ToscaMetadata result;
-
- // default test
-
- result = Deencapsulation.invoke(testSubject, "convertMetadata", component, isInstance, componentInstance);
- }
-
- @Test
- public void testFillImports() throws Exception {
-
- Component component = getNewService();
- ToscaTemplate toscaTemplate = new ToscaTemplate("");
- Either<ImmutablePair<ToscaTemplate, Map<String, Component>>, ToscaError> result;
-
- ComponentInstance instance = new ComponentInstance();
- List<ComponentInstance> resourceInstances = new ArrayList<>();
- instance.setComponentUid("name");
- resourceInstances.add(instance);
- component.setComponentInstances(resourceInstances);
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("name.name2");
- toscaArtifacts.put("assettoscatemplate", artifact);
- component.setToscaArtifacts(toscaArtifacts);
-
- Mockito.when(toscaOperationFacade.getToscaFullElement(Mockito.any(String.class)))
- .thenReturn(Either.left(component));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "fillImports", component, toscaTemplate);
- }
-
- @Test
- public void testCreateDependency() throws Exception {
-
- Map<String, Component> componentCache = new HashMap<>();
- List<Map<String, Map<String, String>>> imports = new ArrayList<>();
- List<Triple<String, String, Component>> dependecies = new ArrayList<>();
- ComponentInstance ci = new ComponentInstance();
- Component component = getNewResource();
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("name.name2");
- toscaArtifacts.put("assettoscatemplate", artifact);
- component.setToscaArtifacts(toscaArtifacts);
- ci.setComponentUid("name");
- ci.setOriginType(OriginTypeEnum.ServiceProxy);
- ci.setSourceModelUid("modelName");
-
- Mockito.when(toscaOperationFacade.getToscaFullElement(Mockito.eq("name"))).thenReturn(Either.left(component));
-
- Mockito.when(toscaOperationFacade.getToscaFullElement(Mockito.eq("modelName")))
- .thenReturn(Either.left(new Service()));
-
- // default test
- Deencapsulation.invoke(testSubject, "createDependency", componentCache, imports, dependecies, ci);
- }
-
- @Test
- public void testGetInterfaceFilename() throws Exception {
- String artifactName = "artifact.name";
- String result;
-
- // default test
- result = ToscaExportHandler.getInterfaceFilename(artifactName);
- }
-
- @Test
- public void testConvertNodeType() throws Exception {
- Component component = new Resource();
- ToscaTemplate toscaNode = new ToscaTemplate("");
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- Either<ToscaTemplate, ToscaError> result;
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
- Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
- .thenReturn(Either.left(Collections.emptyMap()));
- // default test
- result = Deencapsulation.invoke(testSubject, "convertNodeType",new HashMap<>(), component, toscaNode, nodeTypes);
- }
-
- @Test
- public void testConvertInterfaceNodeType() throws Exception {
- Component component = getNewResource();
- ToscaTemplate toscaNode = new ToscaTemplate("");
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- Either<ToscaTemplate, ToscaError> result;
- List<InputDefinition> inputs = new ArrayList<>();
- inputs.add(new InputDefinition());
- component.setInputs(inputs);
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
- Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(Collections.emptyMap()));
-
- Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class), Mockito.any(Resource.class),
- Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertInterfaceNodeType",new HashMap<>(), component, toscaNode
- , nodeTypes, false);
- }
- @Ignore("need to fix change in injected class.")
- @Test
- public void testConvertReqCapAndTypeName() throws Exception {
- Component component = new Resource();
- ToscaTemplate toscaNode = new ToscaTemplate("");
- Map<String, ToscaNodeType> nodeTypes = new HashMap();
- ToscaNodeType toscaNodeType = new ToscaNodeType();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- Either<ToscaTemplate, ToscaError> result;
-
- Mockito.when(
- capabiltyRequirementConvertor.convertCapabilities(Mockito.any(Map.class),Mockito.any(Resource.class), Mockito.any(Map.class)))
- .thenReturn(new HashMap<>());
-
- Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Resource.class),
- Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertReqCapAndTypeName",new HashMap<>(), component, toscaNode, nodeTypes,
- toscaNodeType, dataTypes);
-
- component = new Service();
-
- Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Service.class),
- Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
-
- // test when component is service
- result = Deencapsulation.invoke(testSubject, "convertReqCapAndTypeName", component, toscaNode, nodeTypes,
- toscaNodeType, dataTypes);
- }
-
- @Ignore
- @Test
- public void testConvertNodeTemplates() throws Exception {
- Component component = getNewResource();
- List<ComponentInstance> componentInstances = new ArrayList<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
- Map<String, Component> componentCache = new HashMap<>();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
- Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
- Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
- List<ComponentInstanceInput> inputs = new ArrayList<>();
- inputs.add(new ComponentInstanceInput());
- componentInstancesInputs.put("key", inputs);
- List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
- RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
- reldef.setFromNode("node");
- resourceInstancesRelations.add(reldef);
- component.setComponentInstancesRelations(resourceInstancesRelations);
-
- ComponentInstance instance = new ComponentInstance();
- instance.setUniqueId("id");
- instance.setComponentUid("uid");
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- List<GroupInstance> groupInstances = new ArrayList<>();
- GroupInstance groupInst = new GroupInstance();
- List<String> artifacts = new ArrayList<>();
- artifacts.add("artifact");
- groupInst.setArtifacts(artifacts);
- groupInst.setType("type");
- groupInstances.add(groupInst);
- instance.setGroupInstances(groupInstances);
- componentInstances.add(instance);
-
- component.setComponentInstancesInputs(componentInstancesInputs);
- component.setInvariantUUID("uuid");
- component.setUUID("uuid");
- component.setDescription("desc");
-
- componentCache.put("uid", component);
-
- componentInstancesProperties.put("id", new ArrayList<>());
- componentInstancesInputs.put("id", new ArrayList<>());
-
- Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class),
- Mockito.any(ComponentInstance.class))).thenReturn(Either.left(component));
-
- Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities(
- Mockito.any(ComponentInstance.class), Mockito.any(Map.class), Mockito.any(ToscaNodeTemplate.class)))
- .thenReturn(Either.left(new ToscaNodeTemplate()));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
- componentInstancesProperties, componentCache, dataTypes, topologyTemplate);
- }
-
- @Test
- public void testConvertNodeTemplatesWhenComponentIsService() throws Exception {
- Component component = getNewService();
- List<ComponentInstance> componentInstances = new ArrayList<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
- Map<String, Component> componentCache = new HashMap<>();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
- Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
- Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
- List<ComponentInstanceInput> inputs = new ArrayList<>();
- inputs.add(new ComponentInstanceInput());
- componentInstancesInputs.put("key", inputs);
- List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
- RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
- reldef.setFromNode("node");
- resourceInstancesRelations.add(reldef);
- component.setComponentInstancesRelations(resourceInstancesRelations);
-
- ComponentInstance instance = new ComponentInstance();
- instance.setUniqueId("id");
- instance.setComponentUid("uid");
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- List<GroupInstance> groupInstances = new ArrayList<>();
- GroupInstance groupInst = new GroupInstance();
- List<String> artifacts = new ArrayList<>();
- artifacts.add("artifact");
- groupInst.setArtifacts(artifacts);
- groupInst.setType("type");
- groupInstances.add(groupInst);
- instance.setGroupInstances(groupInstances);
- componentInstances.add(instance);
-
- component.setComponentInstancesInputs(componentInstancesInputs);
- component.setInvariantUUID("uuid");
- component.setUUID("uuid");
- component.setDescription("desc");
-
- Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
- ForwardingPathDataDefinition path = new ForwardingPathDataDefinition();
- ListDataDefinition<ForwardingPathElementDataDefinition> list = new ListDataDefinition<>();
- path.setPathElements(list);
- forwardingPaths.put("key", path);
-
- ((Service) component).setForwardingPaths(forwardingPaths);
-
- componentCache.put("uid", component);
-
- componentInstancesProperties.put("id", new ArrayList<>());
- componentInstancesInterfaces.put("id", new ArrayList<>());
- componentInstancesInputs.put("id", new ArrayList<>());
-
- Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class),
- Mockito.any(ComponentInstance.class))).thenReturn(Either.left(component));
-
- Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities(
- Mockito.any(ComponentInstance.class), Mockito.any(Map.class), Mockito.any(ToscaNodeTemplate.class)))
- .thenReturn(Either.left(new ToscaNodeTemplate()));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
- componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
- }
-
- @Test
- public void testConvertNodeTemplatesWhenConvertComponentInstanceCapabilitiesIsRight() throws Exception {
- Component component = getNewResource();
- List<ComponentInstance> componentInstances = new ArrayList<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
- Map<String, Component> componentCache = new HashMap<>();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
- Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
- Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
- List<ComponentInstanceInput> inputs = new ArrayList<>();
- inputs.add(new ComponentInstanceInput());
- componentInstancesInputs.put("key", inputs);
- List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
- RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
- reldef.setFromNode("node");
- resourceInstancesRelations.add(reldef);
- component.setComponentInstancesRelations(resourceInstancesRelations);
-
- ComponentInstance instance = new ComponentInstance();
- instance.setUniqueId("id");
- instance.setComponentUid("uid");
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- componentInstances.add(instance);
-
- component.setComponentInstancesInputs(componentInstancesInputs);
- component.setInvariantUUID("uuid");
- component.setUUID("uuid");
- component.setDescription("desc");
-
- componentCache.put("uid", component);
-
- Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class),
- Mockito.any(ComponentInstance.class))).thenReturn(Either.left(component));
-
- Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities(
- Mockito.any(ComponentInstance.class), Mockito.any(Map.class), Mockito.any(ToscaNodeTemplate.class)))
- .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
- componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
- }
-
- @Test
- public void testConvetNodeTemplateWhenGetOriginComponentIsRight() throws Exception {
- Component component = getNewResource();
- List<ComponentInstance> componentInstances = new ArrayList<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
- Map<String, Component> componentCache = new HashMap<>();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
- Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
- Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
- List<ComponentInstanceInput> inputs = new ArrayList<>();
- inputs.add(new ComponentInstanceInput());
- componentInstancesInputs.put("key", inputs);
- List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
- RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
- reldef.setFromNode("id");
- resourceInstancesRelations.add(reldef);
- component.setComponentInstancesRelations(resourceInstancesRelations);
-
- ComponentInstance instance = new ComponentInstance();
- instance.setUniqueId("id");
- instance.setComponentUid("uid");
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- componentInstances.add(instance);
-
- component.setComponentInstancesInputs(componentInstancesInputs);
- component.setInvariantUUID("uuid");
- component.setUUID("uuid");
- component.setDescription("desc");
-
- componentCache.put("uid", component);
-
- Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class),
- Mockito.any(ComponentInstance.class))).thenReturn(Either.right(false));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
- componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
- }
-
- @Test
- public void testConvertNodeTemplatesWhenConvertComponentInstanceRequirmentsIsRight() {
- Component component = new Resource();
- List<ComponentInstance> componentInstances = new ArrayList<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
- Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
- Map<String, Component> componentCache = new HashMap<>();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
- Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
- Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
- List<ComponentInstanceInput> inputs = new ArrayList<>();
- inputs.add(new ComponentInstanceInput());
- componentInstancesInputs.put("key", inputs);
- List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
- RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
- reldef.setFromNode("id");
- reldef.setToNode("node");
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
- relationship.setRelation(new RelationshipInfo());
- relationships.add(relationship);
- reldef.setRelationships(relationships);
- resourceInstancesRelations.add(reldef);
- component.setComponentInstancesRelations(resourceInstancesRelations);
-
- ComponentInstance instance = new ComponentInstance();
- instance.setUniqueId("id");
- componentInstances.add(instance);
-
- component.setComponentInstancesInputs(componentInstancesInputs);
- component.setComponentInstances(componentInstances);
-
- Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class),
- Mockito.any(ComponentInstance.class))).thenReturn(Either.left(component));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
- componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
- }
-
- @Test
- public void testAddComponentInstanceInputs() throws Exception {
-
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
- ComponentInstance componentInstance = new ComponentInstance();
- String instanceUniqueId = "id";
- Map<String, Object> props = new HashMap<>();
-
- List<ComponentInstanceInput> componentInstanceInputs = new ArrayList<>();
- componentInstanceInputs.add(new ComponentInstanceInput());
-
- componentInstancesInputs.put(instanceUniqueId, componentInstanceInputs);
-
- // default test
- Deencapsulation.invoke(testSubject, "addComponentInstanceInputs", dataTypes, componentInstancesInputs,
- instanceUniqueId, props);
- }
-
- @Test
- public void testAddPropertiesOfComponentInstance() throws Exception {
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ComponentInstance componentInstance = new ComponentInstance();
- String instanceUniqueId = "id";
- Map<String, Object> props = new HashMap<>();
-
- ComponentInstanceProperty cip = new ComponentInstanceProperty();
- cip.setInstanceUniqueId("id");
-
- List<ComponentInstanceProperty> list = new ArrayList<>();
- list.add(cip);
-
- componentInstancesProperties.put("id", list);
-
- // default test
- Deencapsulation.invoke(testSubject, "addPropertiesOfComponentInstance", componentInstancesProperties, dataTypes,
- instanceUniqueId, props);
- }
-
- @Test
- public void testAddPropertiesOfParentComponent() throws Exception {
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ComponentInstance componentInstance = new ComponentInstance();
- Component componentOfInstance = new Resource();
- Map<String, Object> props = new HashMap<>();
-
- List<PropertyDefinition> properties = new ArrayList<>();
- properties.add(new PropertyDefinition());
-
- ((Resource) componentOfInstance).setProperties(properties);
-
- // default test
- Deencapsulation.invoke(testSubject, "addPropertiesOfParentComponent", dataTypes,
- componentOfInstance, props);
- }
-
-
- @Test
- public void testCreateNodeType() throws Exception {
-
- Component component = new Resource();
- List<String> array = new ArrayList<>();
- array.add("value");
- ((Resource) component).setDerivedFrom(array);
- ToscaNodeType result;
-
- // test when component is resource
- result = Deencapsulation.invoke(testSubject, "createNodeType", component);
-
- component = new Service();
- // test when component is service
- result = Deencapsulation.invoke(testSubject, "createNodeType", component);
- }
-
- @Test
- public void testCreateProxyInterfaceTypesComponentNotFound() throws Exception {
- Component container = new Service();
- Either<Map<String, ToscaNodeType>, ToscaError> result;
- List<ComponentInstance> componentInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- instance.setSourceModelUid("targetModelUid");
- instance.setToscaComponentName("toscaComponentName");
-
- componentInstances.add(instance);
- container.setComponentInstances(componentInstances);
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class),
- Mockito.any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
- result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
- Assert.assertTrue(result.isRight());
-
- }
-
- @Test
- public void testCreateProxyInterfaceTypesWhenInterfaceLifecycleFetchFailed() {
- Component container = new Service();
- Either<Map<String, ToscaNodeType>, ToscaError> result;
- List<ComponentInstance> componentInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- instance.setSourceModelUid("targetModelUid");
- instance.setToscaComponentName("toscaComponentName");
- componentInstances.add(instance);
- container.setComponentInstances(componentInstances);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class),
- Mockito.any(ComponentParametersView.class)))
- .thenReturn(Either.left(new Resource()));
- Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
- result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
- Assert.assertTrue(result.isRight());
- }
-
- @Test
- public void testCreateProxyInterfaceTypesPositive() {
- Component container = new Service();
- Either<Map<String, ToscaNodeType>, ToscaError> result;
- List<ComponentInstance> componentInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- instance.setSourceModelUid("targetModelUid");
- instance.setToscaComponentName("toscaComponentName");
- componentInstances.add(instance);
- container.setComponentInstances(componentInstances);
-
- Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
- .thenReturn(Either.left(Collections.emptyMap()));
-
- Component proxyResource = new Resource();
- Map<String, InterfaceDefinition> proxyInterfaces = new HashMap<>();
- proxyInterfaces.put("Local", new InterfaceDefinition("Local", "desc", new HashMap<>()));
- proxyResource.setInterfaces(proxyInterfaces);
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class),
- Mockito.any(ComponentParametersView.class)))
- .thenReturn(Either.left(proxyResource));
-
- result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
- Assert.assertTrue(result.isLeft());
- Assert.assertEquals(1, result.left().value().size());
- }
-
- @Test
- public void testCreateProxyNodeTypes() throws Exception {
- Map<String, Component> componentCache = new HashMap<>();
- Component container = new Resource();
- Either<Map<String, ToscaNodeType>, ToscaError> result;
- List<ComponentInstance> componentInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- instance.setSourceModelUid("targetModelUid");
-
- componentInstances.add(instance);
- container.setComponentInstances(componentInstances);
-
- Mockito.when(toscaOperationFacade.getLatestByName("serviceProxy"))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
-
- // test when getLatestByName return is right
- result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
-
- }
-
- @Test
- public void testCreateProxyNodeTypesWhenGetLatestByNameReturnValue() {
- Map<String, Component> componentCache = new HashMap<>();
- Component container = new Resource();
- Either<Map<String, ToscaNodeType>, ToscaError> result;
- List<ComponentInstance> componentInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
- instance.setSourceModelUid("targetModelUid");
-
- componentInstances.add(instance);
- container.setComponentInstances(componentInstances);
-
- Mockito.when(toscaOperationFacade.getLatestByName("serviceProxy")).thenReturn(Either.left(new Resource()));
-
- ComponentParametersView parameterView = new ComponentParametersView();
- parameterView.disableAll();
- parameterView.setIgnoreCategories(false);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class),
- Mockito.any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
-
- // test when getLatestByName is left
- result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
- }
-
- @Test
- public void testCreateProxyNodeType() throws Exception {
- Map<String, Component> componentCache = new HashMap<>();
- Component origComponent = new Resource();
- Component proxyComponent = new Resource();
- ComponentInstance instance = new ComponentInstance();
- ToscaNodeType result;
-
- Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "createProxyNodeType", componentCache, origComponent,
- proxyComponent, instance);
- }
-
- @Test
- public void testConvertComponentInstanceRequirements() throws Exception {
- Component component = new Resource();
- ComponentInstance componentInstance = new ComponentInstance();
- List<RequirementCapabilityRelDef> relations = new ArrayList<>();
- ToscaNodeTemplate nodeTypeTemplate = new ToscaNodeTemplate();
- Component originComponent = new Resource();
- Map<String, Component> componentCache = new HashMap<>();
- Either<ToscaNodeTemplate, ToscaError> result;
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
- componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
-
- RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
- reldef.setFromNode("name");
- reldef.setToNode("name1");
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
- cap.setRelation(new RelationshipInfo());
- relationships.add(cap);
- reldef.setRelationships(relationships);
- relations.add(reldef);
- componentInstance.setUniqueId("name");
-
- List<ComponentInstance> instances = new ArrayList<>();
- instances.add(componentInstance);
- component.setComponentInstances(instances);
-
- // test when filteredRElations ins't empty
- result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
- componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
- }
-
- @Test
- public void testAddRequirement() throws Exception {
- ComponentInstance fromInstance = new ComponentInstance();
- Component fromOriginComponent = new Resource();
- List<ComponentInstance> instancesList = new ArrayList<>();
- RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
- List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
- Map<String, Component> componentCache = new HashMap<>();
- boolean result;
-
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
- cap.setRequirement(new RequirementDataDefinition());
- RelationshipInfo relation = new RelationshipInfo();
- relation.setRequirementUid("Uid");
- relation.setRequirement("requirment");
- relation.setCapability("cap");
- relation.setCapabilityOwnerId("id1");
- cap.setRelation(relation);
- relationships.add(cap);
- rel.setRelationships(relationships);
- rel.setToNode("name");
- fromInstance.setUniqueId("name");
- fromInstance.setComponentUid("string");
- instancesList.add(fromInstance);
- Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
- fromOriginComponent.setRequirements(requirements);
-
- // default test
- result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
- rel, toscaRequirements, componentCache);
-
- }
-
- @Test
- public void testAddRequirmentsWhenFindRequirmentsReturnsValue() {
-
- ComponentInstance fromInstance = new ComponentInstance();
- Component fromOriginComponent = new Resource();
- List<ComponentInstance> instancesList = new ArrayList<>();
- RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
- List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
- Map<String, Component> componentCache = new HashMap<>();
- boolean result;
-
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
- cap.setRequirement(new RequirementDataDefinition());
- RelationshipInfo relation = new RelationshipInfo();
- relation.setRequirementUid("Uid");
- relation.setRequirement("requirment");
- relation.setCapability("cap");
- relation.setCapabilityOwnerId("id1");
- cap.setRelation(relation);
- relationships.add(cap);
- rel.setRelationships(relationships);
- rel.setToNode("name");
- fromInstance.setUniqueId("name");
- fromInstance.setComponentUid("string");
- instancesList.add(fromInstance);
- Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
-
- List<RequirementDefinition> defs = new ArrayList<>();
- RequirementDefinition def = new RequirementDefinition();
- def.setName("requirment");
- def.setCapability("cap");
- defs.add(def);
- requirements.put("key", defs);
- fromOriginComponent.setRequirements(requirements);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class),
- Mockito.any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
- rel, toscaRequirements, componentCache);
- }
-
- @Test
- public void testAddRequirmentsWhenCapabilityBelongsToRelation() {
- ComponentInstance fromInstance = new ComponentInstance();
- Component fromOriginComponent = new Resource();
- List<ComponentInstance> instancesList = new ArrayList<>();
- RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
- List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
- Map<String, Component> componentCache = new HashMap<>();
- boolean result;
-
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
- cap.setRequirement(new RequirementDataDefinition());
- RelationshipInfo relation = new RelationshipInfo();
- relation.setRequirementUid("Uid");
- relation.setRequirement("requirment");
- relation.setCapability("cap");
- relation.setCapabilityOwnerId("id1");
- cap.setRelation(relation);
- relationships.add(cap);
- rel.setRelationships(relationships);
- rel.setToNode("name");
- fromInstance.setUniqueId("name");
- fromInstance.setComponentUid("string");
- instancesList.add(fromInstance);
- Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
-
- List<RequirementDefinition> defs = new ArrayList<>();
- RequirementDefinition def = new RequirementDefinition();
- def.setName("requirment");
- def.setCapability("cap");
- defs.add(def);
- requirements.put("key", defs);
- fromOriginComponent.setRequirements(requirements);
-
- Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
- List<CapabilityDefinition> caps = new ArrayList<>();
- CapabilityDefinition capdef = new CapabilityDefinition();
- capdef.setOwnerId("id");
- capdef.setName("name");
- capdef.setType("type");
- caps.add(capdef);
- capabilities.put("cap", caps);
-
- fromOriginComponent.setCapabilities(capabilities);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class),
- Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
- rel, toscaRequirements, componentCache);
- }
- @Ignore("need to fix change in injected class.")
- @Test
- public void testAddRequirmentsWithBuildAndAddRequirements() {
- ComponentInstance fromInstance = new ComponentInstance();
- Component fromOriginComponent = new Resource();
- List<ComponentInstance> instancesList = new ArrayList<>();
- RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
- List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
- Map<String, Component> componentCache = new HashMap<>();
- boolean result;
-
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
- cap.setRequirement(new RequirementDataDefinition());
- RelationshipInfo relation = new RelationshipInfo();
- relation.setRequirementUid("Uid");
- relation.setRequirement("requirment");
- relation.setCapability("cap");
- relation.setCapabilityOwnerId("id");
- cap.setRelation(relation);
- relationships.add(cap);
- rel.setRelationships(relationships);
- rel.setToNode("name");
- fromInstance.setUniqueId("name");
- fromInstance.setComponentUid("string");
- instancesList.add(fromInstance);
- Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
-
- List<RequirementDefinition> defs = new ArrayList<>();
- RequirementDefinition def = new RequirementDefinition();
- def.setName("requirment");
- def.setCapability("cap");
- defs.add(def);
- requirements.put("key", defs);
- fromOriginComponent.setRequirements(requirements);
-
- Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
- List<CapabilityDefinition> caps = new ArrayList<>();
- CapabilityDefinition capdef = new CapabilityDefinition();
- capdef.setOwnerId("id");
- capdef.setName("cap");
- capdef.setType("type");
- caps.add(capdef);
- capabilities.put("cap", caps);
- fromOriginComponent.setCapabilities(capabilities);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class),
- Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
-
- Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(Mockito.any(Map.class),
- Mockito.any(Component.class), Mockito.any(List.class), Mockito.anyString(),Mockito.anyString()))
- .thenReturn(Either.right(false));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
- rel, toscaRequirements, componentCache);
- }
- @Ignore("need to fix change in injected class.")
- @Test
- public void testBuildAndAddRequirement() throws Exception {
- List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
- Component fromOriginComponent = new Resource();
- Component toOriginComponent = new Resource();
- CapabilityDefinition capability = new CapabilityDefinition();
- RequirementDefinition requirement = new RequirementDefinition();
- RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
- ComponentInstance toInstance = new ComponentInstance();
- Map<String, Component> componentCache = new HashMap<>();
- boolean result;
- capability.setPath(new ArrayList<>());
- reqAndRelationshipPair.setCapability("cap");
- requirement.setPath(new ArrayList<>());
- reqAndRelationshipPair.setRequirement("req");
-
- Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(new HashMap<>(), toOriginComponent,
- new ArrayList<>(),Mockito.anyString(), "cap")).thenReturn(Either.left("buildCapNameRes"));
-
- Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(new HashMap<>(), fromOriginComponent,
- new ArrayList<>(),Mockito.anyString(), "req")).thenReturn(Either.right(false));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "buildAndAddRequirement", toscaRequirements, fromOriginComponent,
- toOriginComponent, capability, requirement, reqAndRelationshipPair, toInstance, componentCache);
- }
-
- @Ignore("need to fix change in injected class.")
- @Test
- public void testBuildAndAddRequirementBuildSubtitutedNameReturnsValueTwice() {
- List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
- Component fromOriginComponent = new Resource();
- Component toOriginComponent = new Resource();
- CapabilityDefinition capability = new CapabilityDefinition();
- RequirementDefinition requirement = new RequirementDefinition();
- RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
- ComponentInstance toInstance = new ComponentInstance();
- Map<String, Component> componentCache = new HashMap<>();
- boolean result;
- capability.setPath(new ArrayList<>());
- reqAndRelationshipPair.setCapability("cap");
- requirement.setPath(new ArrayList<>());
- reqAndRelationshipPair.setRequirement("req");
-
- Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(Mockito.anyMap(), Mockito.any(Resource.class),
- Mockito.anyList(), Mockito.anyString(),Mockito.anyString())).thenReturn(Either.left("buildCapNameRes"));
-
- // default test
- result = Deencapsulation.invoke(testSubject, "buildAndAddRequirement", toscaRequirements, fromOriginComponent,
- toOriginComponent, capability, requirement, reqAndRelationshipPair, toInstance, componentCache);
- }
-
- @Test
- public void testIsRequirementBelongToRelation() throws Exception {
-
- Component originComponent = new Resource();
- RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
- RequirementDefinition requirement = new RequirementDefinition();
- String fromInstanceId = "";
- boolean result;
-
- requirement.setName("name");
- reqAndRelationshipPair.setRequirement("name1");
-
- // test return false
- result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
- reqAndRelationshipPair, requirement, fromInstanceId);
- }
-
- @Test
- public void testIsRequirementBelongToRelationWithNonAtomicComponent() {
-
- Component originComponent = new Service();
- RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
- RequirementDefinition requirement = new RequirementDefinition();
- String fromInstanceId = "";
- boolean result;
-
- // default test return true
- result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
- reqAndRelationshipPair, requirement, fromInstanceId);
- }
-
- @Test
- public void testIsRequirementBelongToOwner() throws Exception {
-
- RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
- RequirementDefinition requirement = new RequirementDefinition();
- String fromInstanceId = "";
- Component originComponent = new Resource();
- boolean result;
-
- requirement.setOwnerId("owner1");
- reqAndRelationshipPair.setRequirementOwnerId("owner");
-
- // default test
- result = Deencapsulation.invoke(testSubject, "isRequirementBelongToOwner", reqAndRelationshipPair, requirement,
- fromInstanceId, originComponent);
- }
-
- @Test
- public void testIsCvfc() throws Exception {
-
- Component component = new Resource();
- boolean result;
-
- component = new Service();
-
- result = Deencapsulation.invoke(testSubject, "isCvfc", component);
- }
-
- @Test
- public void testConvertCapabilities() throws Exception {
- Component component = new Resource();
- SubstitutionMapping substitutionMappings = new SubstitutionMapping();
- Map<String, Component> componentCache = new HashMap<>();
- Either<SubstitutionMapping, ToscaError> result;
-
- Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingCapabilities(componentCache, component))
- .thenReturn(Either.right(ToscaError.NODE_TYPE_CAPABILITY_ERROR));
-
- // default test return isRight
- result = Deencapsulation.invoke(testSubject, "convertCapabilities", component, substitutionMappings,
- componentCache);
- }
- @Ignore("need to fix change in injected class.")
- @Test
- public void testConvertCapabilities_1() throws Exception {
- Component component = new Resource();
- ToscaNodeType nodeType = new ToscaNodeType();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- Either<ToscaNodeType, ToscaError> result;
-
- Map<String, ToscaCapability> capabilities = new HashMap<>();
- capabilities.put("key", new ToscaCapability());
-
- Mockito.when(capabiltyRequirementConvertor.convertCapabilities(Mockito.any(Map.class), component, dataTypes)).thenReturn(capabilities);
-
- // default test
- result = Deencapsulation.invoke(testSubject, "convertCapabilities", component, nodeType, dataTypes);
- }
-
- @Test
- public void testConvertToNodeTemplateArtifacts() throws Exception {
- Map<String, ToscaArtifactDataDefinition> container = new HashMap<>();
- ToscaArtifactDataDefinition art = new ToscaArtifactDataDefinition();
- art.setFile("test_file");
- art.setType("test_type");
- Map<String, ToscaTemplateArtifact> result;
- container.put("test_art", art);
- result = Deencapsulation.invoke(testSubject, "convertToNodeTemplateArtifacts", container);
- Assert.assertTrue(MapUtils.isNotEmpty(result));
- Assert.assertTrue(result.get("test_art").getFile().equals("test_file"));
- Assert.assertTrue(result.get("test_art").getType().equals("test_type"));
- }
+
+ private static final String COMPONENT_PROPERTY_NAME = "prop1";
+ private static final String COMPONENT_PROPERTY_TYPE = "string";
+ private static final String COMPONENT_INPUT_NAME = "input1";
+ private static final String COMPONENT_INPUT_TYPE = "integer";
+ private static final String RESOURCE_NAME = "resource";
+ private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1";
+
+ @InjectMocks
+ private ToscaExportHandler testSubject;
+
+ @Mock
+ private ApplicationDataTypeCache dataTypeCache;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @Mock
+ private CapabilityRequirementConverter capabiltyRequirementConvertor;
+
+ @Mock
+ private InputConverter inputConverter;
+
+ @Mock
+ private GroupExportParser groupExportParser;
+
+ @Mock
+ private GroupExportParserImpl groupExportParserImpl;
+
+ @Mock
+ private InterfaceLifecycleOperation interfaceLifecycleOperation;
+
+ @Mock
+ private PolicyExportParser policyExportParser;
+
+ @Before
+ public void setUpMock() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ private Resource getNewResource() {
+ Resource resource = new Resource();
+ List<CategoryDefinition> categories = new ArrayList<>();
+ CategoryDefinition category = new CategoryDefinition();
+ List<SubCategoryDefinition> subcategories = new ArrayList<>();
+ SubCategoryDefinition subcategory = new SubCategoryDefinition();
+ List<DataTypeDefinition> dataTypes = new ArrayList<>();
+ DataTypeDefinition dataType = new DataTypeDefinition();
+ dataType.setName("dataTypeName");
+ dataType.setDerivedFromName("tosca.datatypes.Root");
+ PropertyDataDefinition propData = new PropertyDataDefinitionBuilder()
+ .setName("property")
+ .setType("type")
+ .build();
+ List<PropertyDataDefinition> propDataList = Arrays.asList(propData);
+ dataType.setPropertiesData(propDataList);
+ List<PropertyDefinition> propList = propDataList.stream().map(PropertyDefinition::new)
+ .collect(Collectors.toList());
+ dataType.setProperties(propList);
+ dataTypes.add(dataType);
+
+ subcategory.setName("name");
+ subcategories.add(subcategory);
+ category.setName("name");
+ category.setSubcategories(subcategories);
+ categories.add(category);
+
+ resource.setCategories(categories);
+ resource.setVersion("version");
+ resource.setVendorName("vendorName");
+ resource.setVendorRelease("vendorRelease");
+ resource.setResourceVendorModelNumber("resourceVendorModelNumber");
+ resource.setDataTypes(dataTypes);
+
+ return resource;
+ }
+
+ private Service getNewService() {
+ Service service = new Service();
+ List<CategoryDefinition> categories = new ArrayList<>();
+ CategoryDefinition category = new CategoryDefinition();
+ List<SubCategoryDefinition> subcategories = new ArrayList<>();
+ SubCategoryDefinition subcategory = new SubCategoryDefinition();
+
+ subcategory.setName("name");
+ subcategories.add(subcategory);
+ category.setName("name");
+ category.setSubcategories(subcategories);
+ categories.add(category);
+
+ service.setCategories(categories);
+ service.setComponentType(ComponentTypeEnum.SERVICE);
+ service.setServiceType("serviceType");
+ service.setServiceRole("serviceRole");
+ service.setEnvironmentContext("environmentContext");
+
+ return service;
+ }
+
+ @Test
+ public void testExportComponent() throws Exception {
+ Component component = getNewResource();
+ Either<ToscaRepresentation, ToscaError> result;
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ Mockito
+ .when(capabiltyRequirementConvertor.convertRequirements(any(Map.class), any(Resource.class),
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
+ .thenReturn(Either.left(Collections.emptyMap()));
+
+ // default test when component is Resource
+ result = testSubject.exportComponent(component);
+ Assert.assertNotNull(result);
+
+ component = getNewService();
+ Mockito
+ .when(capabiltyRequirementConvertor.convertRequirements(any(Map.class), any(Service.class),
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+
+ // default test when component is Service
+ result = testSubject.exportComponent(component);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testExportComponentInterface() throws Exception {
+ Component component = getNewResource();
+ Either<ToscaRepresentation, ToscaError> result;
+
+ ((Resource) component).setInterfaces(new HashMap<>());
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
+ .thenReturn(Either.left(Collections.emptyMap()));
+ // default test when convertInterfaceNodeType is right
+ result = testSubject.exportComponentInterface(component, false);
+ Assert.assertNotNull(result);
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ Mockito
+ .when(capabiltyRequirementConvertor.convertRequirements(any(Map.class), any(Resource.class),
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+
+ // default test when convertInterfaceNodeType is left
+ result = testSubject.exportComponentInterface(component, false);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertInterfaceNodeTypeProperties() throws Exception {
+
+ Resource component = getNewResource();
+
+ component.setInterfaces(new HashMap<>());
+ InputDefinition input = new InputDefinition();
+ input.setName(COMPONENT_INPUT_NAME);
+ input.setType(COMPONENT_INPUT_TYPE);
+ component.setInputs(Collections.singletonList(input));
+ PropertyDefinition property = new PropertyDefinition();
+ property.setName(COMPONENT_PROPERTY_NAME);
+ property.setType(COMPONENT_PROPERTY_TYPE);
+ component.setProperties(Collections.singletonList(property));
+ component.setName(RESOURCE_NAME);
+ component.setToscaResourceName(RESOURCE_NAME);
+
+ Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
+ .thenReturn(Either.left(Collections.emptyMap()));
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ // when convertRequirements is called, make it return the same value as 3rd (index=2) argument.
+ Mockito
+ .when(capabiltyRequirementConvertor.convertRequirements(any(Map.class), any(Resource.class),
+ any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
+
+ Either<ToscaTemplate, ToscaError> result = (Either<ToscaTemplate, ToscaError>) Deencapsulation
+ .invoke(testSubject, "convertInterfaceNodeType", new HashMap<String, Component>(), component,
+ new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
+ Assert.assertNotNull(result);
+ assertThat(result.isLeft(), is(true));
+ Map<String, ToscaNodeType> nodeTypeMap = result.left().value().getNode_types();
+ assertThat(nodeTypeMap.size(), is(1));
+ ToscaNodeType toscaNodeType = nodeTypeMap.values().iterator().next();
+ Map<String, ToscaProperty> propertyMap = toscaNodeType.getProperties();
+ // Check if inputs and properties in component are merged properly
+ assertThat(propertyMap.size(), is(2));
+ assertThat(propertyMap.containsKey(COMPONENT_INPUT_NAME), is(true));
+ assertThat(propertyMap.containsKey(COMPONENT_PROPERTY_NAME), is(true));
+ }
+
+ @Test
+ public void testCreateToscaRepresentation() throws Exception {
+ ToscaTemplate toscaTemplate = new ToscaTemplate("");
+ ToscaRepresentation result;
+
+ // default test
+ result = testSubject.createToscaRepresentation(toscaTemplate);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testGetDependencies() throws Exception {
+
+ Component component = new Resource();
+ Either<ToscaTemplate, ToscaError> result;
+
+ // default test
+ result = testSubject.getDependencies(component);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertToscaTemplate() throws Exception {
+
+ Component component = getNewResource();
+ ToscaTemplate toscaNode = new ToscaTemplate("");
+ Either<ToscaTemplate, ToscaError> result;
+ List<ComponentInstance> resourceInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+
+ instance.setOriginType(OriginTypeEnum.SERVICE);
+ instance.setSourceModelUid("targetModelUid");
+ resourceInstances.add(instance);
+
+ component.setComponentInstances(resourceInstances);
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ Mockito.when(capabiltyRequirementConvertor.getOriginComponent(any(Map.class),
+ any(ComponentInstance.class))).thenReturn(Either.right(false));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertToscaTemplateWhenComponentContainsGroup() {
+ Component component = getNewResource();
+ ToscaTemplate toscaNode = new ToscaTemplate("");
+ Either<ToscaTemplate, ToscaError> result;
+ component.setComponentInstances(new ArrayList<>());
+
+ List<GroupDefinition> groups = new ArrayList<>();
+ GroupDefinition group = new GroupDefinition();
+ List<String> artifacts = new ArrayList<>();
+ artifacts.add("artifact");
+ group.setType("org.openecomp.groups.VfModule");
+ group.setArtifacts(artifacts);
+ groups.add(group);
+ component.setGroups(groups);
+
+ Map<String, String[]> substitutionMappingMap = new HashMap<>();
+ String[] array = {"value1", "value2"};
+ substitutionMappingMap.put("key", array);
+
+ Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingCapabilities(any(Map.class),
+ any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
+
+ Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingRequirements(any(Map.class),
+ any(Component.class), any(SubstitutionMapping.class)))
+ .thenReturn(Either.left(new SubstitutionMapping()));
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+
+ Mockito.when(inputConverter.convertInputs(any(List.class), any(Map.class)))
+ .thenReturn(new HashMap<>());
+
+ Mockito.when(groupExportParser.getGroups(component))
+ .thenReturn(null);
+
+ // test component contains group
+ result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertToscaTemplateWhenComponentIsService() throws Exception {
+ Component component = getNewService();
+ ToscaTemplate toscaNode = new ToscaTemplate("");
+ Either<ToscaTemplate, ToscaError> result;
+ component.setComponentInstances(new ArrayList<>());
+
+ List<GroupDefinition> groups = new ArrayList<>();
+ GroupDefinition group = new GroupDefinition();
+ List<String> artifacts = new ArrayList<>();
+ artifacts.add("artifact");
+ group.setType("org.openecomp.groups.VfModule");
+ group.setArtifacts(artifacts);
+ groups.add(group);
+ component.setGroups(groups);
+
+ Map<String, String[]> substitutionMappingMap = new HashMap<>();
+ String[] array = {"value1", "value2"};
+ substitutionMappingMap.put("key", array);
+
+ Mockito
+ .when(capabiltyRequirementConvertor.convertSubstitutionMappingCapabilities(anyMap(), any(Component.class)))
+ .thenReturn(Either.left(substitutionMappingMap));
+
+ Mockito.when(capabiltyRequirementConvertor
+ .convertSubstitutionMappingRequirements(anyMap(), any(Component.class), any(SubstitutionMapping.class)))
+ .thenReturn(Either.left(new SubstitutionMapping()));
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+
+ Mockito.when(inputConverter.convertInputs(anyList(), anyMap())).thenReturn(new HashMap<>());
+ // test component contains group
+ result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertMetadata_1() throws Exception {
+
+ Component component = getNewResource();
+ boolean isInstance = true;
+ ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setOriginType(OriginTypeEnum.ServiceProxy);
+ componentInstance.setSourceModelInvariant("targetModelInvariant");
+
+ ToscaMetadata result;
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertMetadata", component, isInstance, componentInstance);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testFillImports() throws Exception {
+
+ Component component = getNewService();
+ ToscaTemplate toscaTemplate = new ToscaTemplate("");
+ Either<ImmutablePair<ToscaTemplate, Map<String, Component>>, ToscaError> result;
+
+ ComponentInstance instance = new ComponentInstance();
+ List<ComponentInstance> resourceInstances = new ArrayList<>();
+ instance.setComponentUid("name");
+ resourceInstances.add(instance);
+ component.setComponentInstances(resourceInstances);
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("name.name2");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+ component.setToscaArtifacts(toscaArtifacts);
+
+ Mockito.when(toscaOperationFacade.getToscaFullElement(any(String.class)))
+ .thenReturn(Either.left(component));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "fillImports", component, toscaTemplate);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testCreateDependency() throws Exception {
+
+ Map<String, Component> componentCache = new HashMap<>();
+ List<Map<String, Map<String, String>>> imports = new ArrayList<>();
+ List<Triple<String, String, Component>> dependecies = new ArrayList<>();
+ ComponentInstance ci = new ComponentInstance();
+ Component component = getNewResource();
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("name.name2");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+ component.setToscaArtifacts(toscaArtifacts);
+ ci.setComponentUid("name");
+ ci.setOriginType(OriginTypeEnum.ServiceProxy);
+ ci.setSourceModelUid("modelName");
+
+ Mockito.when(toscaOperationFacade.getToscaFullElement(eq("name"))).thenReturn(Either.left(component));
+
+ Mockito.when(toscaOperationFacade.getToscaFullElement(eq("modelName")))
+ .thenReturn(Either.left(new Service()));
+
+ // default test
+ Deencapsulation.invoke(testSubject, "createDependency", componentCache, imports, dependecies, ci);
+ }
+
+ @Test
+ public void testGetInterfaceFilename() throws Exception {
+ String artifactName = "artifact.name";
+ String result;
+
+ // default test
+ result = ToscaExportHandler.getInterfaceFilename(artifactName);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertNodeType() throws Exception {
+ Component component = new Resource();
+ ToscaTemplate toscaNode = new ToscaTemplate("");
+ Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
+ Either<ToscaTemplate, ToscaError> result;
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
+ Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
+ .thenReturn(Either.left(Collections.emptyMap()));
+ // default test
+ result = Deencapsulation
+ .invoke(testSubject, "convertNodeType", new HashMap<>(), component, toscaNode, nodeTypes);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertInterfaceNodeType() throws Exception {
+ Component component = getNewResource();
+ ToscaTemplate toscaNode = new ToscaTemplate("");
+ Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
+ Either<ToscaTemplate, ToscaError> result;
+ List<InputDefinition> inputs = new ArrayList<>();
+ inputs.add(new InputDefinition());
+ component.setInputs(inputs);
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
+ .thenReturn(Either.left(Collections.emptyMap()));
+
+ Mockito
+ .when(capabiltyRequirementConvertor.convertRequirements(any(Map.class), any(Resource.class),
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertInterfaceNodeType", new HashMap<>(), component, toscaNode
+ , nodeTypes, false);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertReqCapAndTypeName() throws Exception {
+ Component component = new Resource();
+ ToscaTemplate toscaNode = new ToscaTemplate("");
+ Map<String, ToscaNodeType> nodeTypes = new HashMap();
+ ToscaNodeType toscaNodeType = new ToscaNodeType();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ Either<ToscaTemplate, ToscaError> result;
+
+ Mockito.when(
+ capabiltyRequirementConvertor
+ .convertCapabilities(any(Map.class), any(Resource.class), any(Map.class)))
+ .thenReturn(new HashMap<>());
+
+ Mockito
+ .when(capabiltyRequirementConvertor.convertRequirements(any(Map.class), any(Resource.class),
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+
+ // default test
+ result = Deencapsulation
+ .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
+ toscaNodeType, dataTypes);
+ Assert.assertNotNull(result);
+
+ component = new Service();
+
+ Mockito
+ .when(capabiltyRequirementConvertor.convertRequirements(any(Map.class), any(Service.class),
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+
+ // test when component is service
+ result = Deencapsulation
+ .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
+ toscaNodeType, dataTypes);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertNodeTemplates() throws Exception {
+ Component component = getNewResource();
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
+ Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
+ Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
+ List<ComponentInstanceInput> inputs = new ArrayList<>();
+ inputs.add(new ComponentInstanceInput());
+ componentInstancesInputs.put("key", inputs);
+ List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
+ RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
+ reldef.setFromNode("node");
+ resourceInstancesRelations.add(reldef);
+ component.setComponentInstancesRelations(resourceInstancesRelations);
+
+ ComponentInstance instance = new ComponentInstance();
+ instance.setUniqueId("id");
+ instance.setComponentUid("uid");
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ List<GroupInstance> groupInstances = new ArrayList<>();
+ GroupInstance groupInst = new GroupInstance();
+ List<String> artifacts = new ArrayList<>();
+ artifacts.add("artifact");
+ groupInst.setArtifacts(artifacts);
+ groupInst.setType("type");
+ groupInstances.add(groupInst);
+ instance.setGroupInstances(groupInstances);
+ componentInstances.add(instance);
+
+ component.setComponentInstancesInputs(componentInstancesInputs);
+ component.setInvariantUUID("uuid");
+ component.setUUID("uuid");
+ component.setDescription("desc");
+
+ componentCache.put("uid", component);
+
+ componentInstancesProperties.put("id", new ArrayList<>());
+ componentInstancesInputs.put("id", new ArrayList<>());
+
+ Mockito.when(capabiltyRequirementConvertor.getOriginComponent(any(Map.class),
+ any(ComponentInstance.class))).thenReturn(Either.left(component));
+
+ Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities(
+ any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
+ .thenReturn(Either.left(new ToscaNodeTemplate()));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
+ componentInstancesProperties, new HashMap<>(), componentCache, dataTypes, topologyTemplate);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertNodeTemplatesWhenComponentIsService() throws Exception {
+ Component component = getNewService();
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
+ Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
+ Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
+ List<ComponentInstanceInput> inputs = new ArrayList<>();
+ inputs.add(new ComponentInstanceInput());
+ componentInstancesInputs.put("key", inputs);
+ List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
+ RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
+ reldef.setFromNode("node");
+ resourceInstancesRelations.add(reldef);
+ component.setComponentInstancesRelations(resourceInstancesRelations);
+
+ ComponentInstance instance = new ComponentInstance();
+ instance.setUniqueId("id");
+ instance.setComponentUid("uid");
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ List<GroupInstance> groupInstances = new ArrayList<>();
+ GroupInstance groupInst = new GroupInstance();
+ List<String> artifacts = new ArrayList<>();
+ artifacts.add("artifact");
+ groupInst.setArtifacts(artifacts);
+ groupInst.setType("type");
+ groupInstances.add(groupInst);
+ instance.setGroupInstances(groupInstances);
+ componentInstances.add(instance);
+
+ component.setComponentInstancesInputs(componentInstancesInputs);
+ component.setInvariantUUID("uuid");
+ component.setUUID("uuid");
+ component.setDescription("desc");
+
+ Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
+ ForwardingPathDataDefinition path = new ForwardingPathDataDefinition();
+ ListDataDefinition<ForwardingPathElementDataDefinition> list = new ListDataDefinition<>();
+ path.setPathElements(list);
+ forwardingPaths.put("key", path);
+
+ ((Service) component).setForwardingPaths(forwardingPaths);
+
+ componentCache.put("uid", component);
+
+ componentInstancesProperties.put("id", new ArrayList<>());
+ componentInstancesInterfaces.put("id", new ArrayList<>());
+ componentInstancesInputs.put("id", new ArrayList<>());
+
+ Mockito.when(capabiltyRequirementConvertor.getOriginComponent(any(Map.class),
+ any(ComponentInstance.class))).thenReturn(Either.left(component));
+
+ Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities(
+ any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
+ .thenReturn(Either.left(new ToscaNodeTemplate()));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
+ componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertNodeTemplatesWhenConvertComponentInstanceCapabilitiesIsRight() throws Exception {
+ Component component = getNewResource();
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
+ Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
+ Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
+ List<ComponentInstanceInput> inputs = new ArrayList<>();
+ inputs.add(new ComponentInstanceInput());
+ componentInstancesInputs.put("key", inputs);
+ List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
+ RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
+ reldef.setFromNode("node");
+ resourceInstancesRelations.add(reldef);
+ component.setComponentInstancesRelations(resourceInstancesRelations);
+
+ ComponentInstance instance = new ComponentInstance();
+ instance.setUniqueId("id");
+ instance.setComponentUid("uid");
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ componentInstances.add(instance);
+
+ component.setComponentInstancesInputs(componentInstancesInputs);
+ component.setInvariantUUID("uuid");
+ component.setUUID("uuid");
+ component.setDescription("desc");
+
+ componentCache.put("uid", component);
+
+ Mockito.when(capabiltyRequirementConvertor.getOriginComponent(any(Map.class),
+ any(ComponentInstance.class))).thenReturn(Either.left(component));
+
+ Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities(
+ any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
+ .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
+ componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvetNodeTemplateWhenGetOriginComponentIsRight() throws Exception {
+ Component component = getNewResource();
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
+ Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
+ Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
+ List<ComponentInstanceInput> inputs = new ArrayList<>();
+ inputs.add(new ComponentInstanceInput());
+ componentInstancesInputs.put("key", inputs);
+ List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
+ RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
+ reldef.setFromNode("id");
+ resourceInstancesRelations.add(reldef);
+ component.setComponentInstancesRelations(resourceInstancesRelations);
+
+ ComponentInstance instance = new ComponentInstance();
+ instance.setUniqueId("id");
+ instance.setComponentUid("uid");
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ componentInstances.add(instance);
+
+ component.setComponentInstancesInputs(componentInstancesInputs);
+ component.setInvariantUUID("uuid");
+ component.setUUID("uuid");
+ component.setDescription("desc");
+
+ componentCache.put("uid", component);
+
+ Mockito.when(capabiltyRequirementConvertor.getOriginComponent(any(Map.class),
+ any(ComponentInstance.class))).thenReturn(Either.right(false));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
+ componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertNodeTemplatesWhenConvertComponentInstanceRequirmentsIsRight() {
+ Component component = new Resource();
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
+ Map<String, List<ComponentInstanceProperty>> componentInstancesInterfaces = new HashMap<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate();
+ Either<Map<String, ToscaNodeTemplate>, ToscaError> result;
+ Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
+ List<ComponentInstanceInput> inputs = new ArrayList<>();
+ inputs.add(new ComponentInstanceInput());
+ componentInstancesInputs.put("key", inputs);
+ List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
+ RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
+ reldef.setFromNode("id");
+ reldef.setToNode("node");
+ List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
+ CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
+ relationship.setRelation(new RelationshipInfo());
+ relationships.add(relationship);
+ reldef.setRelationships(relationships);
+ resourceInstancesRelations.add(reldef);
+ component.setComponentInstancesRelations(resourceInstancesRelations);
+
+ ComponentInstance instance = new ComponentInstance();
+ instance.setUniqueId("id");
+ componentInstances.add(instance);
+
+ component.setComponentInstancesInputs(componentInstancesInputs);
+ component.setComponentInstances(componentInstances);
+
+ Mockito.when(capabiltyRequirementConvertor.getOriginComponent(any(Map.class),
+ any(ComponentInstance.class))).thenReturn(Either.left(component));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertNodeTemplates", component, componentInstances,
+ componentInstancesProperties, componentInstancesInterfaces, componentCache, dataTypes, topologyTemplate);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testAddComponentInstanceInputs() throws Exception {
+
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
+ ComponentInstance componentInstance = new ComponentInstance();
+ String instanceUniqueId = "id";
+ Map<String, Object> props = new HashMap<>();
+
+ List<ComponentInstanceInput> componentInstanceInputs = new ArrayList<>();
+ componentInstanceInputs.add(new ComponentInstanceInput());
+
+ componentInstancesInputs.put(instanceUniqueId, componentInstanceInputs);
+
+ // default test
+ Deencapsulation.invoke(testSubject, "addComponentInstanceInputs", dataTypes, componentInstancesInputs,
+ instanceUniqueId, props);
+ }
+
+ @Test
+ public void testAddPropertiesOfComponentInstance() throws Exception {
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ ComponentInstance componentInstance = new ComponentInstance();
+ String instanceUniqueId = "id";
+ Map<String, Object> props = new HashMap<>();
+
+ ComponentInstanceProperty cip = new ComponentInstanceProperty();
+ cip.setInstanceUniqueId("id");
+
+ List<ComponentInstanceProperty> list = new ArrayList<>();
+ list.add(cip);
+
+ componentInstancesProperties.put("id", list);
+
+ // default test
+ Deencapsulation.invoke(testSubject, "addPropertiesOfComponentInstance", componentInstancesProperties, dataTypes,
+ instanceUniqueId, props);
+ }
+
+ @Test
+ public void testAddPropertiesOfParentComponent() throws Exception {
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ ComponentInstance componentInstance = new ComponentInstance();
+ Component componentOfInstance = new Resource();
+ Map<String, Object> props = new HashMap<>();
+
+ List<PropertyDefinition> properties = new ArrayList<>();
+ properties.add(new PropertyDefinition());
+
+ ((Resource) componentOfInstance).setProperties(properties);
+
+ // default test
+ Deencapsulation.invoke(testSubject, "addPropertiesOfParentComponent", dataTypes,
+ componentOfInstance, props);
+ }
+
+ @Test
+ public void testCreateNodeType() throws Exception {
+
+ Component component = new Resource();
+ List<String> array = new ArrayList<>();
+ array.add("value");
+ ((Resource) component).setDerivedFrom(array);
+ ToscaNodeType result;
+
+ // test when component is resource
+ result = Deencapsulation.invoke(testSubject, "createNodeType", component);
+ Assert.assertNotNull(result);
+
+ component = new Service();
+ // test when component is service
+ result = Deencapsulation.invoke(testSubject, "createNodeType", component);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testCreateProxyInterfaceTypesComponentNotFound() throws Exception {
+ Component container = new Service();
+ Either<Map<String, ToscaNodeType>, ToscaError> result;
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ instance.setSourceModelUid("targetModelUid");
+ instance.setToscaComponentName("toscaComponentName");
+
+ componentInstances.add(instance);
+ container.setComponentInstances(componentInstances);
+ Mockito.when(toscaOperationFacade.getToscaElement(any(String.class),
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
+ Assert.assertTrue(result.isRight());
+ }
+
+ @Test
+ public void testCreateProxyInterfaceTypesWhenInterfaceLifecycleFetchFailed() {
+ Component container = new Service();
+ Either<Map<String, ToscaNodeType>, ToscaError> result;
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ instance.setSourceModelUid("targetModelUid");
+ instance.setToscaComponentName("toscaComponentName");
+ componentInstances.add(instance);
+ container.setComponentInstances(componentInstances);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(any(String.class),
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.left(new Resource()));
+ Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
+ Assert.assertTrue(result.isRight());
+ }
+
+ @Test
+ public void testCreateProxyInterfaceTypesPositive() {
+ Component container = new Service();
+ Either<Map<String, ToscaNodeType>, ToscaError> result;
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ instance.setSourceModelUid("targetModelUid");
+ instance.setToscaComponentName("toscaComponentName");
+ componentInstances.add(instance);
+ container.setComponentInstances(componentInstances);
+
+ Mockito.when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
+ .thenReturn(Either.left(Collections.emptyMap()));
+
+ Component proxyResource = new Resource();
+ Map<String, InterfaceDefinition> proxyInterfaces = new HashMap<>();
+ proxyInterfaces.put("Local", new InterfaceDefinition("Local", "desc", new HashMap<>()));
+ proxyResource.setInterfaces(proxyInterfaces);
+ Mockito.when(toscaOperationFacade.getToscaElement(any(String.class),
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.left(proxyResource));
+
+ result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result.isLeft());
+ Assert.assertEquals(1, result.left().value().size());
+ }
+
+ @Test
+ public void testCreateProxyNodeTypes() throws Exception {
+ Map<String, Component> componentCache = new HashMap<>();
+ Component container = new Resource();
+ Either<Map<String, ToscaNodeType>, ToscaError> result;
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ instance.setSourceModelUid("targetModelUid");
+
+ componentInstances.add(instance);
+ container.setComponentInstances(componentInstances);
+
+ Mockito.when(toscaOperationFacade.getLatestByName("serviceProxy"))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+
+ // test when getLatestByName return is right
+ result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testCreateProxyNodeTypesWhenGetLatestByNameReturnValue() {
+ Map<String, Component> componentCache = new HashMap<>();
+ Component container = new Resource();
+ Either<Map<String, ToscaNodeType>, ToscaError> result;
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ instance.setSourceModelUid("targetModelUid");
+
+ componentInstances.add(instance);
+ container.setComponentInstances(componentInstances);
+
+ Mockito.when(toscaOperationFacade.getLatestByName("serviceProxy")).thenReturn(Either.left(new Resource()));
+
+ ComponentParametersView parameterView = new ComponentParametersView();
+ parameterView.disableAll();
+ parameterView.setIgnoreCategories(false);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(any(String.class),
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+
+ // test when getLatestByName is left
+ result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testCreateProxyNodeType() throws Exception {
+ Map<String, Component> componentCache = new HashMap<>();
+ Component origComponent = new Resource();
+ Component proxyComponent = new Resource();
+ ComponentInstance instance = new ComponentInstance();
+ ToscaNodeType result;
+
+ Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "createProxyNodeType", componentCache, origComponent,
+ proxyComponent, instance);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertComponentInstanceRequirements() throws Exception {
+ Component component = new Resource();
+ ComponentInstance componentInstance = new ComponentInstance();
+ List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ ToscaNodeTemplate nodeTypeTemplate = new ToscaNodeTemplate();
+ Component originComponent = new Resource();
+ Map<String, Component> componentCache = new HashMap<>();
+ Either<ToscaNodeTemplate, ToscaError> result;
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
+ componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
+ Assert.assertNotNull(result);
+
+ RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
+ reldef.setFromNode("name");
+ reldef.setToNode("name1");
+ List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
+ CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
+ cap.setRelation(new RelationshipInfo());
+ relationships.add(cap);
+ reldef.setRelationships(relationships);
+ relations.add(reldef);
+ componentInstance.setUniqueId("name");
+
+ List<ComponentInstance> instances = new ArrayList<>();
+ instances.add(componentInstance);
+ component.setComponentInstances(instances);
+
+ // test when filteredRElations ins't empty
+ result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
+ componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testAddRequirement() throws Exception {
+ ComponentInstance fromInstance = new ComponentInstance();
+ Component fromOriginComponent = new Resource();
+ List<ComponentInstance> instancesList = new ArrayList<>();
+ RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ boolean result;
+
+ List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
+ CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
+ cap.setRequirement(new RequirementDataDefinition());
+ RelationshipInfo relation = new RelationshipInfo();
+ relation.setRequirementUid("Uid");
+ relation.setRequirement("requirment");
+ relation.setCapability("cap");
+ relation.setCapabilityOwnerId("id1");
+ cap.setRelation(relation);
+ relationships.add(cap);
+ rel.setRelationships(relationships);
+ rel.setToNode("name");
+ fromInstance.setUniqueId("name");
+ fromInstance.setComponentUid("string");
+ instancesList.add(fromInstance);
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ fromOriginComponent.setRequirements(requirements);
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
+ rel, toscaRequirements, componentCache);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testAddRequirmentsWhenFindRequirmentsReturnsValue() {
+
+ ComponentInstance fromInstance = new ComponentInstance();
+ Component fromOriginComponent = new Resource();
+ List<ComponentInstance> instancesList = new ArrayList<>();
+ RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ boolean result;
+
+ List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
+ CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
+ cap.setRequirement(new RequirementDataDefinition());
+ RelationshipInfo relation = new RelationshipInfo();
+ relation.setRequirementUid("Uid");
+ relation.setRequirement("requirment");
+ relation.setCapability("cap");
+ relation.setCapabilityOwnerId("id1");
+ cap.setRelation(relation);
+ relationships.add(cap);
+ rel.setRelationships(relationships);
+ rel.setToNode("name");
+ fromInstance.setUniqueId("name");
+ fromInstance.setComponentUid("string");
+ instancesList.add(fromInstance);
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+
+ List<RequirementDefinition> defs = new ArrayList<>();
+ RequirementDefinition def = new RequirementDefinition();
+ def.setName("requirment");
+ def.setCapability("cap");
+ defs.add(def);
+ requirements.put("key", defs);
+ fromOriginComponent.setRequirements(requirements);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(any(String.class),
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
+ rel, toscaRequirements, componentCache);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testAddRequirmentsWhenCapabilityBelongsToRelation() {
+ ComponentInstance fromInstance = new ComponentInstance();
+ Component fromOriginComponent = new Resource();
+ List<ComponentInstance> instancesList = new ArrayList<>();
+ RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ boolean result;
+
+ List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
+ CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
+ cap.setRequirement(new RequirementDataDefinition());
+ RelationshipInfo relation = new RelationshipInfo();
+ relation.setRequirementUid("Uid");
+ relation.setRequirement("requirment");
+ relation.setCapability("cap");
+ relation.setCapabilityOwnerId("id1");
+ cap.setRelation(relation);
+ relationships.add(cap);
+ rel.setRelationships(relationships);
+ rel.setToNode("name");
+ fromInstance.setUniqueId("name");
+ fromInstance.setComponentUid("string");
+ instancesList.add(fromInstance);
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+
+ List<RequirementDefinition> defs = new ArrayList<>();
+ RequirementDefinition def = new RequirementDefinition();
+ def.setName("requirment");
+ def.setCapability("cap");
+ defs.add(def);
+ requirements.put("key", defs);
+ fromOriginComponent.setRequirements(requirements);
+
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ List<CapabilityDefinition> caps = new ArrayList<>();
+ CapabilityDefinition capdef = new CapabilityDefinition();
+ capdef.setOwnerId("id");
+ capdef.setName("name");
+ capdef.setType("type");
+ caps.add(capdef);
+ capabilities.put("cap", caps);
+
+ fromOriginComponent.setCapabilities(capabilities);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(any(String.class),
+ any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
+ rel, toscaRequirements, componentCache);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testAddRequirmentsWithBuildAndAddRequirements() {
+ ComponentInstance fromInstance = new ComponentInstance();
+ Component fromOriginComponent = new Resource();
+ List<ComponentInstance> instancesList = new ArrayList<>();
+ RequirementCapabilityRelDef rel = new RequirementCapabilityRelDef();
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
+ Map<String, Component> componentCache = new HashMap<>();
+ boolean result;
+
+ List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
+ CapabilityRequirementRelationship cap = new CapabilityRequirementRelationship();
+ cap.setRequirement(new RequirementDataDefinition());
+ RelationshipInfo relation = new RelationshipInfo();
+ relation.setRequirementUid("Uid");
+ relation.setRequirement("requirment");
+ relation.setCapability("cap");
+ relation.setCapabilityOwnerId("id");
+ cap.setRelation(relation);
+ relationships.add(cap);
+ rel.setRelationships(relationships);
+ rel.setToNode("name");
+ fromInstance.setUniqueId("name");
+ fromInstance.setComponentUid("string");
+ instancesList.add(fromInstance);
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+
+ List<RequirementDefinition> defs = new ArrayList<>();
+ RequirementDefinition def = new RequirementDefinition();
+ def.setName("requirment");
+ def.setCapability("cap");
+ defs.add(def);
+ requirements.put("key", defs);
+ fromOriginComponent.setRequirements(requirements);
+
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ List<CapabilityDefinition> caps = new ArrayList<>();
+ CapabilityDefinition capdef = new CapabilityDefinition();
+ capdef.setOwnerId("id");
+ capdef.setName("cap");
+ capdef.setPreviousName("before cap");
+ capdef.setType("type");
+ caps.add(capdef);
+ capabilities.put("cap", caps);
+ fromOriginComponent.setCapabilities(capabilities);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(any(String.class),
+ any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
+
+ Mockito.when(
+ capabiltyRequirementConvertor
+ .buildSubstitutedName(anyMap(), any(Component.class), anyList(), anyString(), anyString()))
+ .thenReturn(Either.right(false));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList,
+ rel, toscaRequirements, componentCache);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testBuildAndAddRequirement() throws Exception {
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
+ Component fromOriginComponent = new Resource();
+ Component toOriginComponent = new Resource();
+ CapabilityDefinition capability = new CapabilityDefinition();
+ RequirementDefinition requirement = new RequirementDefinition();
+ RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
+ ComponentInstance toInstance = new ComponentInstance();
+ Map<String, Component> componentCache = new HashMap<>();
+ boolean result;
+ capability.setPath(new ArrayList<>());
+ capability.setPreviousName("before cap");
+ reqAndRelationshipPair.setCapability("cap");
+ requirement.setPath(new ArrayList<>());
+ requirement.setPreviousName("before req");
+ reqAndRelationshipPair.setRequirement("req");
+
+ Mockito.when(
+ capabiltyRequirementConvertor
+ .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("cap"), anyString()))
+ .thenReturn(Either.left("buildCapNameRes"));
+
+ Mockito.when(
+ capabiltyRequirementConvertor
+ .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("req"), anyString()))
+ .thenReturn(Either.right(false));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "buildAndAddRequirement", toscaRequirements, fromOriginComponent,
+ toOriginComponent, capability, requirement, reqAndRelationshipPair, toInstance, componentCache);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testBuildAndAddRequirementBuildSubtitutedNameReturnsValueTwice() {
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
+ Component fromOriginComponent = new Resource();
+ Component toOriginComponent = new Resource();
+ CapabilityDefinition capability = new CapabilityDefinition();
+ RequirementDefinition requirement = new RequirementDefinition();
+ RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
+ ComponentInstance toInstance = new ComponentInstance();
+ Map<String, Component> componentCache = new HashMap<>();
+ boolean result;
+ capability.setPath(new ArrayList<>());
+ reqAndRelationshipPair.setCapability("cap");
+ requirement.setPath(new ArrayList<>());
+ reqAndRelationshipPair.setRequirement("req");
+
+ Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(any(), any(), any(), any(), any()))
+ .thenReturn(Either.left("buildCapNameRes"));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "buildAndAddRequirement", toscaRequirements, fromOriginComponent,
+ toOriginComponent, capability, requirement, reqAndRelationshipPair, toInstance, componentCache);
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testIsRequirementBelongToRelation() throws Exception {
+
+ Component originComponent = new Resource();
+ RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
+ RequirementDefinition requirement = new RequirementDefinition();
+ String fromInstanceId = "";
+ boolean result;
+
+ requirement.setName("name");
+ reqAndRelationshipPair.setRequirement("name1");
+
+ // test return false
+ result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
+ reqAndRelationshipPair, requirement, fromInstanceId);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testIsRequirementBelongToRelationWithNonAtomicComponent() {
+
+ Component originComponent = new Service();
+ RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
+ RequirementDefinition requirement = new RequirementDefinition();
+ String fromInstanceId = "";
+ boolean result;
+
+ // default test return true
+ result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
+ reqAndRelationshipPair, requirement, fromInstanceId);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testIsRequirementBelongToOwner() throws Exception {
+
+ RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
+ RequirementDefinition requirement = new RequirementDefinition();
+ String fromInstanceId = "";
+ Component originComponent = new Resource();
+ boolean result;
+
+ requirement.setOwnerId("owner1");
+ reqAndRelationshipPair.setRequirementOwnerId("owner");
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "isRequirementBelongToOwner", reqAndRelationshipPair, requirement,
+ fromInstanceId, originComponent);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testIsCvfc() throws Exception {
+
+ Component component = new Resource();
+ boolean result;
+
+ component = new Service();
+
+ result = Deencapsulation.invoke(testSubject, "isCvfc", component);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertCapabilities() throws Exception {
+ Component component = new Resource();
+ SubstitutionMapping substitutionMappings = new SubstitutionMapping();
+ Map<String, Component> componentCache = new HashMap<>();
+ Either<SubstitutionMapping, ToscaError> result;
+
+ Mockito.when(capabiltyRequirementConvertor.convertSubstitutionMappingCapabilities(componentCache, component))
+ .thenReturn(Either.right(ToscaError.NODE_TYPE_CAPABILITY_ERROR));
+
+ // default test return isRight
+ result = Deencapsulation.invoke(testSubject, "convertCapabilities", component, substitutionMappings,
+ componentCache);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertCapabilities_1() throws Exception {
+ Component component = new Resource();
+ ToscaNodeType nodeType = new ToscaNodeType();
+ Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+ Either<ToscaNodeType, ToscaError> result;
+
+ Map<String, ToscaCapability> capabilities = new HashMap<>();
+ capabilities.put("key", new ToscaCapability());
+
+ // default test
+ result = Deencapsulation
+ .invoke(testSubject, "convertCapabilities", new HashMap<>(), component, nodeType, dataTypes);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertToNodeTemplateArtifacts() throws Exception {
+ Map<String, ToscaArtifactDataDefinition> container = new HashMap<>();
+ ToscaArtifactDataDefinition art = new ToscaArtifactDataDefinition();
+ art.setFile("test_file");
+ art.setType("test_type");
+ Map<String, ToscaTemplateArtifact> result;
+ container.put("test_art", art);
+ result = Deencapsulation.invoke(testSubject, "convertToNodeTemplateArtifacts", container);
+ Assert.assertNotNull(result);
+ Assert.assertTrue(MapUtils.isNotEmpty(result));
+ Assert.assertTrue(result.get("test_art").getFile().equals("test_file"));
+ Assert.assertTrue(result.get("test_art").getType().equals("test_type"));
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnum.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnum.java
index 2fabef955d..365e65f8a1 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnum.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnum.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,13 +24,17 @@ public enum LifeCycleTransitionEnum {
CHECKOUT("checkout"),
CHECKIN("checkin"),
+ CERTIFICATION_REQUEST("certificationRequest"),
UNDO_CHECKOUT("undoCheckout"),
+ CANCEL_CERTIFICATION("cancelCertification"),
+ START_CERTIFICATION("startCertification"),
+ FAIL_CERTIFICATION("failCertification"),
CERTIFY("certify"),
DISTRIBUTE("distribute");
String displayName;
- LifeCycleTransitionEnum(String displayName) {
+ LifeCycleTransitionEnum(final String displayName) {
this.displayName = displayName;
}
@@ -38,28 +42,41 @@ public enum LifeCycleTransitionEnum {
return displayName;
}
- public static LifeCycleTransitionEnum getFromDisplayName(String name) {
- if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CHECKOUT.getDisplayName())) {
- return LifeCycleTransitionEnum.CHECKOUT;
+ public static LifeCycleTransitionEnum getFromDisplayName(final String name) {
+ if (name.equalsIgnoreCase(CHECKOUT.getDisplayName())) {
+ return CHECKOUT;
}
- if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CHECKIN.getDisplayName())) {
- return LifeCycleTransitionEnum.CHECKIN;
+ if (name.equalsIgnoreCase(CHECKIN.getDisplayName())) {
+ return CHECKIN;
}
- if (name.equalsIgnoreCase(LifeCycleTransitionEnum.UNDO_CHECKOUT.getDisplayName())) {
- return LifeCycleTransitionEnum.UNDO_CHECKOUT;
+ if (name.equalsIgnoreCase(CERTIFICATION_REQUEST.getDisplayName())) {
+ return CERTIFICATION_REQUEST;
}
- if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CERTIFY.getDisplayName())) {
- return LifeCycleTransitionEnum.CERTIFY;
+ if (name.equalsIgnoreCase(UNDO_CHECKOUT.getDisplayName())) {
+ return UNDO_CHECKOUT;
}
- if (name.equalsIgnoreCase(LifeCycleTransitionEnum.DISTRIBUTE.getDisplayName())) {
- return LifeCycleTransitionEnum.DISTRIBUTE;
- } else
+ if (name.equalsIgnoreCase(CANCEL_CERTIFICATION.getDisplayName())) {
+ return CANCEL_CERTIFICATION;
+ }
+ if (name.equalsIgnoreCase(START_CERTIFICATION.getDisplayName())) {
+ return START_CERTIFICATION;
+ }
+ if (name.equalsIgnoreCase(FAIL_CERTIFICATION.getDisplayName())) {
+ return FAIL_CERTIFICATION;
+ }
+ if (name.equalsIgnoreCase(CERTIFY.getDisplayName())) {
+ return CERTIFY;
+ }
+ if (name.equalsIgnoreCase(DISTRIBUTE.getDisplayName())) {
+ return DISTRIBUTE;
+ } else {
throw new IllegalArgumentException(name + " value does not match any of LifeCycleTransitionEnum values");
+ }
}
public static String valuesAsString() {
- StringBuilder sb = new StringBuilder();
- for (LifeCycleTransitionEnum op : LifeCycleTransitionEnum.values()) {
+ final StringBuilder sb = new StringBuilder();
+ for (final LifeCycleTransitionEnum op : LifeCycleTransitionEnum.values()) {
sb.append(op.getDisplayName()).append(" ");
}
return sb.toString();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java
index 9ae89148c1..af803eee5d 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,53 +20,49 @@
package org.openecomp.sdc.be.model;
+import org.junit.Assert;
import org.junit.Test;
public class LifeCycleTransitionEnumTest {
- private LifeCycleTransitionEnum createTestSubject() {
- return LifeCycleTransitionEnum.CERTIFY;
- }
+ private LifeCycleTransitionEnum createTestSubject() {
+ return LifeCycleTransitionEnum.CERTIFY;
+ }
- @Test
- public void testGetDisplayName() throws Exception {
- LifeCycleTransitionEnum testSubject;
- String result;
+ @Test
+ public void testGetDisplayName() {
+ LifeCycleTransitionEnum testSubject;
+ String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDisplayName();
- }
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDisplayName();
+ Assert.assertNotNull(result);
+ }
- @Test
- public void testGetFromDisplayName() throws Exception {
- String name = LifeCycleTransitionEnum.CHECKIN.getDisplayName();
- LifeCycleTransitionEnum result;
+ @Test
+ public void testGetFromDisplayName() {
+ LifeCycleTransitionEnum result;
- // default test
- for (LifeCycleTransitionEnum iterable_element : LifeCycleTransitionEnum.values()) {
- result = LifeCycleTransitionEnum.getFromDisplayName(iterable_element.getDisplayName());
- }
- }
+ // default test
+ for (LifeCycleTransitionEnum iterable_element : LifeCycleTransitionEnum.values()) {
+ result = LifeCycleTransitionEnum.getFromDisplayName(iterable_element.getDisplayName());
+ Assert.assertNotNull(result);
+ }
+ }
- @Test
- public void testGetFromDisplayNameException() throws Exception {
- String name = LifeCycleTransitionEnum.CHECKIN.getDisplayName();
- LifeCycleTransitionEnum result;
+ @Test(expected = IllegalArgumentException.class)
+ public void testGetFromDisplayNameException() {
+ // default test
+ LifeCycleTransitionEnum.getFromDisplayName("mock");
+ }
- // default test
- try {
- result = LifeCycleTransitionEnum.getFromDisplayName("mock");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- }
- }
+ @Test
+ public void testValuesAsString() {
+ String result;
- @Test
- public void testValuesAsString() throws Exception {
- String result;
-
- // default test
- result = LifeCycleTransitionEnum.valuesAsString();
- }
+ // default test
+ result = LifeCycleTransitionEnum.valuesAsString();
+ Assert.assertNotNull(result);
+ }
}
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
deleted file mode 100644
index 81a165afc9..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java
+++ /dev/null
@@ -1,749 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.artifacts;
-
-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;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-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 org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-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.*;
-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.enums.ErrorInfo;
-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.http.HttpHeaderEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.execute.interfaceoperation.InterfaceOperationsTest;
-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.*;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.openecomp.sdc.common.util.GeneralUtility;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class ArtifactServletTest extends ComponentBaseTest {
-
- private static final String ARTIFACT_NAME_STR = "artifactName";
- private static final String ARTIFACT_TYPE_STR = "artifactType";
- private static final String ARTIFACT_DESCRIPTION_STR = "description";
- private static final String ARTIFACT_PAYLOAD_DATA_STR = "payloadData";
- private static Logger log = LoggerFactory.getLogger(ArtifactServletTest.class.getName());
- protected static final String UPLOAD_ARTIFACT_PAYLOAD = "UHVUVFktVXNlci1LZXktRmlsZS0yOiBzc2gtcnNhDQpFbmNyeXB0aW9uOiBhZXMyNTYtY2JjDQpDb21tZW5wOA0K";
- protected static final String UPLOAD_ARTIFACT_NAME = "TLV_prv.ppk";
- protected Config config = Config.instance();
- protected String contentTypeHeaderData = "application/json";
- protected String acceptHeaderDate = "application/json";
- protected Gson gson = new Gson();
- protected JSONParser jsonParser = new JSONParser();
- protected String serviceVersion;
- protected Resource resourceDetailsVFCcomp;
- protected Service defaultService1;
- protected Resource resource;
- protected Resource pnfResource;
-
- protected User sdncUserDetails;
-
- @Rule
- public static TestName name = new TestName();
-
- public ArtifactServletTest() {
- super(name, ArtifactServletTest.class.getName());
-
- }
-
- @BeforeMethod
- public void create() throws Exception {
-
- sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- Either<Resource, RestResponse> resourceDetailsVFCcompE = AtomicOperationUtils
- .createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.COMPUTE,
- ResourceCategoryEnum.APPLICATION_L4_APP_SERVER, UserRoleEnum.DESIGNER, true);
- resourceDetailsVFCcomp = resourceDetailsVFCcompE.left().value();
- Either<Service, RestResponse> defaultService1e = AtomicOperationUtils
- .createDefaultService(UserRoleEnum.DESIGNER, true);
- defaultService1 = defaultService1e.left().value();
-
- Either<Resource, RestResponse> createDefaultResourceEither =
- AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true);
- resource = createDefaultResourceEither.left().value();
-
- Either<Resource, RestResponse> createDefaultPNFResourceEither =
- AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true);
- pnfResource = createDefaultPNFResourceEither.left().value();
- }
-
- @Test
- public void upadteArtifactWithPayLoadToResourcseTest() throws Exception {
-
- ArtifactReqDetails defaultArtifact = ElementFactory.getDefaultArtifact();
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- int status = response.getErrorCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + response.getErrorCode(), 200,
- status);
-
- defaultArtifact.setDescription("kjglkh");
- defaultArtifact.setArtifactName("install_apache.sh");
- defaultArtifact.setArtifactType("SHELL");
- defaultArtifact.setPayload("new payload");
-
- response = ArtifactRestUtils.updateInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- status = response.getErrorCode();
- AssertJUnit.assertEquals("failed to update artifact metatdata: " + response.getErrorCode(), 200, status);
-
- response = ArtifactRestUtils.deleteInformationalArtifactFromResource(resourceDetailsVFCcomp.getUniqueId(),
- defaultArtifact, sdncUserDetails);
- status = response.getErrorCode();
- AssertJUnit.assertEquals("failed to remove artifact: " + response.getErrorCode(), 200, status);
-
- }
-
- @Test
- public void createAndUpdateArtifactToInterface() throws Exception {
-
- CloseableHttpResponse response;
- int status;
- CloseableHttpClient httpclient = HttpClients.createDefault();
-
- try {
- // upload artifact to interface
- String interfaceName = "Standard";
- String operationName = "configure";
-
- String userBodyJson = createUploadArtifactBodyJson();
- String url = String.format(Urls.UPLOAD_ARTIFACT_BY_INTERFACE_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId(), interfaceName, operationName);
-
- HttpPost httpPost = createPostAddArtifactRequeast(userBodyJson, url, true);
- response = httpclient.execute(httpPost);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 200, returned :" + status, status, 200);
-
- // get artifact uniqueId
- String artifactId = getLifecycleArtifactUid(response);
-
- Map<String, Object> jsonBody = new HashMap<String, Object>();
- jsonBody.put(ARTIFACT_NAME_STR, "TLV_prv.ppk");
- jsonBody.put("artifactDisplayName", "configure");
- jsonBody.put(ARTIFACT_TYPE_STR, "SHELL");
- jsonBody.put("mandatory", "false");
- String newDescription = "new something";
- jsonBody.put(ARTIFACT_DESCRIPTION_STR, newDescription);
- jsonBody.put("artifactLabel", "configure");
- userBodyJson = gson.toJson(jsonBody);
-
- url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId(), interfaceName, operationName,
- artifactId);
-
- httpPost = createPostAddArtifactRequeast(userBodyJson, url, false);
-
- response = httpclient.execute(httpPost);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 200, returned :" + status, 200, status);
-
- url = String.format(Urls.GET_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceDetailsVFCcomp.getUniqueId());
- HttpGet httpGet = createGetRequest(url);
- response = httpclient.execute(httpGet);
- AssertJUnit.assertTrue(response.getStatusLine().getStatusCode() == 200);
- String responseString = new BasicResponseHandler().handleResponse(response);
-
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- responseMap = (JSONObject) responseMap.get("interfaces");
- responseMap = (JSONObject) responseMap.get(interfaceName.toLowerCase());
- responseMap = (JSONObject) responseMap.get("operations");
- responseMap = (JSONObject) responseMap.get(operationName.toLowerCase());
- responseMap = (JSONObject) responseMap.get("implementation");
- String description = (String) responseMap.get(ARTIFACT_DESCRIPTION_STR);
-
- AssertJUnit.assertEquals("the new description value was not set", newDescription, description);
-
- // delete artifact
- url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId(), interfaceName, operationName,
- artifactId);
- HttpDelete httpDelete = createDeleteArtifactRequest(url);
-
- response = httpclient.execute(httpDelete);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 200, returned :" + status, status, 200);
- } finally {
- httpclient.close();
- }
-
- }
-
- protected String createUploadArtifactBodyJson() {
- Map<String, Object> jsonBody = new HashMap<String, Object>();
- jsonBody.put(ARTIFACT_NAME_STR, UPLOAD_ARTIFACT_NAME);
- jsonBody.put("artifactDisplayName", "configure");
- jsonBody.put(ARTIFACT_TYPE_STR, "SHELL");
- jsonBody.put("mandatory", "false");
- jsonBody.put(ARTIFACT_DESCRIPTION_STR, "ff");
- jsonBody.put(ARTIFACT_PAYLOAD_DATA_STR, UPLOAD_ARTIFACT_PAYLOAD);
- jsonBody.put("artifactLabel", "configure");
- return gson.toJson(jsonBody);
- }
-
- protected ArtifactDefinition getArtifactDataFromJson(String json) {
- Gson gson = new Gson();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact = gson.fromJson(json, ArtifactDefinition.class);
-
- /*
- * atifact.setArtifactName(UPLOAD_ARTIFACT_NAME);
- * artifact.setArtifactDisplayName("configure");
- * artifact.setArtifactType("SHELL"); artifact.setMandatory(false);
- * artifact.setDescription("ff");
- * artifact.setPayloadData(UPLOAD_ARTIFACT_PAYLOAD);
- * artifact.setArtifactLabel("configure");
- */
- return artifact;
- }
-
- protected HttpGet createGetRequest(String url) {
- HttpGet httpGet = new HttpGet(url);
- httpGet.addHeader(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- httpGet.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- httpGet.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId());
- return httpGet;
- }
-
- protected String getArtifactUid(HttpResponse response) throws HttpResponseException, IOException, ParseException {
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- String artifactId = (String) responseMap.get("uniqueId");
- return artifactId;
- }
-
- protected String getArtifactEsId(HttpResponse response) throws HttpResponseException, IOException, ParseException {
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- String esId = (String) responseMap.get("EsId");
- return esId;
- }
-
- protected ArtifactDefinition addArtifactDataFromResponse(HttpResponse response, ArtifactDefinition artifact)
- throws HttpResponseException, IOException, ParseException {
- // String responseString = new
- // BasicResponseHandler().handleResponse(response);
- HttpEntity entity = response.getEntity();
- String responseString = EntityUtils.toString(entity);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- artifact.setEsId((String) responseMap.get("esId"));
- artifact.setUniqueId((String) responseMap.get("uniqueId"));
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.findType((String) responseMap.get("artifactGroupType")));
- artifact.setTimeout(((Long) responseMap.get("timeout")).intValue());
- return artifact;
- }
-
- protected String getLifecycleArtifactUid(CloseableHttpResponse response)
- throws HttpResponseException, IOException, ParseException {
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseMap = (JSONObject) jsonParser.parse(responseString);
- responseMap = (JSONObject) responseMap.get("implementation");
- String artifactId = (String) responseMap.get("uniqueId");
- return artifactId;
- }
-
- protected HttpDelete createDeleteArtifactRequest(String url) {
- HttpDelete httpDelete = new HttpDelete(url);
- httpDelete.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId());
- httpDelete.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- return httpDelete;
- }
-
- protected HttpPost createPostAddArtifactRequeast(String jsonBody, String url, boolean addMd5Header)
- throws UnsupportedEncodingException {
- HttpPost httppost = new HttpPost(url);
- httppost.addHeader(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- httppost.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- httppost.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId());
- if (addMd5Header) {
- httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5Base64EncodedByString(jsonBody));
- }
- StringEntity input = new StringEntity(jsonBody);
- input.setContentType("application/json");
- httppost.setEntity(input);
- log.debug("Executing request {}", httppost.getRequestLine());
- return httppost;
- }
-
- protected String createLoadArtifactBody() {
- Map<String, Object> json = new HashMap<String, Object>();
- json.put(ARTIFACT_NAME_STR, "install_apache2.sh");
- json.put(ARTIFACT_TYPE_STR, "SHELL");
- json.put(ARTIFACT_DESCRIPTION_STR, "ddd");
- json.put(ARTIFACT_PAYLOAD_DATA_STR, "UEsDBAoAAAAIAAeLb0bDQz");
- json.put("artifactLabel", "name123");
-
- String jsonStr = gson.toJson(json);
- return jsonStr;
- }
-
- protected void checkDeleteResponse(RestResponse response) {
- BaseRestUtils.checkStatusCode(response, "delete request failed", false, 204, 404);
- }
-
- protected ArtifactUiDownloadData getArtifactUiDownloadData(String artifactUiDownloadDataStr) throws Exception {
-
- ObjectMapper mapper = new ObjectMapper();
- try {
- ArtifactUiDownloadData artifactUiDownloadData = mapper.readValue(artifactUiDownloadDataStr,
- ArtifactUiDownloadData.class);
- return artifactUiDownloadData;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- // TODO
- // @Ignore("")
- @Test
- public void addArtifactNoPayLoadToResourcseTest() throws Exception {
- ArtifactReqDetails defaultArtifact = ElementFactory.getDefaultArtifact();
- defaultArtifact.setPayload(null);
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- int status = response.getErrorCode();
- AssertJUnit.assertTrue(status == 400);
-
- }
-
- @Test
- public void upadteArtifactNoPayLoadToResourcseTest() throws Exception {
-
- ArtifactReqDetails defaultArtifact = ElementFactory.getDefaultArtifact();
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- int status = response.getErrorCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + response.getErrorCode(), 200,
- status);
-
- defaultArtifact.setDescription("kjglkh");
- defaultArtifact.setArtifactName("install_apache.sh");
- defaultArtifact.setArtifactType("SHELL");
- defaultArtifact.setPayload(null);
-
- response = ArtifactRestUtils.updateInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- status = response.getErrorCode();
- AssertJUnit.assertEquals("failed to update artifact metatdata: " + response.getErrorCode(), 200, status);
-
- response = ArtifactRestUtils.deleteInformationalArtifactFromResource(resourceDetailsVFCcomp.getUniqueId(),
- defaultArtifact, sdncUserDetails);
- status = response.getErrorCode();
- AssertJUnit.assertEquals("failed to remove artifact: " + response.getErrorCode(), 200, status);
-
- }
-
- // TODO
- @Test(enabled = false)
- public void updateDeploymentArtifactToResourcseTest() throws Exception {
-
- ArtifactReqDetails defaultArtifact = ElementFactory.getDefaultDeploymentArtifactForType("HEAT");
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- int status = response.getErrorCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + response.getErrorCode(), 200,
- status);
-
- response = ArtifactRestUtils.updateInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- status = response.getErrorCode();
- AssertJUnit.assertEquals("failed to update artifact metatdata: " + response.getErrorCode(), 200, status);
-
- response = ArtifactRestUtils.deleteInformationalArtifactFromResource(resourceDetailsVFCcomp.getUniqueId(),
- defaultArtifact, sdncUserDetails);
- status = response.getErrorCode();
- AssertJUnit.assertEquals("failed to remove artifact: " + response.getErrorCode(), 200, status);
-
- }
-
- // --------------------
- @Test
- public void addArtifactToResourcse_AlreadyExistsTest() throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- String jsonBody = createLoadArtifactBody();
-
- String url = String.format(Urls.ADD_ARTIFACT_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId());
- HttpPost httppost = createPostAddArtifactRequeast(jsonBody, url, true);
- CloseableHttpResponse response = httpclient.execute(httppost);
- int status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertTrue("failed to add artifact", status == 200);
-
- String artifactId = getArtifactUid(response);
-
- httppost = createPostAddArtifactRequeast(jsonBody, url, true);
- response = httpclient.execute(httppost);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("the returned status code is in correct", status, 400);
-
- url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_OF_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId(), artifactId);
- HttpDelete httpDelete = createDeleteArtifactRequest(url);
- response = httpclient.execute(httpDelete);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertTrue("failed to remove artifact", status == 200);
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void addArtifactToResourcse_MissingContentTest() throws Exception {
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- Map<String, Object> json = new HashMap<String, Object>();
- json.put(ARTIFACT_DESCRIPTION_STR, "desc");
- json.put(ARTIFACT_PAYLOAD_DATA_STR, "UEsDBAoAAAAIAAeLb0bDQz");
- json.put("Content-MD5", "YTg2Mjg4MWJhNmI5NzBiNzdDFkMWI=");
-
- String jsonBody = gson.toJson(json);
-
- String url = String.format(Urls.ADD_ARTIFACT_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId());
- HttpPost httppost = createPostAddArtifactRequeast(jsonBody, url, true);
- CloseableHttpResponse response = httpclient.execute(httppost);
- int status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("the returned status code is in correct", status, 400);
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void addArtifactToResourcse_MissingMd5Test() throws Exception {
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- HashMap<String, Object> json = new HashMap<String, Object>();
- json.put(ARTIFACT_NAME_STR, "install_apache.sh");
- json.put(ARTIFACT_TYPE_STR, "SHELL");
- json.put(ARTIFACT_DESCRIPTION_STR, "kjglkh");
- json.put(ARTIFACT_PAYLOAD_DATA_STR, "UEsDBYTEIWUYIFHWFMABCNAoAAAAIAAeLb0bDQz");
- json.put("artifactLabel", "name123");
- String url = String.format(Urls.ADD_ARTIFACT_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId());
- String jsonBody = gson.toJson(json);
- HttpPost httppost = createPostAddArtifactRequeast(jsonBody, url, false);
- CloseableHttpResponse response = httpclient.execute(httppost);
- int status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertTrue("failed to update artifact metatdata", status == 400);
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void deleteArtifact_NotExistsTest() throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- String url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_OF_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId(), "someFakeId");
- HttpDelete httpDelete = createDeleteArtifactRequest(url);
- CloseableHttpResponse response = httpclient.execute(httpDelete);
- int status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("the returned status code is in correct", status, 404);
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void createAndRemoveArtifactToInterface() throws Exception {
- CloseableHttpResponse response;
- int status;
- CloseableHttpClient httpclient = HttpClients.createDefault();
-
- try {
- // upload artifact to interface
- String interfaceName = "Standard";
- String operationName = "configure";
-
- String userBodyJson = createUploadArtifactBodyJson();
- String url = String.format(Urls.UPLOAD_ARTIFACT_BY_INTERFACE_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId(), interfaceName, operationName);
-
- HttpPost httpPost = createPostAddArtifactRequeast(userBodyJson, url, true);
- response = httpclient.execute(httpPost);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 200, returned :" + status, status, 200);
-
- // get artifact uniqueId
- String artifactId = getLifecycleArtifactUid(response);
-
- // delete artifact
- url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_RESOURCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), resourceDetailsVFCcomp.getUniqueId(), interfaceName, operationName,
- artifactId);
- HttpDelete httpDelete = createDeleteArtifactRequest(url);
-
- response = httpclient.execute(httpDelete);
- status = response.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 200, returned :" + status, status, 200);
- } finally {
- httpclient.close();
- }
-
- }
-
- @Test
- public void addArtifactToServiceTest() throws Exception {
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
-
- try {
- String jsonStr = createLoadArtifactBody();
-
- String url = String.format(Urls.ADD_ARTIFACT_TO_SERVICE, config.getCatalogBeHost(),
- config.getCatalogBePort(), defaultService1.getUniqueId());
- HttpPost httpPost = createPostAddArtifactRequeast(jsonStr, url, true);
- CloseableHttpResponse result = httpclient.execute(httpPost);
- int status = result.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 200, returned :" + status, 200, status);
-
- String artifactId = getArtifactUid(result);
-
- url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE, config.getCatalogBeHost(),
- config.getCatalogBePort(), defaultService1.getUniqueId(), artifactId);
- HttpDelete httpDelete = createDeleteArtifactRequest(url);
-
- result = httpclient.execute(httpDelete);
- status = result.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 200, returned :" + status, 200, status);
- } finally {
- RestResponse response = ServiceRestUtils.deleteService(defaultService1.getName(), serviceVersion,
- sdncUserDetails);
- checkDeleteResponse(response);
- httpclient.close();
- }
- }
-
- @Test
- public void addArtifactNotSupportedTypeToServiceTest() throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- Map<String, Object> json = new HashMap<String, Object>();
- json.put(ARTIFACT_NAME_STR, "install_apache.sh");
- json.put(ARTIFACT_TYPE_STR, "SHELL11");
- json.put(ARTIFACT_DESCRIPTION_STR, "fff");
- json.put(ARTIFACT_PAYLOAD_DATA_STR, "UEsDBAoAAAAIAAeLb0bDQz");
- json.put("artifactLabel", "name123");
-
- String jsonStr = gson.toJson(json);
-
- String url = String.format(Urls.ADD_ARTIFACT_TO_SERVICE, config.getCatalogBeHost(),
- config.getCatalogBePort(), defaultService1.getUniqueId());
-
- HttpPost httpPost = createPostAddArtifactRequeast(jsonStr, url, true);
- CloseableHttpResponse result = httpclient.execute(httpPost);
- int status = result.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("response code is not 400, returned :" + status, 400, status);
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
-
- String responseString = EntityUtils.toString(result.getEntity());
-
- JSONObject map = (JSONObject) jsonParser.parse(responseString);
- JSONObject requestError = (JSONObject) map.get("requestError");
- JSONObject serviceException = (JSONObject) requestError.get("serviceException");
-
- String msgId = (String) serviceException.get("messageId");
- AssertJUnit.assertEquals("message id did not match expacted", errorInfo.getMessageId(), msgId);
-
- String text = (String) serviceException.get("text");
- AssertJUnit.assertEquals("text did not match expacted", errorInfo.getMessage(), text);
-
- JSONArray variables = (JSONArray) serviceException.get("variables");
- String type = (String) variables.get(0);
- AssertJUnit.assertEquals("variable did not match expacted", "SHELL11", type);
- } finally {
- RestResponse response = ServiceRestUtils.deleteService(defaultService1.getName(), serviceVersion,
- sdncUserDetails);
- checkDeleteResponse(response);
- httpclient.close();
- }
-
- }
-
- @Test
- public void addArtifactToResourceTest() throws Exception {
-
- ArtifactReqDetails defaultArtifact = ElementFactory.getDefaultArtifact();
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(defaultArtifact, sdncUserDetails,
- resourceDetailsVFCcomp.getUniqueId());
- int status = response.getErrorCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + response.getErrorCode(), 200,
- status);
-
- RestResponse resourceResp = ResourceRestUtils.getResource(resourceDetailsVFCcomp.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
- AssertJUnit.assertNotNull(resource);
-
- Map<String, ArtifactDefinition> artifacts = resource.getArtifacts();
- boolean isExist = false;
- for (Map.Entry<String, ArtifactDefinition> entry : artifacts.entrySet()) {
- if (entry.getKey().equals(defaultArtifact.getArtifactLabel())) {
- isExist = true;
-
- }
- }
- AssertJUnit.assertTrue(isExist);
- }
-
- @Test
- public void addInterfaceOperationArtifactOnResource() throws Exception {
- try (CloseableHttpClient httpclient = HttpClients.createDefault()){
- Map<String, Object> artifactData = new HashMap<>();
- artifactData.put(ARTIFACT_NAME_STR, "TestWF-1_0.bpmn");
- artifactData.put(ARTIFACT_TYPE_STR, "WORKFLOW");
- artifactData.put(ARTIFACT_DESCRIPTION_STR, "Resource Workflow Artifact Description");
- artifactData.put(ARTIFACT_PAYLOAD_DATA_STR, "Test Data of Resource");
-
- String jsonStr = gson.toJson(artifactData);
- RestResponse restResponse = InterfaceOperationsRestUtils.addInterfaceOperations(resource,
- new InterfaceOperationsTest().buildInterfaceDefinitionForResource(resource,
- null, null),
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- String interfaceDefStr = ResponseParser.getListFromJson(restResponse, "interfaces").get(0).toString();
- InterfaceDefinition interfaceDefinition = ResponseParser.convertInterfaceDefinitionResponseToJavaObject(interfaceDefStr);
- String interfaceUUID = interfaceDefinition.getUniqueId();
- String operationUUID = interfaceDefinition.getOperationsMap().keySet().stream().findFirst().orElse(null);
- String artifactUUID = interfaceDefinition.getOperationsMap().values().stream().findFirst().get().getImplementation().getArtifactUUID();
-
- String url = String.format(Urls.UPLOAD_INTERFACE_OPERATION_ARTIFACT, config.getCatalogBeHost(),
- config.getCatalogBePort(), ComponentTypeEnum.findParamByType(resource.getComponentType()),
- resource.getUUID(), interfaceUUID, operationUUID, artifactUUID);
- CloseableHttpResponse result = httpclient.execute(createPostAddArtifactRequeast(jsonStr, url, true));
- int status = result.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + status, 200, status);
- }
- }
-
- @Test
- public void addInterfaceOperationArtifactOnPNFResource() throws Exception {
- try (CloseableHttpClient httpclient = HttpClients.createDefault()){
- Map<String, Object> artifactData = new HashMap<>();
- artifactData.put(ARTIFACT_NAME_STR, "TestWF-1_0.bpmn");
- artifactData.put(ARTIFACT_TYPE_STR, "WORKFLOW");
- artifactData.put(ARTIFACT_DESCRIPTION_STR, "PNF Resource Workflow Artifact Description");
- artifactData.put(ARTIFACT_PAYLOAD_DATA_STR, "Test Data of PNF Resource");
-
- String jsonStr = gson.toJson(artifactData);
- RestResponse restResponse = InterfaceOperationsRestUtils.addInterfaceOperations(pnfResource,
- new InterfaceOperationsTest().buildInterfaceDefinitionForResource(pnfResource,
- null, null),
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- String interfaceDefStr = ResponseParser.getListFromJson(restResponse, "interfaces").get(0).toString();
- InterfaceDefinition interfaceDefinition = ResponseParser.convertInterfaceDefinitionResponseToJavaObject(interfaceDefStr);
- String interfaceUUID = interfaceDefinition.getUniqueId();
- String operationUUID = interfaceDefinition.getOperationsMap().keySet().stream().findFirst().orElse(null);
- String artifactUUID = interfaceDefinition.getOperationsMap().values().stream().findFirst().get().getImplementation().getArtifactUUID();
-
- String url = String.format(Urls.UPLOAD_INTERFACE_OPERATION_ARTIFACT, config.getCatalogBeHost(),
- config.getCatalogBePort(), ComponentTypeEnum.findParamByType(pnfResource.getComponentType()),
- pnfResource.getUUID(), interfaceUUID, operationUUID, artifactUUID);
- CloseableHttpResponse result = httpclient.execute(createPostAddArtifactRequeast(jsonStr, url, true));
- int status = result.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + status, 200, status);
- }
- }
-
- @Test
- public void addInterfaceOperationArtifactOnService() throws Exception {
- try (CloseableHttpClient httpclient = HttpClients.createDefault()){
- Map<String, Object> artifactData = new HashMap<>();
- artifactData.put(ARTIFACT_NAME_STR, "TestWF-1_0.bpmn");
- artifactData.put(ARTIFACT_TYPE_STR, "WORKFLOW");
- artifactData.put(ARTIFACT_DESCRIPTION_STR, "Service Workflow Artifact Description");
- artifactData.put(ARTIFACT_PAYLOAD_DATA_STR, "Test Data of Service");
-
- String jsonStr = gson.toJson(artifactData);
- RestResponse restResponse = InterfaceOperationsRestUtils.addInterfaceOperations(defaultService1,
- new InterfaceOperationsTest().buildInterfaceDefinitionForService(),
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- String interfaceDefinitionStr = ResponseParser.getListFromJson(restResponse, "interfaces").get(0).toString();
- InterfaceDefinition interfaceDefinition = ResponseParser.convertInterfaceDefinitionResponseToJavaObject(interfaceDefinitionStr);
- String interfaceUUID = interfaceDefinition.getUniqueId();
- String operationUUID = interfaceDefinition.getOperationsMap().keySet().stream().findFirst().orElse(null);
- String artifactUUID = interfaceDefinition.getOperationsMap().values().stream().findFirst().get().getImplementation().getArtifactUUID();
-
- String url = String.format(Urls.UPLOAD_INTERFACE_OPERATION_ARTIFACT, config.getCatalogBeHost(),
- config.getCatalogBePort(), ComponentTypeEnum.findParamByType(defaultService1.getComponentType()),
- defaultService1.getUUID(), interfaceUUID, operationUUID, artifactUUID);
- CloseableHttpResponse result = httpclient.execute(createPostAddArtifactRequeast(jsonStr, url, true));
- int status = result.getStatusLine().getStatusCode();
- AssertJUnit.assertEquals("add informational artifact request returned status: " + status, 200, status);
- }
- }
-
-}
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
deleted file mode 100644
index 5072f58112..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java
+++ /dev/null
@@ -1,1786 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.artifacts;
-
-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.*;
-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.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.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.general.FileUtils;
-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;
-import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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());
- private static final User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
-
- private static final String HEAT_NET_LABEL = "heatnet";
- private static final String HEAT_LABEL = "heat";
-
- protected String testResourcesPath;
- protected String testResourcesInstancesPath;
-
- protected static final String dcaeInventoryToscaFile = "toscaSampleArtifact.yml";
- protected static final String dcaeInventoryJsonFile = "jsonSampleArtifact.json";
- protected static final String dcaeInventoryPolicyFile = "emfSampleArtifact.emf";
- protected static final String dcaeInventoryDocFile = "docSampleArtifact.doc";
- protected static final String dcaeInventoryBlueprintFile = "bluePrintSampleArtifact.xml";
- protected static final String dcaeInventoryEventFile = "eventSampleArtifact.xml";
-
- protected static final String heatSuccessFile = "asc_heat 0 2.yaml";
- protected static final String heatNetSuccessFile = "asc_heat_net 0 2.yaml";
- protected static final String yangFile = "addYangXmlArtifactToResource.xml";
- protected static final String jsonFile = "jsonArtifact.json";
- protected static final String invalidJsonFile = "invalidJson.json";
- protected static final String invalidYangFile = "invalidYangXml.xml";
- protected static final String otherFile = "other.txt";
- protected static final String muranoFile = "asc_heat 0 2.zip";
- protected static final String heatSuccessMiniFile = "heat_mini.yaml";
- protected static final String heatInvalidFormat = "heatInvalidFormat.yaml";
- protected static final String yamlInvalidFormat = "invalidYamlFormat.yaml";
- protected static final String heatEnvfile = "heatEnvfile.env";
-
- protected ServiceReqDetails serviceDetails;
- protected ResourceReqDetails vfResourceDetails;
- protected ResourceReqDetails cpResourceDetails;
- protected ResourceReqDetails vfcResourceDetails;
- protected ResourceReqDetails vlResourceDetails;
-
- @Rule
- public static TestName name = new TestName();
-
- public CrudArt() {
- super(name, CrudArt.class.getName());
- }
-
- @DataProvider
- private static final Object[][] getDepArtByType() throws IOException, Exception {
- return new Object[][] { { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType()) },
- { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()) },
- { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()) },
- { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()) }, { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()) },
- { ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()) } };
- }
-
- @DataProvider
- private static final Object[][] getServiceDepArtByType() throws IOException, Exception {
- return new Object[][] { { ArtifactTypeEnum.OTHER.getType() }, { ArtifactTypeEnum.YANG_XML.getType() }, };
- }
-
- @BeforeMethod
- public void init() throws Exception {
- // Set files working directory
- String sourceDir = config.getResourceConfigDir();
- String workDir = "HeatDeploymentArtifacts";
- testResourcesPath = sourceDir + File.separator + workDir;
- String workDirResourceInstanceArtifacts = "ResourceInstanceArtifacts";
- testResourcesInstancesPath = sourceDir + File.separator + workDirResourceInstanceArtifacts;
-
- // Build the components
- Service serviceObj = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
- serviceDetails = new ServiceReqDetails(serviceObj);
-
- Resource vfcResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- vfcResourceDetails = new ResourceReqDetails(vfcResourceObj);
-
- Resource vfResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
- vfResourceDetails = new ResourceReqDetails(vfResourceObj);
-
- Resource cpResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.CP, UserRoleEnum.DESIGNER, true).left().value();
- cpResourceDetails = new ResourceReqDetails(cpResourceObj);
-
- Resource vlResourceObj = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VL, UserRoleEnum.DESIGNER, true).left().value();
- vlResourceDetails = new ResourceReqDetails(vlResourceObj);
- }
-
- // ---------------------------------Resource
- // success--------------------------------
- @Test
- public void addHeatArtifactToResourceAndCertify() throws Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // certified resource
- RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
- int status = changeResourceState.getErrorCode();
- assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
-
- Resource resourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(changeResourceState.getResponse());
- Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
- boolean flag = false;
- if (artifactsMap != null) {
- for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
- if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
- assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
- flag = true;
- break;
- }
- }
- assertTrue("expected artifact not found", flag == true);
- }
-
- }
-
- // ---------------------------------Resource
- // success--------------------------------
- @Test
- public void addDcaeInventoryToscaArtifactToResourceInstanceAndCertify() throws Exception {
- String artifactFileName = dcaeInventoryToscaFile;
- String artifactName = dcaeInventoryToscaFile;
- String artifactLabel = "dcae inv tosca label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void addDcaeInventoryJsonArtifactToResourceInstanceAndCertify() throws Exception {
- String artifactFileName = dcaeInventoryJsonFile;
- String artifactName = dcaeInventoryJsonFile;
- String artifactLabel = "dcae inv json label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_JSON;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void addDcaeInventoryPolicyArtifactToResourceInstanceAndCertify() throws Exception {
- String artifactFileName = dcaeInventoryPolicyFile;
- String artifactName = dcaeInventoryPolicyFile;
- String artifactLabel = "dcae inv policy label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_POLICY;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void addDcaeInventoryDocArtifactToResourceInstanceAndCertify() throws Exception {
- String artifactFileName = dcaeInventoryDocFile;
- String artifactName = dcaeInventoryDocFile;
- String artifactLabel = "dcae inv doc label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_DOC;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void addDcaeInventoryBluePrintArtifactToResourceInstanceAndCertify() throws Exception {
- String artifactFileName = dcaeInventoryBlueprintFile;
- String artifactName = dcaeInventoryBlueprintFile;
- String artifactLabel = "dcae inv blueprint label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void addDcaeInventoryEventArtifactToResourceInstanceAndCertify() throws Exception {
- String artifactFileName = dcaeInventoryEventFile;
- String artifactName = dcaeInventoryEventFile;
- String artifactLabel = "dcae inv event label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_EVENT;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- private RestResponse addArtifactToResourceInstanceAndCertify(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
-
- // Get the resource
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
-
- // Certify VF
- Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // Add VF instance to service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
-
- // Get the VF instance
- getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ComponentInstance VfInstance = service.getComponentInstances().get(0);
-
- // Create the artifact
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstance(artifactFileName, artifactName, artifactLabel, artifactType, VfInstance, serviceDetails);
- logger.debug("addInformationalArtifactToResource response: {}",addArtifactToResourceInstanceResponse.getResponseMessage());
- return addArtifactToResourceInstanceResponse;
- }
-
- @Test
- public void updateArtifactDescriptionToResourceInstance() throws Exception {
- String artifactFileName = dcaeInventoryToscaFile;
- String artifactName = dcaeInventoryToscaFile;
- String artifactLabel = "dcae inv tosca label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- logger.debug("addInformationalArtifactToResource response: {}" ,addArtifactToResourceInstanceResponse.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // Get the artifact from VF instance and change his description.
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ComponentInstance vfInstance = service.getComponentInstances().get(0);
- Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
- artifactDefinition.setDescription("My new description");
-
- // Update the artifact
- RestResponse updateDeploymentArtifactToRI = ArtifactRestUtils.updateArtifactToResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",updateDeploymentArtifactToRI.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateDeploymentArtifactToRI.getErrorCode(), updateDeploymentArtifactToRI.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void deleteArtifactToResourceInstance() throws Exception {
- String artifactFileName = dcaeInventoryToscaFile;
- String artifactName = dcaeInventoryToscaFile;
- String artifactLabel = "dcae inv tosca label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.DCAE_INVENTORY_TOSCA;
- RestResponse addArtifactToResourceInstanceResponse = addArtifactToResourceInstanceAndCertify(artifactFileName, artifactName, artifactLabel, artifactType);
- logger.debug("addInformationalArtifactToResource response: {}",addArtifactToResourceInstanceResponse.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addArtifactToResourceInstanceResponse.getErrorCode(), addArtifactToResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // Get the artifact from VF instance and change his description.
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ComponentInstance vfInstance = service.getComponentInstances().get(0);
- Map<String, ArtifactDefinition> deploymentArtifacts = vfInstance.getDeploymentArtifacts();
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get("dcaeinvtoscalabel");
-
- // Delete the artifact
- RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteArtifactFromResourceInstance(artifactDefinition, sdncDesignerDetails1, vfInstance.getUniqueId(), service.getUniqueId());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void addHeatArtifactToResource() throws Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- }
-
- @Test
- public void addHeatAndHeatNetArtifactsToResource() throws Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
-
- // Add HEAT
- logger.debug("listFileName: {}",listFileName.toString());
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // Add HEAT_NET
- String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
- ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
- heatNetArtifactDetails.setPayload(payloadNet);
- heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
-
- RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource1.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource1.getErrorCode(), addInformationalArtifactToResource1.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(vfResourceDetails, sdncDesignerDetails1);
- Resource resourceRespJavaObject = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
-
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get(HEAT_LABEL);
- assertNotNull(artifactDefinition);
- String heatEsId = artifactDefinition.getEsId();
- assertNotNull(heatEsId);
-
- ArtifactDefinition artifactDefinitionNet = deploymentArtifacts.get(HEAT_NET_LABEL);
- assertNotNull(artifactDefinitionNet);
- String heatNetEsId = artifactDefinitionNet.getEsId();
- assertNotNull(heatNetEsId);
- assertFalse(heatEsId.equalsIgnoreCase(heatNetEsId));
- }
-
- @Test
- public void addDeleteAddHeatArtifactToResource() throws Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- RestResponse deleteInformationalArtifactFromResource = ArtifactRestUtils.deleteInformationalArtifactFromResource(vfResourceDetails.getUniqueId(), heatArtifactDetails, sdncDesignerDetails1);
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + deleteInformationalArtifactFromResource.getErrorCode(), deleteInformationalArtifactFromResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- @Test
- public void addYangXmlArtifactToResource() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "asc_heat 0 2.XML";
- String artifactLabel = "Label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addOtherTypeDeploymentArtifactToResource() throws Exception {
-
- String fileName = otherFile;
- String artifactName = "other.txt";
- String artifactLabel = "Label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.OTHER;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addYangXmlArtifactSameName() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "asc_heat_0_2.XML";
- String artifactLabel = "Label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- // Changing label but not name
- artifactLabel = "Label1";
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
- BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, new String[] { "Resource", vfResourceDetails.getName(), artifactName });
-
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addInvalidYangXmlFormat() throws Exception {
-
- String fileName = invalidYangFile;
- String artifactName = "asc_heat_0_2.XML";
- String artifactLabel = "Label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == 400);
- BaseValidationUtils.checkErrorResponse(addInformationalArtifactToResource, ActionStatus.INVALID_XML, new String[] { "YANG_XML" });
-
- }
-
- @Test
- public void addSeveralYangXmlArtifacts() throws Exception {
-
- // Adding 4 artifacts
- String fileName = yangFile;
- String artifactName = "asc_heat_0_2.XML";
- String artifactLabel = "Label";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.YANG_XML;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- // Changing label and name
- artifactLabel = "Label1";
- artifactName = "asc_heat_0_3.XML";
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // Changing label and name
- artifactLabel = "Label2";
- artifactName = "asc_heat_0_4.XML";
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
-
- // Changing label and name
- artifactLabel = "Label3";
- artifactName = "asc_heat_0_5.XML";
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType);
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 4);
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void updateHeatArtifactToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- heatTypeArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // update
- heatTypeArtifactDetails.setArtifactName("UPDATE.yaml");
- heatTypeArtifactDetails.setPayloadData(null);
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",updateInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void updateHeatArtifactTimeOutToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
- int actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
- assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
-
- // update
- heatTypeArtifactDetails.setTimeout(35);
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",updateInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
- actualTimeout = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getTimeout();
- assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact timout, expected " + heatTypeArtifactDetails.getTimeout() + ", but was " + actualTimeout, heatTypeArtifactDetails.getTimeout() == actualTimeout);
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void updateHeatArtifactDescriptionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- Resource resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
- String actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
- assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
-
- // update
- heatTypeArtifactDetails.setDescription("the best description was ever");
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",updateInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToResource.getErrorCode(), updateInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- resource = getResourceByResDetails(vfResourceDetails, sdncDesignerDetails1);
- actualDescription = resource.getDeploymentArtifacts().get(heatTypeArtifactDetails.getArtifactLabel().toLowerCase()).getDescription();
- assertTrue("verify " + heatTypeArtifactDetails.getArtifactLabel().toLowerCase() + " artifact Description, expected " + heatTypeArtifactDetails.getDescription() + ", but was " + actualDescription, heatTypeArtifactDetails.getDescription().equals(actualDescription));
- }
-
- private Resource getResourceByResDetails(ResourceReqDetails resDetails, User userDetails) throws IOException {
- RestResponse response = ResourceRestUtils.getResource(resDetails, userDetails);
- assertTrue("response code on get resource not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + response.getErrorCode(), response.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
- return resource;
- }
-
- // ---------------------------------Service
- // success--------------------------------
- @Test()
- public void addAllTypesDepArtifactToService() throws Exception, Exception {
-
- // String fileName = heatSuccessFile;
- // List<String> listFileName =
- // FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- // logger.debug("listFileName: {}",listFileName.toString());
-
- // String payload = FileUtils.loadPayloadFile(listFileName, fileName,
- // true);
- ArtifactReqDetails otherArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
- // otherArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(otherArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- ArtifactReqDetails yangXmlArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
-
- addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(yangXmlArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- }
-
- @Test(enabled = false)
- public void addMuranoPkgArtifactToService() throws Exception, Exception {
-
- String fileName = muranoFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}" ,listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MURANO_PKG.getType());
- heatArtifactDetails.setPayload(payload);
- heatArtifactDetails.setArtifactName("asc_heat 0 2.zip");
- heatArtifactDetails.setArtifactLabel("Label");
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- }
-
- @Test(dataProvider = "getServiceDepArtByType")
- public void addHeatArtifactToServiceAndCertify(String artType) throws Exception, Exception {
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // certified service
- RestResponse changeServiceState = LifecycleRestUtils.certifyService(serviceDetails);
- int status = changeServiceState.getErrorCode();
- assertEquals("certify service request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
-
- Service resourceJavaObject = ResponseParser.convertServiceResponseToJavaObject(changeServiceState.getResponse());
- Map<String, ArtifactDefinition> artifactsMap = resourceJavaObject.getDeploymentArtifacts();
- boolean flag = false;
- if (artifactsMap != null) {
- for (Entry<String, ArtifactDefinition> art : artifactsMap.entrySet()) {
- if (art.getValue().getArtifactName().equals(heatArtifactDetails.getArtifactName())) {
- assertTrue("expected artifact type is " + ArtifactGroupTypeEnum.DEPLOYMENT.getType() + " but was " + art.getValue().getArtifactGroupType(), art.getValue().getArtifactGroupType().equals(ArtifactGroupTypeEnum.DEPLOYMENT));
- flag = true;
- break;
- }
- }
- assertTrue("expected artifact not found", flag == true);
- }
-
- }
-
- @Test(enabled = false, dataProvider = "getServiceDepArtByType")
- public void updateHeatArtifactToService(String artType) throws Exception, Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToService.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // update
- heatArtifactDetails.setPayloadData(payload);
- RestResponse updateInformationalArtifactToService = ArtifactRestUtils.updateInformationalArtifactOfServiceByMethod(heatArtifactDetails, serviceDetails.getUniqueId(), sdncDesignerDetails1, "POST");
- logger.debug("updateInformationalArtifactToService response: {}",updateInformationalArtifactToService.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + updateInformationalArtifactToService.getErrorCode(), updateInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- }
-
- // --------------------------------------Resource Negative
- // Tests-------------------------------------
-
- // TODO Andrey the method of DEPLOYMENT artifact is update and not add
- @Test(dataProvider = "getServiceDepArtByType")
- public void addTheSameAdditionalHeatArtifactToResource(String artType) throws Exception, Exception {
-
- ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artType);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
-
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // add the same artifact one more time
- artifactDetails.setArtifactLabel("the second artifact");
- addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
-
- List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), artifactDetails.getArtifactName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
-
- }
-
- @Test
- public void addHeatArtifactTwiceSameNameToResource() throws Exception, Exception {
-
- String filename1 = heatSuccessFile;
- // String filename2 = heatSuccessMiniFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
-
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
-
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // Add HEAT_NET
- String payloadNet = FileUtils.loadPayloadFile(listFileName, heatNetSuccessFile, true);
- ArtifactReqDetails heatNetArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
- heatNetArtifactDetails.setPayload(payloadNet);
- heatNetArtifactDetails.setArtifactLabel(HEAT_NET_LABEL);
- heatNetArtifactDetails.setArtifactName(heatArtifactDetails.getArtifactName());
-
- RestResponse addInformationalArtifactToResource1 = ArtifactRestUtils.uploadArtifactToPlaceholderOnResource(heatNetArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId(), HEAT_NET_LABEL);
- logger.debug("addInformationalArtifactToResource response: {}" ,addInformationalArtifactToResource1.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource1.getErrorCode());
-
- List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatNetArtifactDetails.getArtifactName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource1.getResponse());
-
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void addHeatArtifactTwiceToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- String filename1 = heatSuccessFile;
- String filename2 = heatSuccessMiniFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, filename1, true);
- heatTypeArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}" ,addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // add the second artifact
- payload = FileUtils.loadPayloadFile(listFileName, heatSuccessMiniFile, true);
- heatTypeArtifactDetails.setPayload(payload);
- heatTypeArtifactDetails.setArtifactName(filename2);
- heatTypeArtifactDetails.setArtifactLabel("the second artifact");
-
- addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
-
- List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
-
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void addHeatArtifactInvalidHeatFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- String fileName = heatInvalidFormat;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- heatTypeArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
-
- List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToResource.getResponse());
-
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void addHeatArtifactInvalidYamlFormatToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- String fileName = yamlInvalidFormat;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- heatTypeArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
-
- List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToResource.getResponse());
-
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void addHeatArtifactInvalidFileExtensionToResource(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- String fileName = yangFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
-
- heatTypeArtifactDetails.setPayload(payload);
- heatTypeArtifactDetails.setArtifactName(fileName);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
-
- List<String> variables = Arrays.asList(heatTypeArtifactDetails.getArtifactType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToResource.getResponse());
-
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void addHeatArtifactToResourceCertifyAndAddAdditionalHeatArtifact(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
- heatTypeArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.updateInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
-
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // certified resource
- RestResponse changeResourceState = LifecycleRestUtils.certifyResource(vfResourceDetails);
- int status = changeResourceState.getErrorCode();
- assertEquals("certify resource request returned status:" + status, BaseRestUtils.STATUS_CODE_SUCCESS, status);
-
- // add second HEAT artifact to the certified resource
- changeResourceState = LifecycleRestUtils.changeResourceState(vfResourceDetails, sdncDesignerDetails1, LifeCycleStatesEnum.CHECKOUT);
- assertTrue("expected code response on change resource state to CHECKOUT BaseRestUtils.STATUS_CODE_SUCCESS, but was " + changeResourceState.getErrorCode(), changeResourceState.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // ArtifactReqDetails heatArtifactDetails1 =
- // ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatTypeArtifactDetails.setPayload(payload);
- heatTypeArtifactDetails.setArtifactName(fileName);
- heatTypeArtifactDetails.setArtifactLabel("the second artifact");
-
- addInformationalArtifactToResource = ArtifactRestUtils.explicitAddInformationalArtifactToResource(heatTypeArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
-
- List<String> variables = Arrays.asList("Resource", vfResourceDetails.getName(), heatTypeArtifactDetails.getArtifactType(), heatTypeArtifactDetails.getArtifactType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToResource.getResponse());
-
- }
-
- // -----------------Service Negative
- // Tests--------------------------------------------------------
-
- // Absolute
- @Test(enabled = false)
- public void addHeatArtifactTwiceToService() throws Exception, Exception {
-
- String fileName1 = heatSuccessFile;
- String fileName2 = heatSuccessMiniFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName1, true);
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToService.getErrorCode(), addInformationalArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // add the second artifact
- payload = FileUtils.loadPayloadFile(listFileName, fileName2, true);
-
- ArtifactReqDetails heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.OTHER.getType());
- heatArtifactDetails1.setPayload(payload);
- heatArtifactDetails1.setArtifactName(fileName2);
- heatArtifactDetails1.setArtifactLabel("the second artifact");
-
- addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails1, sdncDesignerDetails1, serviceDetails.getUniqueId());
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
-
- List<String> variables = Arrays.asList("Service", serviceDetails.getName(), ArtifactTypeEnum.OTHER.getType(), ArtifactTypeEnum.OTHER.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS.name(), variables, addInformationalArtifactToService.getResponse());
-
- }
-
- // TODO Andrey Obsolete
- @Test(enabled = false)
- public void addHeatArtifactInvalidHeatFormatToService() throws Exception, Exception {
-
- String fileName = heatInvalidFormat;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
-
- List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT.name(), variables, addInformationalArtifactToService.getResponse());
-
- }
-
- // TODO Andrey Obsolete
- @Test(enabled = false)
- public void addHeatArtifactInvalidYamlFormatToService() throws Exception, Exception {
-
- String fileName = yamlInvalidFormat;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_YAML.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
-
- List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML.name(), variables, addInformationalArtifactToService.getResponse());
-
- }
-
- @Test
- public void addHeatArtifactInvalidFileExtensionToService() throws Exception, Exception {
-
- String fileName = muranoFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.YANG_XML.getType());
- heatArtifactDetails.setPayload(payload);
- heatArtifactDetails.setArtifactName(fileName);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- logger.debug("addInformationalArtifactToService response: {}",addInformationalArtifactToService.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
-
- List<String> variables = Arrays.asList(ArtifactTypeEnum.YANG_XML.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION.name(), variables, addInformationalArtifactToService.getResponse());
-
- }
-
- @Test(dataProvider = "getDepArtByType")
- public void addHeatEnvArtifactToResourceNotSupportedType(ArtifactReqDetails heatTypeArtifactDetails) throws Exception, Exception {
-
- String fileName = heatEnvfile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_ENV.getType());
- heatArtifactDetails.setPayload(payload);
- heatArtifactDetails.setArtifactName("asc_heat 0 2.env");
- heatArtifactDetails.setArtifactLabel(heatTypeArtifactDetails.getArtifactLabel());
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToResource.getErrorCode());
-
- List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT_ENV.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToResource.getResponse());
- }
-
- // TODO Andrey
- @Test
- public void addHeatArtifactToServiceNotSupportDeploymentArt() throws Exception, Exception {
-
- String fileName = heatSuccessFile;
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(testResourcesPath);
- logger.debug("listFileName: {}",listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, fileName, true);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(payload);
-
- RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(heatArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), addInformationalArtifactToService.getErrorCode());
-
- List<String> variables = Arrays.asList(ArtifactTypeEnum.HEAT.getType());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addInformationalArtifactToService.getResponse());
-
- }
-
- protected RestResponse addArtifactToResourceInstance(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ComponentInstance componentInstance, ServiceReqDetails serviceDetails) throws Exception {
- ArtifactReqDetails dcaeArtifactDetails = buildArtifactReqDetailsObject(testResourcesInstancesPath, artifactFileName, artifactName, artifactLabel, artifactType);
- RestResponse addArtifactToResourceInstance = ArtifactRestUtils.addArtifactToResourceInstance(dcaeArtifactDetails, sdncDesignerDetails1, componentInstance.getUniqueId(), serviceDetails.getUniqueId());
- return addArtifactToResourceInstance;
- }
-
- protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws Exception {
- ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, vfResourceDetails.getUniqueId());
- return addInformationalArtifactToResource;
- }
-
- protected RestResponse addDeploymentArtifactToResource(String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType, ResourceReqDetails resource) throws Exception {
- ArtifactReqDetails heatArtifactDetails = buildArtifactReqDetailsObject(testResourcesPath, artifactFileName, artifactName, artifactLabel, artifactType);
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, resource.getUniqueId());
- return addInformationalArtifactToResource;
- }
-
- // US672293 - Support new artifact type : BEVF_LICENSE , VENDOR_LICENSE
- @Test
- public void addNewArtifactsToVFResource() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "artifact1.xml";
- String artifactLabel = "Label1";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response:{}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- artifactName = "artifact2.xml";
- artifactLabel = "Label2";
- artifactType = ArtifactTypeEnum.VF_LICENSE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact4.xml";
- artifactLabel = "Label4";
- artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact5.xml";
- artifactLabel = "Label5";
- artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact6.xml";
- artifactLabel = "Label6";
- artifactType = ArtifactTypeEnum.APPC_CONFIG;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}",addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- fileName = jsonFile;
- artifactName = "artifact7.json";
- artifactLabel = "Label7";
- artifactType = ArtifactTypeEnum.APPC_CONFIG;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 2);
-
- //MIB artifacts: SNMP_POLL, SNMP_TRAP
- fileName = jsonFile;
- artifactName = "artifact8.json";
- artifactLabel = "Label8";
- artifactType = ArtifactTypeEnum.SNMP_POLL;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- fileName = jsonFile;
- artifactName = "artifact9.json";
- artifactLabel = "Label9";
- artifactType = ArtifactTypeEnum.SNMP_TRAP;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- //MIB artifacts: SNMP_POLL, SNMP_TRAP
- fileName = jsonFile;
- artifactName = "artifact8.json";
- artifactLabel = "Label8";
- artifactType = ArtifactTypeEnum.SNMP_POLL;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- fileName = jsonFile;
- artifactName = "artifact9.json";
- artifactLabel = "Label9";
- artifactType = ArtifactTypeEnum.SNMP_TRAP;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addNewArtifactsToVFCResource() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "artifact1.xml";
- String artifactLabel = "Label1";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact2.xml";
- artifactLabel = "Label2";
- artifactType = ArtifactTypeEnum.VF_LICENSE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact4.xml";
- artifactLabel = "Label4";
- artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifac5.xml";
- artifactLabel = "Label5";
- artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addNewArtifactsToVfc() throws Exception {
- String fileName = yangFile;
- String artifactName = "artifact2.xml";
- String artifactLabel = "Label2";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
- RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}",addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addNewArtifactsToCp() throws Exception {
- String fileName = yangFile;
- String artifactName = "artifact2.xml";
- String artifactLabel = "Label2";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
- RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addNewArtifactsToVl() throws Exception {
- String fileName = yangFile;
- String artifactName = "artifact2.xml";
- String artifactLabel = "Label2";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
- RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addVfInstanceWithNewArtifactsToService() throws Exception {
- String fileName = yangFile;
- String artifactName = "artifact2.xml";
- String artifactLabel = "Label2";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- // Certify VF
- Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- // Add VF instance to service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
- // get service and verify VF instance contain the Artifacts :VF_LICENSE
- // and VENDOR_LICENSE
- getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ComponentInstance VfInstance = service.getComponentInstances().get(0);
- ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VENDOR_LICENSE, 1);
- ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VF_LICENSE, 1);
- }
-
- @Test
- public void addNotSupportedArtifactsTypeToService01() throws Exception, Exception {
- // Artifact type : VF_LICENSE
- ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VF_LICENSE.getType());
- RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add("VF_LICENSE");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
- }
-
- @Test
- public void addNotSupportedArtifactsTypeToService02() throws Exception, Exception {
- // Artifact type : VENDOR_LICENSE
- ArtifactReqDetails deploymentArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VENDOR_LICENSE.getType());
- RestResponse addDeploymentArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifactDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code eturned :" + addDeploymentArtifactToService.getErrorCode(), addDeploymentArtifactToService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add("VENDOR_LICENSE");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToService.getResponse());
- }
-
- @Test
- public void addInvalidFileForArtifactTypeVendorLicenseToResource() throws Exception {
- String fileName = yangFile;
- String NonXmlFile = heatSuccessFile;
- String artifactName = "artifact2.xml";
- String artifactLabel = "Label2";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VF_LICENSE;
- RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- // Artifact type VENDOR_LICENSE must be XML file
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code 400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add("VENDOR_LICENSE");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
- // get resource and verify that file not exist within
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
- }
-
- @Test
- public void addInvalidFileForArtifactTypeVfLicenseToResource() throws Exception {
- String fileName = yangFile;
- String NonXmlFile = heatSuccessFile;
- String artifactName = "artifact2.xml";
- String artifactLabel = "Label2";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- // Artifact type VF_LICENSE must be XML file
- artifactName = "artifact3.xml";
- artifactLabel = "Label3";
- artifactType = ArtifactTypeEnum.VF_LICENSE;
- addDeploymentArtifactToResource = addDeploymentArtifactToResource(NonXmlFile, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code 400 returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add("VF_LICENSE");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_XML.name(), variables, addDeploymentArtifactToResource.getResponse());
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
- }
-
- @Test
- public void addVendorLicenseArtifactAlreadyExistsInResource() throws Exception {
- String fileName = yangFile;
- String artifactName = "artifact2.xml";
- String artifactLabel = "Label2";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VENDOR_LICENSE;
- RestResponse addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- // Add same file again to resource
- addDeploymentArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addDeploymentArtifactToResource.getResponseMessage());
- assertTrue("response code is not 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add(artifactLabel.toLowerCase());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactToResource.getResponse());
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- // US672294
-
- @Test()
- public void addVnfCatalogArtifactsToService() throws Exception, Exception {
-
- ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.VNF_CATALOG.getType());
- RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- // get service and verify the Artifacts :VNF_CATALOG
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
- }
-
- @Test()
- public void addModelInventoryProfileArtifactsToService() throws Exception, Exception {
-
- ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType());
- RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- // get service and verify the Artifacts :VNF_CATALOG
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
- }
-
- @Test()
- public void addModelQuerySpecArtifactsToService() throws Exception, Exception {
-
- ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
- RestResponse resp = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + resp.getErrorCode(), resp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- // get service and verify the Artifacts :VNF_CATALOG
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
- }
-
- @Test
- public void addVfInstanceWithNewArtifactsToService02() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "artifact1.xml";
- String artifactLabel = "Label1";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- fileName = yangFile;
- artifactName = "artifact2.xml";
- artifactLabel = "Label2";
- artifactType = ArtifactTypeEnum.APPC_CONFIG;
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact4.xml";
- artifactLabel = "Label4";
- artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifac5.xml";
- artifactLabel = "Label5";
- artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- // Certify VF
- Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + changeComponentState.getRight().getErrorCode(), changeComponentState.getRight().getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
-
- // Add VF instance to service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
-
- // get service and verify VF instance contain the Artifacts :VF_LICENSE
- // and VENDOR_LICENSE
- getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ComponentInstance VfInstance = service.getComponentInstances().get(0);
- ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.VNF_CATALOG, 1);
- ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE, 1);
- ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
- ArtifactValidationUtils.validateArtifactsNumberInComponentInstance(VfInstance, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.APPC_CONFIG, 1);
- }
-
- @Test
- public void addAppcConfigArtifactToVfc() throws Exception {
- String fileName = jsonFile;
- String artifactName = "artifact7.json";
- String artifactLabel = "Label7";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add(artifactName);
- variables.add("[VF]");
- variables.add("VFC (Virtual Function Component)");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
- }
-
- @Test
- public void addAppcConfigArtifactToCp() throws Exception {
- String fileName = jsonFile;
- String artifactName = "artifact7.json";
- String artifactLabel = "Label7";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add(artifactName);
- variables.add("[VF]");
- variables.add("CP (Connection Point)");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
- }
-
- @Test
- public void addAppcConfigArtifactToVl() throws Exception {
- String fileName = jsonFile;
- String artifactName = "artifact7.json";
- String artifactLabel = "Label7";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add(artifactName);
- variables.add("[VF]");
- variables.add("VL (Virtual Link)");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE.name(), variables, addInformationalArtifactToResource.getResponse());
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
- }
-
- @Test()
- public void addAppcConfigArtifactsToService() throws Exception, Exception {
- ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.APPC_CONFIG.getType());
- RestResponse addDeploymentArtifactToResource = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code 400, returned :" + addDeploymentArtifactToResource.getErrorCode(), addDeploymentArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name(), variables, addDeploymentArtifactToResource.getResponse());
- }
-
- @Test
- public void addAppcConfigInvalidJsonToVFResourceFailed() throws Exception {
-
- String fileName = invalidJsonFile;
- String artifactName = "invalidJson.json";
- String artifactLabel = "Label7";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.APPC_CONFIG;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is 400, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
-
- ArrayList<String> variables = new ArrayList<>();
- variables.add(ArtifactTypeEnum.APPC_CONFIG.toString());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_JSON.name(), variables, addInformationalArtifactToResource.getResponse());
-
- RestResponse getResource = ResourceRestUtils.getResource(vfResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 0);
-
- }
-
- @Test
- public void addNewArtifactsToCp02() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "artifact1.xml";
- String artifactLabel = "Label1";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact4.xml";
- artifactLabel = "Label4";
- artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifac5.xml";
- artifactLabel = "Label5";
- artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, cpResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(cpResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addNewArtifactsToVl02() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "artifact1.xml";
- String artifactLabel = "Label1";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact4.xml";
- artifactLabel = "Label4";
- artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifac5.xml";
- artifactLabel = "Label5";
- artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vlResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vlResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addNewArtifactsToVfc02() throws Exception {
-
- String fileName = yangFile;
- String artifactName = "artifact1.xml";
- String artifactLabel = "Label1";
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.VNF_CATALOG;
-
- RestResponse addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- RestResponse getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifact4.xml";
- artifactLabel = "Label4";
- artifactType = ArtifactTypeEnum.MODEL_INVENTORY_PROFILE;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
-
- artifactName = "artifac5.xml";
- artifactLabel = "Label5";
- artifactType = ArtifactTypeEnum.MODEL_QUERY_SPEC;
-
- addInformationalArtifactToResource = addDeploymentArtifactToResource(fileName, artifactName, artifactLabel, artifactType, vfcResourceDetails);
- logger.debug("addInformationalArtifactToResource response: {}", addInformationalArtifactToResource.getResponseMessage());
- assertTrue("response code is not BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addInformationalArtifactToResource.getErrorCode(), addInformationalArtifactToResource.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- getResource = ResourceRestUtils.getResource(vfcResourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(resource, ArtifactGroupTypeEnum.DEPLOYMENT, artifactType, 1);
- }
-
- @Test
- public void addNewArtifactAlreadyExistsInService() throws Exception {
- ArtifactReqDetails artDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.MODEL_QUERY_SPEC.getType());
- RestResponse addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code is BaseRestUtils.STATUS_CODE_SUCCESS, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- // get service and verify the Artifacts :VNF_CATALOG
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
- // Add same file again to resource
- addDeploymentArtifactoService = ArtifactRestUtils.addInformationalArtifactToService(artDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
- assertTrue("response code is 400, returned :" + addDeploymentArtifactoService.getErrorCode(), addDeploymentArtifactoService.getErrorCode() == BaseRestUtils.STATUS_CODE_INVALID_CONTENT);
- ArrayList<String> variables = new ArrayList<>();
- variables.add(artDetails.getArtifactLabel().toLowerCase());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.ARTIFACT_EXIST.name(), variables, addDeploymentArtifactoService.getResponse());
- // get service and verify the Artifacts :VNF_CATALOG is still exist and
- // has one occurrences
- getServiceResponse = ServiceRestUtils.getService(serviceDetails, sdncDesignerDetails1);
- service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ArtifactValidationUtils.validateArtifactsNumberInComponent(service, ArtifactGroupTypeEnum.DEPLOYMENT, ArtifactTypeEnum.MODEL_QUERY_SPEC, 1);
- }
-
- private ArtifactReqDetails buildArtifactReqDetailsObject(String filesPath, String artifactFileName, String artifactName, String artifactLabel, ArtifactTypeEnum artifactType) throws IOException, Exception {
- List<String> listFileName = FileUtils.getFileListFromBaseDirectoryByTestName(filesPath);
- logger.debug("listFileName: {}", listFileName.toString());
-
- String payload = FileUtils.loadPayloadFile(listFileName, artifactFileName, true);
-
- ArtifactReqDetails dcaeArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(artifactType.getType());
- dcaeArtifactDetails.setPayload(payload);
- dcaeArtifactDetails.setArtifactName(artifactName);
- dcaeArtifactDetails.setArtifactLabel(artifactLabel);
- return dcaeArtifactDetails;
- }
-
-}
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
deleted file mode 100644
index be9b8b8135..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java
+++ /dev/null
@@ -1,631 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.artifacts;
-
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.HeatParameterDefinition;
-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.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.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.Decoder;
-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.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
-import org.testng.AssertJUnit;
-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
- public static TestName name = new TestName();
- protected String serviceVersion;
-
- public ValidateArtResponse() {
- super(name, ArtifactServletTest.class.getName());
-
- }
-
- protected final String pathToFile = "heatArtifactParameters";
- protected final String heatWithValidParams = "heatWithValidParams.yaml";
- protected final String heatWithParamsMissingDefault = "heatWithParamsMissingDefault.yaml";
- protected final String heatWithParamsMissingDesc = "heatWithParamsMissingDesc.yaml";
- protected final String heatWithParamsMissingType = "heatWithParamsMissingType.yaml";
- protected final String importNoDerivedFromFile = "myComputeDerivedFromNotExists.yml";
- protected final String decodedPayload = "decodedPayload";
- protected final String encodedPayload = "encodedPayload";
-
- protected Resource resourceDetailsObj;
- protected ResourceReqDetails resourceDetails;
- protected User sdncDesignerDetails;
-
- @BeforeMethod
- public void init() throws Exception {
-
- resourceDetailsObj = AtomicOperationUtils
- .createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- resourceDetails = new ResourceReqDetails(resourceDetailsObj);
- sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
-
- }
-
- @Test
- public void compareParamtersVsYaml() throws Exception {
-
- // select file to upload
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithValidParams);
-
- // upload HEAT file and save JSON response
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // create MAP from received JSON
-
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
-
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
-
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
- protected void assertnull(String string, boolean equals) {
-
- }
-
- public Map<String, String> extractSingleParameter(Map<String, String> curr) {
- Map<String, String> innerMap = new HashMap<String, String>();
- if (curr.containsKey("description")) {
- innerMap.put("description", curr.get("description"));
- }
-
- if (curr.containsKey("defaultValue")) {
- innerMap.put("default", curr.get("defaultValue"));
- } else {
- // System.out.println("kuku");
- }
- innerMap.put("type", curr.get("type"));
- return innerMap;
- }
-
- public Map<String, Map> createMapFromYaml(String payload) {
- ArrayList<String> parametersList = new ArrayList<String>();
-
- Yaml yaml = new Yaml();
-
- Map<String, Map> result = (Map<String, Map>) yaml.load(payload);
- Map<String, Map> paramters = (Map<String, Map>) result.get("parameters");
-
- for (Map.Entry<String, Map> entry : paramters.entrySet()) {
- Map<String, String> origInnerMap = (Map<String, String>) entry.getValue();
-
- if (origInnerMap.containsKey("label")) {
- origInnerMap.remove("label");
- paramters.remove(entry);
- paramters.put(entry.getKey(), origInnerMap);
- }
- }
- return paramters;
- }
-
- public Map<String, Map<String, String>> jsonToMap(RestResponse addInformationalArtifactToResource,
- String section2extract, String createKeyMapBy) {
- Map<String, Object> JsonToMap = new HashMap<String, Object>();
- JsonToMap = (Map<String, Object>) ResponseParser.parseToObject(addInformationalArtifactToResource.getResponse(),
- JsonToMap.getClass());
-
- List<Map<String, String>> listOfParamters = (List<Map<String, String>>) JsonToMap.get(section2extract);
- Map<String, Map<String, String>> mapOfActualParameters = new HashMap<String, Map<String, String>>();
-
- for (Map<String, String> curr : listOfParamters) {
- Map<String, String> innerMap = extractSingleParameter(curr);
-
- mapOfActualParameters.put(curr.get(createKeyMapBy), innerMap);
- }
- return mapOfActualParameters;
- }
-
- public Map<String, String> selectFileToUpload(String pathToFile, String fileName) throws IOException {
- String sourceDir = config.getResourceConfigDir();
- String testResourcesPath = sourceDir + File.separator + pathToFile;
- String file = fileName;
- Map<String, String> filePayload = new HashMap<String, String>();
- String payload = Decoder.readFileToString(testResourcesPath + File.separator + file);
- filePayload.put(decodedPayload, payload);
- filePayload.put(encodedPayload, Decoder.encode(payload.getBytes()));
-
- return filePayload;
- }
-
- @Test
- public void missingDescParam() throws Exception {
-
- // select file to upload
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithParamsMissingDesc);
-
- // upload HEAT file and save JSON response
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // create MAP from received JSON
-
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
-
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
-
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
- @Test
- public void missingDefaultParam() throws Exception {
-
- // select file to upload
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithParamsMissingDefault);
-
- // upload HEAT file and save JSON response
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // create MAP from received JSON
-
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
-
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
-
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
- @Test
- public void missingTypeParam() throws Exception {
-
- // select file to upload
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithParamsMissingType);
-
- // upload HEAT file and save JSON response
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // System.out.println(addInformationalArtifactToResource);
- AssertJUnit.assertTrue(
- "response code is not 400, returned :" + addInformationalArtifactToResource.getErrorCode(),
- addInformationalArtifactToResource.getErrorCode() == 400);
-
- }
-
- @Test
- public void updateValueParam() throws Exception {
-
- String updateValueParam = "changed";
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithValidParams);
-
- // upload HEAT file and save JSON response
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
- // System.out.println(resourceGetResponse.getResponse().toString());
- String atifactUniqueId = ResponseParser
- .getValueFromJsonResponse(addInformationalArtifactToResource.getResponse(), "uniqueId");
-
- ArtifactReqDetails artifacJavaObject = ResponseParser
- .convertArtifactReqDetailsToJavaObject(addInformationalArtifactToResource.getResponse());
- List<HeatParameterDefinition> heatParameters2 = artifacJavaObject.getHeatParameters();
-
- for (HeatParameterDefinition heatParameterDefinition : heatParameters2) {
- heatParameterDefinition.setCurrentValue(updateValueParam);
- }
- artifacJavaObject.setHeatParameters(heatParameters2);
- artifacJavaObject.setPayloadData(null);
-
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateDeploymentArtifactToResource(
- artifacJavaObject, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // verify change in update response
-
- ArtifactDefinition ArtifactDefinitionRespJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(updateInformationalArtifactToResource.getResponse());
- List<HeatParameterDataDefinition> heatParameters = ArtifactDefinitionRespJavaObject.getHeatParameters();
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- String verify = updateValueParam;
- AssertJUnit.assertTrue("verification failed", verify.equals(heatParameterDefinition.getCurrentValue()));
- }
-
- // verify change in getResource
-
- resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
-
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
- deploymentArtifacts.get(heatArtifactDetails.getArtifactName());
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- String verify = updateValueParam;
- AssertJUnit.assertTrue("verification failed", verify.equals(heatParameterDefinition.getCurrentValue()));
- }
-
- // create MAP from received JSON
-
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
-
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
-
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
- @Test
- public void updateValueParamMissingDefault() throws Exception {
-
- String updateValueParam = "changed";
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithParamsMissingDefault);
-
- // upload HEAT file and save JSON response
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
- // System.out.println(resourceGetResponse.getResponse().toString());
- String atifactUniqueId = ResponseParser
- .getValueFromJsonResponse(addInformationalArtifactToResource.getResponse(), "uniqueId");
-
- ArtifactReqDetails artifacJavaObject = ResponseParser
- .convertArtifactReqDetailsToJavaObject(addInformationalArtifactToResource.getResponse());
- List<HeatParameterDefinition> heatParameters2 = artifacJavaObject.getHeatParameters();
-
- for (HeatParameterDefinition heatParameterDefinition : heatParameters2) {
- heatParameterDefinition.setCurrentValue(updateValueParam);
- }
- artifacJavaObject.setHeatParameters(heatParameters2);
- artifacJavaObject.setPayloadData(null);
-
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateDeploymentArtifactToResource(
- artifacJavaObject, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // verify change in update response
-
- ArtifactDefinition ArtifactDefinitionRespJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(updateInformationalArtifactToResource.getResponse());
- List<HeatParameterDataDefinition> heatParameters = ArtifactDefinitionRespJavaObject.getHeatParameters();
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- String verify = updateValueParam;
- AssertJUnit.assertTrue("verification failed", verify.equals(heatParameterDefinition.getCurrentValue()));
- }
-
- // verify change in getResource
-
- resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
-
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
- deploymentArtifacts.get(heatArtifactDetails.getArtifactName());
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- String verify = updateValueParam;
- AssertJUnit.assertTrue("verification failed", verify.equals(heatParameterDefinition.getCurrentValue()));
- }
-
- // create MAP from received JSON
-
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
-
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
-
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
- @Test
- public void updateValueParamNull() throws Exception {
-
- String updateValueParam = null;
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithValidParams);
-
- // upload HEAT file and save JSON response
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
- // System.out.println(resourceGetResponse.getResponse().toString());
- String atifactUniqueId = ResponseParser
- .getValueFromJsonResponse(addInformationalArtifactToResource.getResponse(), "uniqueId");
-
- ArtifactReqDetails artifacJavaObject = ResponseParser
- .convertArtifactReqDetailsToJavaObject(addInformationalArtifactToResource.getResponse());
- List<HeatParameterDefinition> heatParameters2 = artifacJavaObject.getHeatParameters();
-
- for (HeatParameterDefinition heatParameterDefinition : heatParameters2) {
- heatParameterDefinition.setCurrentValue(updateValueParam);
- }
- artifacJavaObject.setHeatParameters(heatParameters2);
- artifacJavaObject.setPayloadData(null);
-
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateDeploymentArtifactToResource(
- artifacJavaObject, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // verify change in update response
- ArtifactDefinition ArtifactDefinitionRespJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(updateInformationalArtifactToResource.getResponse());
- List<HeatParameterDataDefinition> heatParameters = ArtifactDefinitionRespJavaObject.getHeatParameters();
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- // String verify = updateValueParam;
- if (heatParameterDefinition.getDefaultValue() != null) {
- AssertJUnit.assertTrue(
- heatParameterDefinition.getDefaultValue().equals(heatParameterDefinition.getCurrentValue()));
- } else {
- AssertJUnit.assertNull("verification failed", heatParameterDefinition.getCurrentValue());
- }
- }
-
- // verify change in getResource
- resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
-
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
- deploymentArtifacts.get(heatArtifactDetails.getArtifactName());
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- // String verify = updateValueParam;
- if (heatParameterDefinition.getDefaultValue() != null) {
- AssertJUnit.assertTrue(
- heatParameterDefinition.getDefaultValue().equals(heatParameterDefinition.getCurrentValue()));
- } else {
- AssertJUnit.assertNull("verification failed", heatParameterDefinition.getCurrentValue());
- }
- }
-
- // create MAP from received JSON
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
- @Test
- public void updateValueParamEmpty() throws Exception {
-
- String updateValueParam = "";
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithValidParams);
-
- // upload HEAT file and save JSON response
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
- // System.out.println(resourceGetResponse.getResponse().toString());
- String atifactUniqueId = ResponseParser
- .getValueFromJsonResponse(addInformationalArtifactToResource.getResponse(), "uniqueId");
-
- ArtifactReqDetails artifacJavaObject = ResponseParser
- .convertArtifactReqDetailsToJavaObject(addInformationalArtifactToResource.getResponse());
- List<HeatParameterDefinition> heatParameters2 = artifacJavaObject.getHeatParameters();
-
- for (HeatParameterDefinition heatParameterDefinition : heatParameters2) {
- heatParameterDefinition.setCurrentValue(updateValueParam);
- }
- artifacJavaObject.setHeatParameters(heatParameters2);
- artifacJavaObject.setPayloadData(null);
-
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateDeploymentArtifactToResource(
- artifacJavaObject, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- // verify change in update response
-
- ArtifactDefinition ArtifactDefinitionRespJavaObject = ResponseParser
- .convertArtifactDefinitionResponseToJavaObject(updateInformationalArtifactToResource.getResponse());
- List<HeatParameterDataDefinition> heatParameters = ArtifactDefinitionRespJavaObject.getHeatParameters();
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- String verify = updateValueParam;
- AssertJUnit.assertTrue("verification failed", verify.equals(heatParameterDefinition.getCurrentValue()));
- }
-
- // verify change in getResource
-
- resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
-
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- Map<String, ArtifactDefinition> deploymentArtifacts = resourceRespJavaObject.getDeploymentArtifacts();
- deploymentArtifacts.get(heatArtifactDetails.getArtifactName());
- for (HeatParameterDataDefinition heatParameterDefinition : heatParameters) {
- String verify = updateValueParam;
- AssertJUnit.assertTrue("verification failed", verify.equals(heatParameterDefinition.getCurrentValue()));
- }
-
- // create MAP from received JSON
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
- @Test
- public void onlyValueParamPermited() throws Exception {
-
- Map<String, String> filePayload = selectFileToUpload(pathToFile, heatWithValidParams);
-
- // upload HEAT file and save JSON response
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatArtifactDetails.setPayload(filePayload.get(encodedPayload));
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
- // System.out.println(resourceGetResponse.getResponse().toString());
- String atifactUniqueId = ResponseParser
- .getValueFromJsonResponse(addInformationalArtifactToResource.getResponse(), "uniqueId");
-
- ArtifactReqDetails artifacJavaObject = ResponseParser
- .convertArtifactReqDetailsToJavaObject(addInformationalArtifactToResource.getResponse());
- List<HeatParameterDefinition> heatParameters2 = artifacJavaObject.getHeatParameters();
-
- for (HeatParameterDefinition heatParameterDefinition : heatParameters2) {
- heatParameterDefinition.setDefaultValue("changed");
- heatParameterDefinition.setName("changed");
- heatParameterDefinition.setDescription("changed");
- heatParameterDefinition.setType("changed");
- heatParameterDefinition.setCurrentValue("changed");
- }
- artifacJavaObject.setHeatParameters(heatParameters2);
- artifacJavaObject.setPayloadData(null);
-
- RestResponse updateInformationalArtifactToResource = ArtifactRestUtils.updateDeploymentArtifactToResource(
- artifacJavaObject, sdncDesignerDetails, resourceDetails.getUniqueId());
-
- resourceGetResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails);
-
- // create MAP from received JSON
-
- String section2extract = "heatParameters";
- String createKeyMapBy = "name";
- Map<String, Map<String, String>> mapOfActualParameters = jsonToMap(addInformationalArtifactToResource,
- section2extract, createKeyMapBy);
-
- // Prepare map to validate JS
-
- Map<String, Map> paramters = createMapFromYaml(filePayload.get(decodedPayload));
-
- // compare MAPs
-
- ResourceValidationUtils.compareElements(mapOfActualParameters, paramters);
-
- }
-
-}
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
deleted file mode 100644
index ed41149f21..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java
+++ /dev/null
@@ -1,2289 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.category;
-
-import org.apache.commons.lang3.text.WordUtils;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.entity.mime.content.FileBody;
-import org.json.JSONArray;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedCategoryAudit;
-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.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.CategoryValidationUtils;
-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";
- protected static final String ADD_CATEGORY = "AddCategory";
- protected static final String DELETE_CATEGORY = "DeleteCategory";
-
- public CategoriesTests() {
- super(name, CategoriesTests.class.getName());
- }
-
- @Rule
- public static TestName name = new TestName();
- private CategoryDefinition categoryDefinition;
- private List<CategoryDefinition> categoryList;
- private List<SubCategoryDefinition> subCategoryList;
- private Map<String, List<String>> subCategoriesToDeleteMap;
-
- @BeforeMethod
- public void init() throws Exception {
- subCategoriesToDeleteMap = new HashMap<String, List<String>>();
- DbUtils.deleteFromEsDbByPattern("_all");
-
- categoryDefinition = new CategoryDefinition();
- categoryDefinition.setName("Abcd");
- categoryList = defineCategories();
- subCategoryList = defineSubCategories(categoryList.size());
- }
-
- // pass
- @Test
- public void createServiceCategorySuccessFlow() throws Exception {
- // Add New category
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("abcd");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- // get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
- // set
- // catalog
- // uniqeId
-
- }
-
- // pass
- @Test
- public void createResourceCategorySuccessFlow() throws Exception {
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("abcd");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get Category
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
- }
-
- // pass
- @Test
- public void createProductCategorySuccessFlow() throws Exception {
- // Add Category by Product-strategist
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
- sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("abcd");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
-
- // Get Category
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
- STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
- }
-
- @Test
- public void CategoryNameValidation_FirstWordStartWithAlphaNumeric_01() throws Exception { // category
- // for
- // service
- categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category14AadE &-+.'#=:@_");
- categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_FirstWordStartWithAlphaNumeric_02() throws Exception { // category
- // for
- // resource
- categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category14AadE &-+.'#=:@_");
- categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_FirstWordStartWithAlphaNumeric_03() throws Exception { // category
- // for
- // resource
- categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
- sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category14AadE &-+.'#=:@_");
- categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
- STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
- }
-
- // pass
- @Test
- public void createServiceCategoryByNonAdminUser() throws Exception {
- // Add New category
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
- sdncProductStrategistUserDetails, SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
- createCategotyRest.getErrorCode().intValue());
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
- ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_SERVICE_TYPE);
- }
-
- // pass
- @Test
- public void createResourceCategoryByNonAdminUser() throws Exception {
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
- sdncProductStrategistUserDetails, RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
- createCategotyRest.getErrorCode().intValue());
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
- ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_RESOURCE_TYPE);
- }
-
- // pass
- @Test
- public void createProductCategoryByNonProductStrategistUser() throws Exception {
- // Add New product category not by Product-Strategist
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
- createCategotyRest.getErrorCode().intValue());
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_PRODUCT_TYPE);
-
- }
-
- // pass
- @Test
- public void addCategoryByNonExistingUser() throws Exception {
- User sdncAdminUserDetailsNonExisting = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncAdminUserDetailsNonExisting.setUserId("bt555h");
- // Add New category
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
- sdncAdminUserDetailsNonExisting, SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
- createCategotyRest.getErrorCode().intValue());
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
- expectedCatrgoryAuditJavaObject.setModifier("(" + sdncAdminUserDetailsNonExisting.getUserId() + ")");
- expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
- expectedCatrgoryAuditJavaObject.setSubCategoryName("");
- expectedCatrgoryAuditJavaObject.setGroupingName("");
- expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
- expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
- expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
- AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_01() throws Exception {
- categoryDefinition.setName("1234AbcdE&");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde&"); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_02() throws Exception {
- categoryDefinition.setName("1234AbcdE-");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde-"); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_03() throws Exception {
- categoryDefinition.setName("1234AbcdE+");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde+"); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_04() throws Exception {
- categoryDefinition.setName("1234AbcdE.");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde."); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_05() throws Exception {
- categoryDefinition.setName("1234AbcdE'");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde'");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_06() throws Exception {
- categoryDefinition.setName("1234AbcdE=");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde="); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_07() throws Exception {
- categoryDefinition.setName("1234AbcdE:");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde:"); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_08() throws Exception {
- categoryDefinition.setName("1234AbcdE@");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde@"); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_09() throws Exception {
- categoryDefinition.setName("1234AbcdE_");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde_"); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_10() throws Exception {
- categoryDefinition.setName("1234AbcdE#");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde#"); // normalization
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_11() throws Exception {
- categoryDefinition.setName("1234AbcdE d");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde d"); // normalization
- categoryDefinition.setName("1234AbcdE D");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void addServiceCategoryAllowedcharacters_12() throws Exception {
- categoryDefinition.setName("1234AbcdE &_=+.-'#:@ d");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("1234abcde &_=+.-'#:@ d"); // normalization
- categoryDefinition.setName("1234AbcdE &_=+.-'#:@ D");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveSpaceFromBeginning() throws Exception {
- categoryDefinition.setName(" Category01");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("category01"); // normalization
- categoryDefinition.setName("Category01");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveSpaceFromEnd() throws Exception {
- categoryDefinition.setName("Category01 ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("category01"); // normalization
- categoryDefinition.setName("Category01");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraSpace() throws Exception {
- categoryDefinition.setName("Category 02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("category 02"); // normalization
- categoryDefinition.setName("Category 02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraAmpersand() throws Exception {
- categoryDefinition.setName("Category&& &02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("category& &02"); // normalization
- categoryDefinition.setName("Category& &02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraDash() throws Exception {
- categoryDefinition.setName("CategorY-- --02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("CategorY- -02");
- categoryDefinition.setNormalizedName("category- -02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraPlus() throws Exception {
- categoryDefinition.setName("CateGory++++ +02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("CateGory+ +02");
- categoryDefinition.setNormalizedName("category+ +02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraPeriod() throws Exception {
- categoryDefinition.setName("Category.... .02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category. .02");
- categoryDefinition.setNormalizedName("category. .02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraApostrophe() throws Exception {
- categoryDefinition.setName("CaTegory''' '02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("CaTegory' '02");
- categoryDefinition.setNormalizedName("category' '02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraHashtag() throws Exception {
- categoryDefinition.setName("Category### #02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category# #02");
- categoryDefinition.setNormalizedName("category# #02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtrEequal() throws Exception {
- categoryDefinition.setName("Category=== =02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category= =02");
- categoryDefinition.setNormalizedName("category= =02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtrColon() throws Exception {
- categoryDefinition.setName("Category::: :02");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category: :02");
- categoryDefinition.setNormalizedName("category: :02");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtrAt() throws Exception {
- categoryDefinition.setName("Category@@@ @a2");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category@ @a2");
- categoryDefinition.setNormalizedName("category@ @a2");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_RemoveExtraUnderscore() throws Exception {
- categoryDefinition.setName("Category___ _22");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Category_ _22");
- categoryDefinition.setNormalizedName("category_ _22");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_FirstWordStartWithNumber() throws Exception {
- categoryDefinition.setName("1Category one");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("1Category One");
- categoryDefinition.setNormalizedName("1category one");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_FirstWordStartWithNonAlphaNumeric() throws Exception { // The
- // first
- // word
- // must
- // start
- // with
- // an
- // alpha-numeric
- // character
- // [a-Z
- // A..Z,
- // 0..9]
- char invalidChars[] = { '&', '-', '+', '.', '\'', '#', '=', ':', '@', '_' };
- for (int i = 0; i < invalidChars.length; i++) {
- DbUtils.deleteFromEsDbByPattern("_all");
- categoryDefinition.setName(invalidChars[i] + "AbcD123");
- categoryDefinition.setNormalizedName((invalidChars[i] + "AbcD123").toLowerCase());
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
- sdncAdminUserDetails1, SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
- createCategotyRest.getErrorCode().intValue());
-
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails1,
- ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
- "Service", "category");
-
- }
- }
-
- @Test
- public void addServiceCategoryAlreadyExist_uniqueness() throws Exception { // Verify
- // category
- // name
- // duplication
- // ("uniqueness")
- // as
- // non-case-sensitive,
- // so
- // we
- // don’t
- // create
- // duplicate
- // names
- // with
- // upper/lower
- // case
- // inconsistency.
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("abcd");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
- // set
- // catalog
- // uniqeId
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- // Create same category name again
- DbUtils.deleteFromEsDbByPattern("_all");
- CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
- categoryDataDefinition2.setName(categoryDefinition.getName());
- RestResponse addDuplicateCategoryRest = CategoryRestUtils.createCategory(categoryDataDefinition2,
- sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_ALREADY_EXISTS,
- addDuplicateCategoryRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
- ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, STATUS_CODE_ALREADY_EXISTS, AUDIT_SERVICE_TYPE,
- "Service", categoryDefinition.getName());
- // Get Category and verify that category was created is not deleted
- getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
-
- }
-
- @Test
- public void categoryNameValidation_ReplaceAndWithAmpersand_01() throws Exception {
- categoryDefinition.setName("At and T");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("At & T");
- categoryDefinition.setNormalizedName("at & t");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_ReplaceAndWithAmpersand_02() throws Exception {
- categoryDefinition.setName("At and t");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("At & T");
- categoryDefinition.setNormalizedName("at & t");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_ReplaceAndWithAmpersand_03() throws Exception {
- categoryDefinition.setName("Atand T");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("atand t");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_ReplaceAndWithAmpersand_04() throws Exception {
- categoryDefinition.setName("At andT");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("at andt");
- categoryDefinition.setName("At AndT");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_ReplaceAndWithAmpersand_05() throws Exception {
- categoryDefinition.setName(" and AttT");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("and attt");
- categoryDefinition.setName("And AttT");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidation_ReplaceAndWithAmpersand_06() throws Exception {
- categoryDefinition.setName("AttT and ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("attt and");
- categoryDefinition.setName("AttT And");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- // Bug
- @Test
- public void categoryNameValidation_ReplaceAndWithAmpersand_07() throws Exception {
- categoryDefinition.setName(" and a");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("and a");
- categoryDefinition.setName("And a");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationMaxLength() throws Exception {
- categoryDefinition.setName("AsdfghjQ234567890@#.&:+-_");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("asdfghjq234567890@#.&:+-_");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
-
- }
-
- @Test
- public void categoryNameValidationMaxLengthAfterNormalization() throws Exception {
- categoryDefinition.setName(" A jQ234 @@@___ +++ At and T and and ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("A JQ234 @_ + At & T & And");
- categoryDefinition.setNormalizedName("a jq234 @_ + at & t & and");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
-
- }
-
- @Test
- public void categoryNameValidationExceedMaxLengthAfterNormalization() throws Exception {
- categoryDefinition.setName(" AbdfghBCVa jQ234 @@___ +++ At and T ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("abdfghbcva jq234 @_ + at&t");
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
- "Service", "category");
- }
-
- @Test
- public void categoryNameValidationMinLengthAfterNormalization() throws Exception { // MinLengthAfterNormalization
- // =
- // 4
- // characters
- categoryDefinition.setName(" At and T ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("At & T");
- categoryDefinition.setNormalizedName("at & t");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationLessThanMinLengthAfterNormalization() throws Exception {
- categoryDefinition.setName(" A&&&&&&&&&&&&&&&&&T ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("a&t");
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
- "Service", "category");
- }
-
- @Test
- public void categoryNameValidationIsNull() throws Exception {
- categoryDefinition.setName(null);
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
- createCategotyRest.getErrorCode().intValue());
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
- "Service", "category");
- }
-
- @Test
- public void categoryNameValidationIsEmpty() throws Exception {
- categoryDefinition.setName("");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("");
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
- "Service", "category");
- }
-
- @Test
- public void categoryNameValidationInvalidCharacters() throws Exception {
- char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/',
- '|', '\\', ',' };
- for (int i = 0; i < invalidChars.length; i++) {
- DbUtils.deleteFromEsDbByPattern("_all");
- // DbUtils.cleanAllAudits();
- categoryDefinition.setName("AbcD123" + invalidChars[i]);
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setNormalizedName("");
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
- "Service", "category");
- }
- }
-
- @Test
- public void categoryNameValidationSameNameDifferentResourceType() throws Exception { // same
- // Catalog
- // Name
- // for
- // service/resource/product
- // is
- // allowed
- String name = ("Abcd");
- CategoryDefinition categoryDataDefinition1 = new CategoryDefinition();
- CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
- CategoryDefinition categoryDataDefinition3 = new CategoryDefinition();
- categoryDataDefinition1.setName(name);
- categoryDataDefinition2.setName(name);
- categoryDataDefinition3.setName(name);
- // CREATE CATEGORY FOR SERVICE
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition1,
- sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDataDefinition1.setNormalizedName("abcd");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition1);
- // get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition1); // also
- // set
- // catalog
- // uniqeId
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition1, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- // CREATE CATEGORY FOR RESOURCE_COMPONENT_TYPE
- DbUtils.deleteFromEsDbByPattern("_all");
- createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition2, sdncAdminUserDetails,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDataDefinition2.setNormalizedName("abcd");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition2);
- // Get Category
- getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition2);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
- // CREATE CATEGORY FOR PRODUCT
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse addCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition3,
- sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- addCategotyRest.getErrorCode().intValue());
- categoryDataDefinition3.setNormalizedName("abcd");
- CategoryValidationUtils.validateCreateCategoryResponse(addCategotyRest, categoryDataDefinition3);
-
- // Get Category
- getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition3);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
- STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
- }
-
- @Test
- public void categoryNameValidationFirstLetterOfKeyWordsCapitalized() throws Exception { // First
- // letter
- // of
- // key
- // words
- // are
- // capitalized
- categoryDefinition.setName("beNNy shaY michEl");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("BeNNy ShaY MichEl");
- categoryDefinition.setNormalizedName("benny shay michel");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_01() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" bank OF america ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Bank of America");
- categoryDefinition.setNormalizedName("bank of america");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_02() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName("THE america bank ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("THE America Bank");
- categoryDefinition.setNormalizedName("the america bank");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_03() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" A bank OF america ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("A Bank of America");
- categoryDefinition.setNormalizedName("a bank of america");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_04() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" bank america is A big ban ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Bank America Is a Big Ban");
- categoryDefinition.setNormalizedName("bank america is a big ban");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_05() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" aN apple comPany inC ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("AN Apple ComPany InC");
- categoryDefinition.setNormalizedName("an apple company inc");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_06() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" eat AN apple ANAN");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Eat an Apple ANAN");
- categoryDefinition.setNormalizedName("eat an apple anan");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_07() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" united states OF americA ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("United States of AmericA");
- categoryDefinition.setNormalizedName("united states of america");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- // need to re-check
- @Test
- public void categoryNameValidationConjunctions_08() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" oF united states OF amer ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("OF United States of Amer");
- categoryDefinition.setNormalizedName("of united states of amer");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_09() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" to Apple TO at&T TOO ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("To Apple to At&T TOO");
- categoryDefinition.setNormalizedName("to apple to at&t too");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_10() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" eat apple AS you liiikeas ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Eat Apple as You Liiikeas");
- categoryDefinition.setNormalizedName("eat apple as you liiikeas");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_11() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" as you may want ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("As You May Want");
- categoryDefinition.setNormalizedName("as you may want");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void categoryNameValidationConjunctions_12() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" the bank OF america ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("The Bank of America");
- categoryDefinition.setNormalizedName("the bank of america");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- // need to recheck
- @Test
- public void categoryNameValidationConjunctions_13() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" To tel-toto ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("To Tel-toto");
- categoryDefinition.setNormalizedName("to tel-toto");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- // recheck
- @Test
- public void categoryNameValidationConjunctions_14() throws Exception { // Normalize
- // the
- // category
- // name
- // conjunctions
- // ('of',
- // 'to',
- // 'for',
- // 'as',
- // 'a',
- // 'an'
- // ,
- // 'the')
- // are
- // lower
- // case.
- categoryDefinition.setName(" tel-aviv To la ");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Tel-aviv to La");
- categoryDefinition.setNormalizedName("tel-aviv to la");
- CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
- // Get service category and validate that category added as defined
- // (also set catalog uniqeId)
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
- STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
- }
-
- @Test
- public void createServiceCategoryHttpCspUserIdIsEmpty() throws Exception {
- User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncAdminUserDetails1.setUserId("");
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Abcd");
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
- expectedCatrgoryAuditJavaObject.setModifier("");
- expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
- expectedCatrgoryAuditJavaObject.setSubCategoryName("");
- expectedCatrgoryAuditJavaObject.setGroupingName("");
- expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
- expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
- expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
- AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
- }
-
- @Test
- public void createServiceCategorHttpCspUserIdIsNull() throws Exception {
- User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncAdminUserDetails1.setUserId(null);
- RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
- createCategotyRest.getErrorCode().intValue());
- categoryDefinition.setName("Abcd");
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
- expectedCatrgoryAuditJavaObject.setModifier("");
- expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
- expectedCatrgoryAuditJavaObject.setSubCategoryName("");
- expectedCatrgoryAuditJavaObject.setGroupingName("");
- expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
- expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
- expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
- AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
- }
-
- @Test
- public void createSrvcCategoryHttpCspUserIdHeaderIsMissing() throws Exception {
- RestResponse createConsumerRest = CategoryRestUtils
- .createServiceCategoryHttpCspAtuUidIsMissing(categoryDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
- createConsumerRest.getErrorCode().intValue());
- categoryDefinition.setName("Abcd");
- // get service category and validate that category was not added
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
- expectedCatrgoryAuditJavaObject.setModifier("");
- expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
- expectedCatrgoryAuditJavaObject.setSubCategoryName("");
- expectedCatrgoryAuditJavaObject.setGroupingName("");
- expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
- expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
- expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
- AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
- }
-
- @Test
- public void getServiceCategoryHierarchySuccessFlow() throws Exception {
-
- int numOfCategories = 3;
- List<CategoryDefinition> categories = new ArrayList<CategoryDefinition>();
- RestResponse restResponse;
- CategoryDefinition category;
- String categoryName = categoryDefinition.getName();
- for (int i = 0; i < numOfCategories; i++) {
- categoryDefinition.setName(categoryName + i);
- restResponse = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- category = ResponseParser.parseToObject(restResponse.getResponse(), CategoryDefinition.class);
- categories.add(category);
- }
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
-
- AuditValidationUtils.GetCategoryHierarchyAuditSuccess(GET_CATEGORY_HIERARCHY, AUDIT_SERVICE_TYPE,
- sdncAdminUserDetails, STATUS_CODE_SUCCESS);
- for (CategoryDefinition categoryCurr : categories) {
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryCurr);
- }
- }
-
- ///////////////////////////////// US570520 /////////////////////////////////
- private List<CategoryDefinition> defineCategories() throws Exception {
- String firstCategory = "FirstCategory";
- String secondCategory = "secondCategory";
- String thirdCategory = "ThirdCategory";
- String forthCategory = "forthCategory";
- CategoryDefinition category1 = new CategoryDefinition(categoryDefinition);
- category1.setName(firstCategory);
- CategoryDefinition category2 = new CategoryDefinition(categoryDefinition);
- category2.setName(secondCategory);
- CategoryDefinition category3 = new CategoryDefinition(categoryDefinition);
- category3.setName(thirdCategory);
- CategoryDefinition category4 = new CategoryDefinition(categoryDefinition);
- category4.setName(forthCategory);
- ArrayList<CategoryDefinition> categoryList = new ArrayList<CategoryDefinition>();
- categoryList.add(category1);
- categoryList.add(category2);
- categoryList.add(category3);
- categoryList.add(category4);
- return categoryList;
- }
-
- @Test
- public void getAllResourceCategoriesHirarchy() throws Exception {
- createAndValidateCategoriesExist(RESOURCE_COMPONENT_TYPE, categoryList);
-
- for (int i = 0; i < categoryList.size(); i++) {
- List<String> subCategorieUniqueIdList = new ArrayList<String>();
- for (int j = 0; j < subCategoryList.size(); j++) {
- RestResponse createSubCategory = CategoryRestUtils.createSubCategory(subCategoryList.get(j),
- categoryList.get(i), sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
- if (createSubCategory.getErrorCode().intValue() == STATUS_CODE_CREATED) {
- String subCategoryUniqeId = ResponseParser.getUniqueIdFromResponse(createSubCategory);
- subCategorieUniqueIdList.add(subCategoryUniqeId);
- subCategoriesToDeleteMap.put(categoryList.get(i).getUniqueId(), subCategorieUniqueIdList);
- }
- }
- }
-
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
-
- for (int i = 0; i < categoryList.size(); i++) {
- for (int j = 0; j < subCategoryList.size(); j++) {
- CategoryValidationUtils.verifySubCategoryExistInGetResponse(getAllCategoriesRest,
- categoryList.get(i).getUniqueId(), subCategoryList.get(j));
- }
- }
-
- checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
- }
-
- private List<SubCategoryDefinition> defineSubCategories(int catListSize) {
- List<SubCategoryDefinition> subCatList = new ArrayList<SubCategoryDefinition>();
- for (int j = 1; j <= catListSize; j++) {
- SubCategoryDefinition subCategory = new SubCategoryDefinition();
- subCategory.setName("SubCategory" + String.valueOf(j));
- subCatList.add(subCategory);
- }
- return subCatList;
- }
-
- private void createAndValidateCategoriesExist(String comp, List<CategoryDefinition> categoryList) throws Exception {
- createCategories(comp, categoryList);
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, comp);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- verifyCategoriesExist(categoryList, getAllCategoriesRest);
- }
-
- private void verifyCategoriesExist(List<CategoryDefinition> categoryList, RestResponse getAllCategoriesRest) {
- for (int i = 0; i < categoryList.size(); i++) {
- categoryList.get(i).setName(WordUtils.capitalize(categoryList.get(i).getName()));
- CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryList.get(i));
- }
- }
-
- private void createCategories(String comp, List<CategoryDefinition> categoryList) throws Exception {
- for (int i = 0; i < categoryList.size(); i++) {
- CategoryRestUtils.createCategory(categoryList.get(i), sdncAdminUserDetails, comp);
- }
- }
-
- @Test
- public void getAllServiceCategoriesHirarchy() throws Exception {
- // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
- createAndValidateCategoriesExist(SERVICE_COMPONENT_TYPE, categoryList);
- checkAuditSuccess(SERVICE_COMPONENT_TYPE);
- // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
- }
-
- @Test
- public void getAllResourceCategories_noAttUserHeader() throws Exception {
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(new User(), RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", 403, getAllCategoriesRest.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
- getAllCategoriesRest.getResponse());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
- expectedCatrgoryAuditJavaObject.setModifierName("");
- expectedCatrgoryAuditJavaObject.setModifierUid("");
- expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
- expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
- expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
- AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
- }
-
- @Test
- public void getAllResourceCategories_userNotProvisioned() throws Exception {
- User notProvisionedUser = new User();
- notProvisionedUser.setUserId("aa0001");
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(notProvisionedUser,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", 409, getAllCategoriesRest.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- getAllCategoriesRest.getResponse());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
- expectedCatrgoryAuditJavaObject.setModifierName("");
- expectedCatrgoryAuditJavaObject.setModifierUid(notProvisionedUser.getUserId());
- expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
- expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
- expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
- AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
- }
-
- @Test
- public void getAllResourceCategories_unsupportedComponent() throws Exception {
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "comp");
- assertEquals("Check response code after get all categories hirarchy", 400,
- getAllCategoriesRest.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(),
- new ArrayList<String>(Arrays.asList("component type")), getAllCategoriesRest.getResponse());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.UNSUPPORTED_ERROR.name());
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
- expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
- expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
- expectedCatrgoryAuditJavaObject.setDetails("comp");
- expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_INVALID_CONTENT));
- expectedCatrgoryAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo,
- new ArrayList<String>(Arrays.asList("component type"))));
- AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
- }
-
- @Test(enabled = false)
- public void getAllResourceCategories_emptyList() throws Exception {
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- RESOURCE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
- assertTrue(jArr.length() == 0);
-
- checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
- }
-
- private void checkAuditSuccess(String componentType) throws Exception {
- ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
- expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
- expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
- expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
- expectedCatrgoryAuditJavaObject.setDetails(componentType);
- expectedCatrgoryAuditJavaObject.setStatus("200");
- expectedCatrgoryAuditJavaObject.setDesc("OK");
- AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
- }
-
- @Test(enabled = false)
- public void getAllServiceCategories_emptyList() throws Exception {
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- SERVICE_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
- assertTrue(jArr.length() == 0);
-
- checkAuditSuccess(SERVICE_COMPONENT_TYPE);
- }
-
- @Test(enabled = false)
- public void getAllProductCategories_emptyList() throws Exception {
- RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
- PRODUCT_COMPONENT_TYPE);
- assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
- getAllCategoriesRest.getErrorCode().intValue());
- JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
- assertTrue(jArr.length() == 0);
-
- checkAuditSuccess(PRODUCT_COMPONENT_TYPE);
- }
-
- // @Test
- // public void getAllResourceCategories_generalError() throws Exception
- // {
- // User user = new User();
- // RestResponse getAllCategoriesRest =
- // CategoryRestUtils.getAllCategories(user, SERVICE_COMPONENT_TYPE);
- // assertEquals("Check response code after get Category", 500,
- // getAllCategoriesRest.getErrorCode().intValue());
- // Utils.checkBodyResponseOnError(ActionStatus.GENERAL_ERROR.name(), new
- // ArrayList<String>(), getAllCategoriesRest.getResponse());
- // }
-
- //////////////////////////////////////////////////////////////////////////////
-
- @Test
- public void importCategories() throws Exception {
-
- String importResourceDir = config.getImportTypesConfigDir() + File.separator + "categoryTypesTest.zip";
-
- MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create();
- mpBuilder.addPart("categoriesZip", new FileBody(new File(importResourceDir)));
-
- RestResponse importResult = CategoryRestUtils.importCategories(mpBuilder, sdncAdminUserDetails.getUserId());
- assertEquals("Check response code after Import", BaseRestUtils.STATUS_CODE_CREATED,
- importResult.getErrorCode().intValue());
-
- Map<String, Object> map = ResponseParser.parseToObjectUsingMapper(importResult.getResponse(), Map.class);
- assertEquals("Check entries count", 2, map.size());
-
- List<Map<String, Object>> resources = (List<Map<String, Object>>) map.get("resources");
- assertEquals("Check resource category entries count", 1, resources.size());
-
- List<Map<String, Object>> services = (List<Map<String, Object>>) map.get("services");
- assertEquals("Check resource category entries count", 2, services.size());
-
- RestResponse allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "resources");
- List<CategoryDefinition> resourceCategories = ResponseParser.parseCategories(allCategories);
- for (Map<String, Object> resource : resources) {
- boolean exist = false;
-
- for (CategoryDefinition categ : resourceCategories) {
- if (categ.getName().equals(resource.get("name"))) {
- exist = true;
- break;
- }
- }
- assertTrue("Check existance resource category " + resource.get("name"), exist);
- }
-
- allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "services");
- List<CategoryDefinition> servicesCategories = ResponseParser.parseCategories(allCategories);
- for (Map<String, Object> service : services) {
- boolean exist = false;
-
- for (CategoryDefinition categ : servicesCategories) {
- if (categ.getName().equals(service.get("name"))) {
- exist = true;
- break;
- }
- }
- assertTrue("Check existance service category " + service.get("name"), exist);
- }
- }
-}
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
deleted file mode 100644
index 3d2b3a06cf..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.category;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-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.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
- public static TestName name = new TestName();
-
- public ElementsApiTest() {
- super(name, ElementsApiTest.class.getName());
- }
-
- // Expected 200 Keep
- @Test
- public void getAllPropertyScopesSuccess() throws Exception {
- RestResponse response = ResourceRestUtils.getAllPropertyScopesTowardsCatalogBe();
- String action = "Get All Property Scopes";
- int expectedCode = 200;
- verifyErrorCode(response, action, expectedCode);
- }
-
- // Expected 200 Keep
- @Test
- public void getAllArtifactTypes() throws Exception {
- RestResponse response = ResourceRestUtils.getAllArtifactTypesTowardsCatalogBe();
- String action = "Get All Artifact Types";
- int expectedCode = 200;
- verifyErrorCode(response, action, expectedCode);
- }
-
- // Expected 200 Keep
- @Test
- public void getConfiguration() throws Exception {
- RestResponse response = ResourceRestUtils.getConfigurationTowardsCatalogBe();
- String action = "Get All Artifact Types";
- int expectedCode = 200;
-
- String json = response.getResponse();
- JSONObject jsonResp = (JSONObject) JSONValue.parse(json);
-
- HashMap<String, Object> artifacts = (HashMap<String, Object>) jsonResp.get("artifacts");
- Long defaultHeatTimeout = (Long) jsonResp.get("defaultHeatTimeout");
-
- if (defaultHeatTimeout == null) {
- response.setErrorCode(500);
- verifyErrorCode(response, action, expectedCode);
- return;
- }
-
- if (artifacts == null) {
- response.setErrorCode(500);
- verifyErrorCode(response, action, expectedCode);
- return;
- }
-
- JSONObject deploymentResources = (JSONObject) artifacts.get("deployment");
- JSONArray otherResources = (JSONArray) artifacts.get("other");
- if (deploymentResources == null || otherResources == null) {
- response.setErrorCode(500);
- verifyErrorCode(response, action, expectedCode);
- return;
- }
-
- JSONArray roles = (JSONArray) jsonResp.get("roles");
- if (roles == null) {
- response.setErrorCode(500);
- verifyErrorCode(response, action, expectedCode);
- return;
- }
-
- }
-
- public void verifyErrorCode(RestResponse response, String action, int expectedCode) {
- assertNotNull("check response object is not null after " + action, response);
- assertNotNull("check error code exists in response after " + action, response.getErrorCode());
- assertEquals("Check response code after + action" + action, expectedCode, response.getErrorCode().intValue());
- }
-
- @Test(enabled = false)
- public void getAllCategoriesSuccess() throws Exception {
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
- RestResponse response = CatalogRestUtils.getAllCategoriesTowardsCatalogBe();
- String action = "Get All Categories";
- int expectedCode = 200;
- verifyErrorCode(response, action, expectedCode);
- }
-
- @Test(enabled = false)
- public void getAllTagSuccess() throws Exception {
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
- RestResponse response = ResourceRestUtils.getAllTagsTowardsCatalogBe();
- String action = "Get All Categories";
- int expectedCode = 200;
- verifyErrorCode(response, action, expectedCode);
- }
-
-}
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
deleted file mode 100644
index 9e77526654..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.devCI;
-
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-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.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.execute.imports.ImportCsarResourceTest;
-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.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-public class ImportCsarUpdate extends ComponentBaseTest {
-
- @Rule
- public static TestName name = new TestName();
-
- public ImportCsarUpdate() {
- super(name, ImportCsarUpdate.class.getName());
- }
-
- @DataProvider(name = "happyArts")
- public Object[][] getHappyArtifacts() {
-
- return new Object[][] { { "happy_VF_RI2_G2_two_different_artifacts_under_heatBaseheatVolheatNet2" },
- { "happy_VF_RI2_G2_two_different_artifacts_under_heatBaseheatVolheatNet" },
- { "happy_VF_RI2_G2_two_identical_artifacts_under_heatBaseheatVolheatNet" },
- { "happy_VF_RI2_G2_two_different_artifacts_under_nested" },
- { "happy_VF_RI2_G2_two_indentical_nested_under_different_groups" },
- { "happy_VF_RI2_G2_two_different_nested_under_different_groups" },
- { "happy_VF_RI2_G2_two_different_nested_under_same_group" },
-
- };
- }
-
- @DataProvider(name = "negativeArts")
- public Object[][] getNegativeArtifacts() {
-
- return new Object[][] {
-
- { "negative_VF_RI2_G2_same_heatVol_different_groups" },
- { "negative_VF_RI2_G2_same_heatBase_different_envs" },
- { "negative_VF_RI2_G2_heatBaseHeatVolHeatNet_under_nested" },
- { "negative_VF_RI2_G2_two_indentical_artifacts_under_nested" },
- { "negative_VF_RI2_G2_nested_under_nested" }, { "negative_VF_RI2_G2_same_heatVol_different_groups" }, };
- }
-
- @BeforeTest
- public void resumeOrigCsarBefore() throws Exception {
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- ImportCsarResourceTest.copyCsarRest(sdncModifierDetails, "orig.csar", "importCsar_2Gartifacts.csar");
-
- }
-
- @AfterTest
- public void resumeOrigCsarAfter() throws Exception {
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- ImportCsarResourceTest.copyCsarRest(sdncModifierDetails, "orig.csar", "importCsar_2Gartifacts.csar");
-
- }
-
- @Test
- public void updateVFsearchByCsarIdCheckInState() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- Component resourceObject = AtomicOperationUtils
- .changeComponentState(resourceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true)
- .getLeft();
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "updateImportCsar_2Gartifacts_topologyChanged.csar", "importCsar_2Gartifacts.csar");
-
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceSecondImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
-
- // Validation Part
-
- resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
-
- }
-
- @Test
- public void updateVFsearchByCsarIdCheckInState_checkSum() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- Component resourceObject = AtomicOperationUtils
- .changeComponentState(resourceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true)
- .getLeft();
-
- // User sdncModifierDetails =
- // ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- // RestResponse copyRes =
- // ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,"updateImportCsar_2Gartifacts_topologyChanged.csar","importCsar_2Gartifacts.csar");
-
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceSecondImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
-
- // Validation Part
-
- resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
-
- }
-
- @Test
- public void updateVFsearchByCsarIdCheckOutState() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- // Component resourceObject =
- // AtomicOperationUtils.changeComponentState(resourceFirstImport,
- // UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "updateImportCsar_2Gartifacts_topologyChanged.csar", "importCsar_2Gartifacts.csar");
-
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceSecondImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
-
- // Validation Part
-
- resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
-
- }
-
- @Test
- public void updateVFsearchByCsarIdCertifyStat() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- Component resourceObject = AtomicOperationUtils
- .changeComponentState(resourceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true)
- .getLeft();
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "updateImportCsar_2Gartifacts_topologyChanged.csar", "importCsar_2Gartifacts.csar");
-
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceSecondImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
-
- // Validation Part
-
- resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
-
- }
-
- /*@Test
- public void updateVFsearchByCsarStartCertifaicationState() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- Component resourceObject = AtomicOperationUtils.changeComponentState(resourceFirstImport, UserRoleEnum.DESIGNER,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST, true).getLeft();
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "updateImportCsar_2Gartifacts_topologyChanged.csar", "importCsar_2Gartifacts.csar");
-
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceSecondImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
-
- // Validation Part
-
- resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
-
- }*/
-
- @Test
- public void updateVFsearchBySystemNameCheckInState() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- Component resourceObject = AtomicOperationUtils
- .changeComponentState(resourceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true)
- .getLeft();
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "updateImportCsar_2Gartifacts_topologyChanged.csar", "importCsar_2Gartifacts.csar");
-
- resourceDetails.setName("hardcodedNameChanged");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceSecondImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
-
- // Validation Part
-
- resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
-
- }
-
- @Test
- public void updateVFsearchBySystemNameCertifyState() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- Component resourceObject = AtomicOperationUtils
- .changeComponentState(resourceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true)
- .getLeft();
-
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "updateImportCsar_2Gartifacts_topologyChanged.csar", "importCsar_2Gartifacts.csar");
-
- resourceDetails.setName("hardcodedNameChanged");
- resourceDetails.setCsarUUID("importCsar_2Gartifacts");
- createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- }
-
- @Test
- public void updateVFsearchBySystemNameCsarIdNotExist() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("hardcodedName");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceFirstImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
- Component resourceObject = AtomicOperationUtils
- .changeComponentState(resourceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true)
- .getLeft();
- // User sdncModifierDetails =
- // ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- // RestResponse copyRes =
- // ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,"updateImportCsar_2Gartifacts_topologyChanged.csar","importCsar_2Gartifacts.csar");
- ResourceReqDetails resourceDetails2 = ElementFactory.getDefaultResource();
- resourceDetails2.setName("hardcodedName");
- resourceDetails2.setCsarUUID("importCsar_2Gartifacts");
- resourceDetails2.setResourceType(ResourceTypeEnum.VF.name());
- createResource = ResourceRestUtils.createResource(resourceDetails2,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resourceSecondImport = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(),
- Resource.class);
-
- // Validation Part
-
- resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
-
- }
-
-}
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 94715b2495..7ddddc1628 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
@@ -320,7 +320,7 @@ public class DistributionDownloadArtifactTest extends ComponentBaseTest {
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void downloadServiceArtifactSuccess() throws Exception {
// Create service
RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
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
deleted file mode 100644
index 404ed04766..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-//US505653
-package org.openecomp.sdc.ci.tests.execute.general;
-
-import org.apache.commons.codec.binary.Base64;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-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.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.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedAuthenticationAudit;
-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.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.*;
-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;
-import org.testng.AssertJUnit;
-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";
-
- protected static final String AUTH_SUCCESS = "AUTH_SUCCESS";
-
- protected static final String AUTH_FAILED_INVALID_PASSWORD = "AUTH_FAILED_INVALID_PASSWORD";
-
- protected static final String AUTH_FAILED_USER_NOT_FOUND = "AUTH_FAILED_USER_NOT_FOUND";
-
- protected static final String AUTH_REQUIRED = "AUTH_REQUIRED";
-
- protected static final String WWW_AUTHENTICATE = "WWW-Authenticate";
-
- // user ci password 123456
- // protected final String authorizationHeader = "Basic Y2k6MTIzNDU2";
- // user ci password 123456
- protected final String USER = "ci";
-
- protected final String PASSWORD = "123456";
-
- protected final String SALT = "2a1f887d607d4515d4066fe0f5452a50";
-
- protected final String HASHED_PASSWORD = "0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b";
-
- protected User sdncAdminUserDetails;
-
- protected ConsumerDataDefinition consumerDataDefinition;
- protected ResourceReqDetails resourceDetails;
- protected ServiceReqDetails serviceDetails;
- protected User sdncUserDetails;
-
- protected ArtifactReqDetails deploymentArtifact;
-
- protected ExpectedAuthenticationAudit expectedAuthenticationAudit;
-
- protected final String auditAction = "HttpAuthentication";
-
- protected String expectedDownloadServiceUrl;
- protected String expectedDownloadResourceUrl;
- protected ComponentInstanceReqDetails componentInstanceReqDetails;
-
- @Rule
- public static TestName name = new TestName();
-
- public BasicHttpAuthenticationTest() {
- super(name, BasicHttpAuthenticationTest.class.getName());
- }
-
- @BeforeMethod
- public void init() throws Exception {
-
- sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- Resource resourceObject = AtomicOperationUtils
- .createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- resourceDetails = new ResourceReqDetails(resourceObject);
- Service serviceObject = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
- serviceDetails = new ServiceReqDetails(serviceObject);
-
- deploymentArtifact = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(deploymentArtifact,
- sdncUserDetails, resourceDetails.getUniqueId());
- AssertJUnit.assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(),
- response.getErrorCode() == 200);
-
- componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance();
- // certified resource
- response = LifecycleRestUtils.certifyResource(resourceDetails);
- AssertJUnit.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, sdncUserDetails,
- serviceDetails.getUniqueId(), ComponentTypeEnum.SERVICE);
- AssertJUnit.assertTrue("response code is not 201, returned: " + response.getErrorCode(),
- response.getErrorCode() == 201);
- expectedAuthenticationAudit = new ExpectedAuthenticationAudit();
-
- // RestResponse addDeploymentArtifactResponse =
- // ArtifactRestUtils.addInformationalArtifactToService(deploymentArtifact,
- // sdncUserDetails, serviceDetails.getUniqueId());
- // assertEquals("didn't succeed to upload deployment artifact", 200,
- // addDeploymentArtifactResponse.getErrorCode().intValue());
- //
- // downloadUrl =
- // String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
- // ValidationUtils.convertToSystemName(serviceDetails.getServiceName()),
- // serviceDetails.getVersion(),
- // ValidationUtils.normalizeFileName(deploymentArtifact.getArtifactName()));
-
- expectedDownloadResourceUrl = String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
- ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(),
- ValidationUtils.convertToSystemName(resourceDetails.getName()), resourceDetails.getVersion(),
- ValidationUtils.normalizeFileName(deploymentArtifact.getArtifactName()));
- expectedDownloadResourceUrl = expectedDownloadResourceUrl.substring("/sdc/".length(),
- expectedDownloadResourceUrl.length());
-
- expectedDownloadServiceUrl = String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
- ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(),
- ValidationUtils.normalizeFileName(deploymentArtifact.getArtifactName()));
- expectedDownloadServiceUrl = expectedDownloadServiceUrl.substring("/sdc/".length(),
- expectedDownloadServiceUrl.length());
-
- sdncAdminUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- consumerDataDefinition = createConsumer();
- RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
- ;
-
- RestResponse createResponse = ConsumerRestUtils.createConsumer(consumerDataDefinition, sdncAdminUserDetails);
- BaseRestUtils.checkCreateResponse(createResponse);
-
- }
-
- @AfterMethod
- public void tearDown() throws Exception {
- RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
- ;
- }
-
- @Test
- public void sendAuthenticatedRequestTest_success() throws Exception, Exception {
- DbUtils.cleanAllAudits();
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(USER, PASSWORD);
- // RestResponse restResponse =
- // ArtifactRestUtils.downloadServiceArtifact(serviceDetails,
- // deploymentArtifact, sdncUserDetails, authorizationHeader);
- RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceDetails,
- deploymentArtifact, sdncUserDetails, authorizationHeader);
- AssertJUnit.assertEquals("Check response code after download artifact", 200,
- restResponse.getErrorCode().intValue());
- AssertJUnit.assertFalse(restResponse.getHeaderFields().containsKey(HttpHeaderEnum.WWW_AUTHENTICATE.getValue()));
-
- validateAuditAuthentication(USER, AUTH_SUCCESS, ComponentTypeEnum.RESOURCE);
-
- }
-
- protected void validateAuditAuthentication(String userName, String AuthStatus, ComponentTypeEnum compType)
- throws Exception {
- if (compType.equals(ComponentTypeEnum.RESOURCE)) {
- expectedAuthenticationAudit = new ExpectedAuthenticationAudit(expectedDownloadResourceUrl, userName,
- auditAction, AuthStatus);
- } else {
- expectedAuthenticationAudit = new ExpectedAuthenticationAudit(expectedDownloadServiceUrl, userName,
- auditAction, AuthStatus);
- }
- AuditValidationUtils.validateAuthenticationAudit(expectedAuthenticationAudit);
- }
-
- protected ConsumerDataDefinition createConsumer() {
- ConsumerDataDefinition consumer = new ConsumerDataDefinition();
- consumer.setConsumerName(USER);
- consumer.setConsumerSalt(SALT);
- consumer.setConsumerPassword(HASHED_PASSWORD);
- return consumer;
-
- }
-
- @Test
- public void sendAuthenticatedRequestWithoutHeadersTest() throws Exception, Exception {
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, new HashMap<String, String>());
- assertEquals("Check response code after download artifact", 401, restResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.AUTH_REQUIRED.name(), new ArrayList<String>(),
- restResponse.getResponse());
- assertTrue(restResponse.getHeaderFields().containsKey(WWW_AUTHENTICATE));
- List<String> getAuthenticateHeader = restResponse.getHeaderFields().get(WWW_AUTHENTICATE);
- assertEquals("www-authenticate header contains more then one value", 1, getAuthenticateHeader.size());
- assertTrue(getAuthenticateHeader.get(0).equals("Basic realm=" + "\"SDC\""));
-
- validateAuditAuthentication("", AUTH_REQUIRED, ComponentTypeEnum.SERVICE);
- }
-
- @Test
- public void sendAuthenticatedRequestTest_userIsNotProvsioned() throws Exception, Exception {
- String userName = "shay";
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(userName, "123456");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 403, restResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.AUTH_FAILED.name(), new ArrayList<String>(),
- restResponse.getResponse());
- assertFalse(restResponse.getHeaderFields().containsKey(WWW_AUTHENTICATE));
-
- validateAuditAuthentication(userName, AUTH_FAILED_USER_NOT_FOUND, ComponentTypeEnum.SERVICE);
- }
-
- @Test
- public void sendAuthenticatedRequestTest_userIsNull() throws Exception, Exception {
- String userName = "";
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(userName, "123456");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 403, restResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.AUTH_FAILED.name(), new ArrayList<String>(),
- restResponse.getResponse());
- assertFalse(restResponse.getHeaderFields().containsKey(WWW_AUTHENTICATE));
-
- validateAuditAuthentication(userName, AUTH_FAILED_USER_NOT_FOUND, ComponentTypeEnum.SERVICE);
- }
-
- @Test
- public void sendAuthenticatedRequestTest_passwordIsNull() throws Exception, Exception {
- String userName = "ci";
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(userName, "");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 403, restResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.AUTH_FAILED.name(), new ArrayList<String>(),
- restResponse.getResponse());
- assertFalse(restResponse.getHeaderFields().containsKey(WWW_AUTHENTICATE));
-
- validateAuditAuthentication(userName, AUTH_FAILED_INVALID_PASSWORD, ComponentTypeEnum.SERVICE);
- }
-
- @Test
- public void sendAuthenticatedRequestTest_passowrdIsNotValidated() throws Exception, Exception {
- String userCi = "ci";
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(userCi, "98765");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 403, restResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.AUTH_FAILED.name(), new ArrayList<String>(),
- restResponse.getResponse());
- assertFalse(restResponse.getHeaderFields().containsKey(HttpHeaderEnum.WWW_AUTHENTICATE.getValue()));
-
- validateAuditAuthentication(userCi, AUTH_FAILED_INVALID_PASSWORD, ComponentTypeEnum.SERVICE);
- }
-
- @Test
- public void sendAuthenticatedRequestTest_InvalidHeader() throws Exception, Exception {
- String userCredentials = USER + ":" + PASSWORD;
- byte[] encodeBase64 = Base64.encodeBase64(userCredentials.getBytes());
- String encodedUserCredentials = new String(encodeBase64);
- Map<String, String> authorizationHeader = new HashMap<String, String>();
- authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials);
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 400, restResponse.getErrorCode().intValue());
- assertFalse(restResponse.getHeaderFields().containsKey(HttpHeaderEnum.WWW_AUTHENTICATE.getValue()));
-
- validateAuditAuthentication("", AUTH_FAILED_INVALID_AUTHENTICATION_HEADER, ComponentTypeEnum.SERVICE);
- }
-
- @Test(enabled = false)
- public void sendTwoAuthenticatedRequestsTest() throws Exception, Exception {
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(USER, PASSWORD);
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 200, restResponse.getErrorCode().intValue());
-
- RestResponse secondRestResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after second download artifact", 200,
- secondRestResponse.getErrorCode().intValue());
- }
-
- @Test(enabled = false)
- public void sendAuthenticatedRequestTest_userValidation_1() throws Exception, Exception {
-
- ConsumerDataDefinition consumer = new ConsumerDataDefinition();
- consumer.setConsumerName("cI2468");
- consumer.setConsumerPassword(HASHED_PASSWORD);
- consumer.setConsumerSalt(SALT);
- RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumer, sdncAdminUserDetails);
- BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
-
- RestResponse createResponse = ConsumerRestUtils.createConsumer(consumer, sdncAdminUserDetails);
- BaseRestUtils.checkCreateResponse(createResponse);
-
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(consumer.getConsumerName(),
- PASSWORD);
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 200, restResponse.getErrorCode().intValue());
-
- deleteResponse = ConsumerRestUtils.deleteConsumer(consumer, sdncAdminUserDetails);
- BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
- }
-
- // ECOMP Consumer Name - UTF-8 string up to 255 characters containing the
- // following characters : ( maybe to limit 4-64 chars ? )
- // Lowercase characters {a-z}
- // Uppercase characters {A-Z}
- // Numbers {0-9}
- // Dash {-}; this character is not supported as the first character in the
- // user name
- // Period {.}; this character is not supported as the first character in the
- // user name
- // Underscore {_}
- // @Ignore("add manually user:password 24-!68:123456 to
- // users-configuration.yaml in runtime")
- @Test(enabled = false)
- public void sendAuthenticatedRequestTest_userValidation_2() throws Exception, Exception {
- ConsumerDataDefinition consumer = new ConsumerDataDefinition();
- consumer.setConsumerName("24-!68");
- consumer.setConsumerPassword(HASHED_PASSWORD);
- consumer.setConsumerSalt(SALT);
- RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumer, sdncAdminUserDetails);
- BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
-
- RestResponse createResponse = ConsumerRestUtils.createConsumer(consumer, sdncAdminUserDetails);
- BaseRestUtils.checkCreateResponse(createResponse);
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader(consumer.getConsumerName(),
- PASSWORD);
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 200, restResponse.getErrorCode().intValue());
-
- deleteResponse = ConsumerRestUtils.deleteConsumer(consumer, sdncAdminUserDetails);
- BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
- }
-
- // this is invalide becouse we do not use the : any more
- // @Ignore("can't exectue, yaml file does not allow to enter more then one
- // colon continuously (\":\") ")
- @Test(enabled = false)
- public void sendAuthenticatedRequestTest_userValidation_3() throws Exception, Exception {
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader("a:", "123456");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 200, restResponse.getErrorCode().intValue());
- }
-
- //
- // * ECOMP Consumer Password - expected to be SHA-2 256 encrypted value (
- // SALT + "real" password ) => maximal length 256 bytes = 32 characters
- // Before storing/comparing please convert upper case letter to lower.
- // The "normalized" encrypted password should match the following format :
- // [a-z0-9]
- // @Ignore("add manually user:password 2468:123:456 to
- // users-configuration.yaml in runtime")
- @Test(enabled = false)
- public void sendAuthenticatedRequestTest_passwordValidation_1() throws Exception, Exception {
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader("A1", "123:456");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 200, restResponse.getErrorCode().intValue());
- }
-
- // * ECOMP Consumer Password - expected to be SHA-2 256 encrypted value (
- // SALT + "real" password ) => maximal length 256 bytes = 32 characters
- // Before storing/comparing please convert upper case letter to lower.
- // The "normalized" encrypted password should match the following format :
- // [a-z0-9]
- @Test(enabled = false)
- // @Ignore("add manually user:password 2468:Sq123a456B to
- // users-configuration.yaml in runtime")
- public void sendAuthenticatedRequestTest_passwordValidation_2() throws Exception, Exception {
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader("B2", "Sq123a456B");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 200, restResponse.getErrorCode().intValue());
- }
-
- // * ECOMP Consumer Password - expected to be SHA-2 256 encrypted value (
- // SALT + "real" password ) => maximal length 256 bytes = 32 characters
- // Before storing/comparing please convert upper case letter to lower.
- // The "normalized" encrypted password should match the following format :
- // [a-z0-9]
- @Test
- // @Ignore("add C3:111T-0-*# to file")
- public void sendAuthenticatedRequestTest_passwordValidation_3() throws Exception, Exception {
- Map<String, String> authorizationHeader = BaseRestUtils.addAuthorizeHeader("C3", "111T-0-*#");
- RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, deploymentArtifact,
- sdncUserDetails, authorizationHeader);
- assertEquals("Check response code after download artifact", 200, restResponse.getErrorCode().intValue());
- }
-
-}
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
deleted file mode 100644
index 0934ebb4c2..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java
+++ /dev/null
@@ -1,1418 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.general;
-
-import com.google.gson.Gson;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedEcomConsumerAudit;
-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.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
-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.HashMap;
-
-import static org.testng.AssertJUnit.assertEquals;
-
-public class ManageEcompConsumerCredentials extends ComponentBaseTest {
-
- protected static final String ADD_ECOMP_USER_CREDENTIALS = "AddECOMPUserCredentials";
- protected static final String DELETE_ECOMP_USER_CREDENTIALS = "DeleteECOMPUserCredentials";
- protected static final String GET_ECOMP_USER_CREDENTIALS = "GetECOMPUserCredentials";
-
- public static final String contentTypeHeaderData = "application/json";
- public static final String acceptHeaderData = "application/json";
-
- public static final int STATUS_CODE_SUCCESS = 200;
- public static final int STATUS_CODE_SUCSESS_CREATED = 201;
- public static final int STATUS_CODE_SUCCESS_DELETE_GET = 200;
- public static final int STATUS_CODE_INVALID_CONTENT = 400;
- public static final int STATUS_CODE_MISSING_DATA = 400;
- public static final int STATUS_CODE_MISSING_INFORMATION = 403;
- public static final int STATUS_CODE_RESTRICTED_ACCESS = 403;
-
- public static final int STATUS_CODE_NOT_FOUND = 404;
- public static final int STATUS_CODE_RESTRICTED_OPERATION = 409;
-
- protected static Gson gson = new Gson();
- protected ConsumerDataDefinition consumerDataDefinition;
- protected User sdncAdminUserDetails;
- protected User sdncDesignerUserDetails;
- protected User sdncTesterUserDetails;
- protected User sdncGovernorUserDetails;
- protected User sdncOpsUserDetails;
-
- public ManageEcompConsumerCredentials() {
- super(name, ManageEcompConsumerCredentials.class.getName());
- }
-
- @Rule
- public static TestName name = new TestName();
-
- protected String salt = "123456789012345678901234567890ab";
- protected String password = "123456789012345678901234567890ab123456789012345678901234567890ab";
- protected String ecompUser = "benny";
-
- protected Long consumerDetailsLastupdatedtime;
-
- @BeforeMethod
- public void init() throws Exception {
- sdncAdminUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncDesignerUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- sdncTesterUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- sdncGovernorUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR);
- sdncOpsUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.OPS);
-
- consumerDataDefinition = new ConsumerDataDefinition();
- consumerDataDefinition.setConsumerName(ecompUser);
- consumerDataDefinition.setConsumerPassword(password);
- consumerDataDefinition.setConsumerSalt(salt);
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
-
- }
-
- // US563681 manage ECOMP consumer credentials - DELETE/GET
- @Test
- public void deleteEcompCredentialsMethodDelete() throws Exception {
- // Create Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- AssertJUnit.assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- AssertJUnit.assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete consumer
- // DbUtils.deleteFromEsDbByPattern("_all");
- DbUtils.cleanAllAudits();
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- AssertJUnit.assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS_DELETE_GET,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCCESS_DELETE_GET);
- // Get Consumer to verify that consumer user does not exist
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- AssertJUnit.assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- }
-
- //// US561728 CREATE ECOMP consumer credentials
- @Test
- public void createEcompCredentialsMethodPost() throws Exception {
- // Create Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- // Validate actual consumerData to returned from response
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
-
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- }
-
- @Test(enabled = false)
- public void createEcompCredentialsUserAlreayExist() throws Exception {
- // Create Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
-
- // Create consumer which already exists with different password and Salt
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerPassword("zxcvb");
- consumerDataDefinition.setConsumerSalt("1234567890qwertyuiop1234567890as");
- createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer with new data
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- // Delete Consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsByDesigner() throws Exception { // HttpCspUserId
- // header
- // contains
- // Designer
- // UserId
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncDesignerUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncDesignerUserDetails, ActionStatus.RESTRICTED_OPERATION);
- }
-
- @Test
- public void createEcompCredentialsByTester() throws Exception { // HttpCspUserId
- // header
- // contains
- // Tester
- // UserId
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncTesterUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncTesterUserDetails, ActionStatus.RESTRICTED_OPERATION);
- }
-
- @Test
- public void createEcompCredentialsByOps() throws Exception { // HttpCspUserId
- // header
- // contains
- // OPS
- // UserId
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition, sdncOpsUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncOpsUserDetails, ActionStatus.RESTRICTED_OPERATION);
- }
-
- @Test
- public void createEcompCredentialsByGovernor() throws Exception { // HttpCspUserId
- // header
- // contains
- // Governor
- // UserId
- // Create
- // Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncGovernorUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncGovernorUserDetails, ActionStatus.RESTRICTED_OPERATION);
- }
-
- @Test
- public void createEcompCredentialsByNoExistingIUser() throws Exception {
- User noSdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- noSdncUserDetails.setRole("blabla");
- noSdncUserDetails.setUserId("bt750h");
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition, noSdncUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_ACCESS.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(
- consumerDataDefinition.getConsumerName() + "," + consumerDataDefinition.getConsumerSalt().toLowerCase()
- + "," + consumerDataDefinition.getConsumerPassword());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc(""));
- expectedEcomConsumerAuditJavaObject.setModifier("(" + noSdncUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- // user name
- @Test
- public void createEcompCredentialsUserNameIsNull() throws Exception {
- consumerDataDefinition.setConsumerName(null); // SVC4528
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_DATA,
- createConsumerRest.getErrorCode().intValue());
- // verify taht consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerSalt().toLowerCase() + ","
- + consumerDataDefinition.getConsumerPassword());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer name"));
- expectedEcomConsumerAuditJavaObject
- .setModifier(sdncAdminUserDetails.getFullName() + "(" + sdncAdminUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void createEcompCredentialsUserNameIsEmpty() throws Exception {
- consumerDataDefinition.setConsumerName("");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerSalt().toLowerCase() + ","
- + consumerDataDefinition.getConsumerPassword());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer name"));
- expectedEcomConsumerAuditJavaObject
- .setModifier(sdncAdminUserDetails.getFullName() + "(" + sdncAdminUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void createEcompCredentialsUserNameIsNotUTF8() throws Exception {
- consumerDataDefinition.setConsumerName("בני"); // SVC4528
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- }
-
- @Test
- public void createEcompCredentialsUserNameMaxLength() throws Exception {
- consumerDataDefinition.setConsumerName(
- "_ABCD-.abcdqwertyuiopasdfghjklzxcvbnmqw1234567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890pf34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfgghjklqwertyuiopzaiutrewasdfghjklqwertyuiopzasxcdferf123456.-"); // SVC4528
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Validate actual consumerData to returned from response
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- // Delete Consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsUserNameExceedMaxLength() throws Exception {
- consumerDataDefinition.setConsumerName(
- "_ABCD-.abcdqwertyuiopasdfghjklzxcvbnmqw1234567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890pf34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfgghjklqwertyuiopzaiutrewasdfghjklqwertyuiopzasxcdferf123456.--"); // SVC4528
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.EXCEEDS_LIMIT, "Consumer name", "255");
- }
-
- @Test
- public void createEcompCredentialsUserNameLastCharIsDash() throws Exception { // allowed
- consumerDataDefinition.setConsumerName("ABCD34567890pf34567890poiutrew-");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject , Validate actual consumerData
- // to returned from response
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- // Delete Consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsUserNameLastCharIsPeriod() throws Exception {
- consumerDataDefinition.setConsumerName("ABCD34567890pf34567890poiutrew.");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject , Validate actual consumerData
- // to returned from response
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- // Delete Consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsUserNameLastCharIsUnderscore() throws Exception {
- consumerDataDefinition.setConsumerName("ABCD34567890pf34567890poiutrew_");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject , Validate actual consumerData
- // to returned from response
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- // Delete Consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsUserNameFirstCharIsUnderscore() throws Exception {
- consumerDataDefinition.setConsumerName("_ABCD34567890pf34567890poiutre");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject , Validate actual consumerData
- // to returned from response
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- // Delete Consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsUserNameFirstCharIsPeriod() throws Exception {
- consumerDataDefinition.setConsumerName(".ABCD34567890pf34567890poiutre");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_CONTENT_PARAM, "Consumer name");
- }
-
- @Test
- public void createEcompCredentialsUserNameFirstCharIsDash() throws Exception { // Not
- // allowed
- consumerDataDefinition.setConsumerName("-ABCD34567890pf34567890poiutre");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_CONTENT_PARAM, "Consumer name");
- }
-
- /// Password
- @Test
- public void createEcompCredentialsPasswordIsNull() throws Exception {
- consumerDataDefinition.setConsumerPassword(null);
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_DATA,
- createConsumerRest.getErrorCode().intValue());
- // verify taht consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerSalt().toLowerCase());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer password"));
- expectedEcomConsumerAuditJavaObject
- .setModifier(sdncAdminUserDetails.getFullName() + "(" + sdncAdminUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void createEcompCredentialsPasswordIsEmpty() throws Exception {
- consumerDataDefinition.setConsumerPassword("");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_DATA,
- createConsumerRest.getErrorCode().intValue());
- // verify taht consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerSalt().toLowerCase());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer password"));
- expectedEcomConsumerAuditJavaObject
- .setModifier(sdncAdminUserDetails.getFullName() + "(" + sdncAdminUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void createEcompCredentialsPasswordMaxLength() throws Exception { // password
- // must
- // be
- // 64
- // chars
- consumerDataDefinition.setConsumerPassword("123456789012345678901234567890ab123456789012345678901234567890ab");
- // Create Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- // Validate actual consumerData to returned from response
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- // Delete Consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsPasswordExceeedMaxLength() throws Exception { // password
- // must
- // be
- // 64
- // chars
- consumerDataDefinition.setConsumerPassword("123456789012345678901234567890ab123456789012345678901234567890ab1");
- // Create Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_LENGTH, "Consumer password", "64");
- }
-
- @Test
- public void createEcompCredentiaPasswordValid() throws Exception {
- // Password Contains lowercase/uppercase characters and numbers -
- // convert upper case letter to lower
- consumerDataDefinition.setConsumerPassword("ABCabc1234567890POImnb12345678901234567890POIUzxcvbNMASDFGhjkl12");
- // Create Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
-
- }
-
- //// Salt
- @Test
- public void createEcompCredentialsSaltIsNull() throws Exception {
- // Length must be 32 characters
- consumerDataDefinition.setConsumerSalt(null);
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_DATA,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerPassword().toLowerCase());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer salt"));
- expectedEcomConsumerAuditJavaObject
- .setModifier(sdncAdminUserDetails.getFullName() + "(" + sdncAdminUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
-
- }
-
- @Test
- public void createEcompCredentialsSaltIsEmpty() throws Exception {
- consumerDataDefinition.setConsumerSalt("");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_DATA,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerPassword().toLowerCase());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer salt"));
- expectedEcomConsumerAuditJavaObject
- .setModifier(sdncAdminUserDetails.getFullName() + "(" + sdncAdminUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void createEcompCredentialsSaltLengthLessThan32() throws Exception {
- consumerDataDefinition.setConsumerSalt("123456789012345678901234567890a");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_LENGTH, "Consumer salt");
-
- }
-
- // Bug
- @Test
- public void createEcompCredentialsSaltLengthMoreThan32() throws Exception { // Length
- // must
- // be
- // 32
- // characters
- // -
- // SVC4529
- // "Error:
- // Invalid
- // Content.
- // %1
- // exceeds
- // limit
- // of
- // %2
- // characters."
- consumerDataDefinition.setConsumerSalt("123456789012345678901234567890abc");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_LENGTH, "Consumer salt");
-
- }
-
- @Test
- public void createEcompCredentialsSaltUppercaseCharacters() throws Exception {
- // Contains uppercase characters– exception invalid content
- consumerDataDefinition.setConsumerSalt("123456789012345678901234567890AB");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // verify that consumer didn't created
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT_PARAM.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerSalt() + "," + consumerDataDefinition.getConsumerPassword());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer salt"));
- expectedEcomConsumerAuditJavaObject
- .setModifier(sdncAdminUserDetails.getFullName() + "(" + sdncAdminUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- // USER_ID (USER_ID is taken from USER_ID header)
-
- @Test
- public void createEcompCredentialsHttpCspUserIdIsEmpty() throws Exception {
- // USER_ID is taken from USER_ID header
- sdncAdminUserDetails.setUserId("");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
- createConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerSalt() + "," + consumerDataDefinition.getConsumerPassword());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer salt"));
- expectedEcomConsumerAuditJavaObject.setModifier("");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void createEcompCredentialsHttpCspUserIdIsNull() throws Exception { // USER_ID
- // is
- // taken
- // from
- // USER_ID
- // header
- sdncAdminUserDetails.setUserId(null);
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
- createConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerSalt() + "," + consumerDataDefinition.getConsumerPassword());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer salt"));
- expectedEcomConsumerAuditJavaObject.setModifier("");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void createEcompCredentialsHttpCspUserIdHeaderIsMissing() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumerHttpCspAtuUidIsMissing(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
- createConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName() + ","
- + consumerDataDefinition.getConsumerSalt() + "," + consumerDataDefinition.getConsumerPassword());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc("Consumer salt"));
- expectedEcomConsumerAuditJavaObject.setModifier("");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- ADD_ECOMP_USER_CREDENTIALS);
- }
-
- // add USER_ID in json body
- @Test
- public void createEcompCredentiaJsonBodyContainLastModfierAtuid() throws Exception {
- // Add USER_ID (not admin) to json - we will ignore and create the user
- HashMap<String, String> jsonMap = new HashMap<String, String>();
- jsonMap.put("consumerName", "benny");
- jsonMap.put("consumerPassword", "123456789012345678901234567890ab123456789012345678901234567890ab");
- jsonMap.put("consumerSalt", "123456789012345678901234567890ab");
- jsonMap.put("lastModfierAtuid", "cs0008"); // designer
- Gson gson = new Gson();
- ConsumerDataDefinition consumer = gson.fromJson(jsonMap.toString(), ConsumerDataDefinition.class);
-
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumer, sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Validate actual consumerData to returned from response
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumer, getConsumerDataObject);
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumer, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumer, sdncAdminUserDetails,
- STATUS_CODE_SUCSESS_CREATED);
- // Delete consumer
- ConsumerRestUtils.deleteConsumer(consumer, sdncAdminUserDetails);
- }
-
- @Test
- public void createEcompCredentialsUserNameNotAllowedCharacters() throws Exception {
- char invalidChars[] = { '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', '<', '>', '?', '/',
- '"', ':', '}', ']', '[', '{', '|', '\\', ' ', '\t', '\n' };
- for (int i = 0; i < invalidChars.length; i++) {
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerName(invalidChars[i] + "ABCdef123");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_CONTENT_PARAM, "Consumer name");
- }
- }
-
- @Test
- public void createEcompCredentialsPasswordIsInvalid() throws Exception {
- char invalidChars[] = { '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', '<', '>', '?', '/',
- '"', ':', '}', ']', '[', '{', '|', '\\', ' ', '\t', '\n' };
- for (int i = 0; i < invalidChars.length; i++) {
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerPassword(
- "ABC" + invalidChars[i] + "ABCabc1234567890POImnb12345678901234567890POIUzxcvbNMASDFGhj");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_CONTENT_PARAM, "Consumer password");
- }
- }
-
- @Test
- public void createEcompCredentialsSaltNotAllowedCharacters() throws Exception { // Salt
- // must
- // be
- // 32
- // chars
- char invalidChars[] = { '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', '<', '>', '?', '/',
- '"', ':', '}', ']', '[', '{', '|', '\\', ' ', '\t', '\n' };
- for (int i = 0; i < invalidChars.length; i++) {
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerSalt(invalidChars[i] + "1234567890123456789012345678901");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_INVALID_CONTENT,
- createConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.createEcompConsumerAuditFailure(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.INVALID_CONTENT_PARAM, "Consumer salt");
- }
- }
-
- @Test
- public void createEcompCredentialsPasswordEncoded() throws Exception {
- consumerDataDefinition.setConsumerPassword("0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- // Validate actual consumerData to returned from response
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
-
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(ADD_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCSESS_CREATED);
- }
-
- //
-
- @Test
- public void deleteEcompUserAlreayDeleted() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete ECOMP consumer
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS_DELETE_GET,
- deleteConsumerRest.getErrorCode().intValue());
- // Try to delete ECOMP consumer already deleted
- DbUtils.deleteFromEsDbByPattern("_all");
- deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
- }
-
- @Test
- public void deleteEcompUserByTester() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncTesterUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncTesterUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Verify that consumer is not deleted
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- }
-
- @Test
- public void deleteEcompUserByOps() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncOpsUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncOpsUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Verify that consumer is not deleted
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- }
-
- @Test
- public void deleteEcompUserByGovernor() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncGovernorUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncGovernorUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Verify that consumer is not deleted
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- }
-
- @Test
- public void deleteEcompUserByDesigner() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncDesignerUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncDesignerUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Verify that consumer is not deleted
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- }
-
- @Test
- public void deleteEcompUserByNoExistingIUser() throws Exception {
- User noSdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- noSdncUserDetails.setRole("blabla");
- noSdncUserDetails.setUserId("bt750h");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, noSdncUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_ACCESS,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_ACCESS.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(ADD_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc(""));
- expectedEcomConsumerAuditJavaObject.setModifier("(" + noSdncUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- DELETE_ECOMP_USER_CREDENTIALS);
- // Verify that consumer is not deleted
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- }
-
- @Test
- public void deleteEcompCredentialsUserDoesNotExist() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
-
- }
-
- @Test
- public void deleteEcompCredentialsUserNameIsNull() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerName(null);
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
- }
-
- @Test
- public void deleteEcompCredentialsUserNameMaxLength() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerName(
- "_BCD-.abcdqwertyuiopasdfghjklzxcvbnmqw1234567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890pf34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfgghjklqwertyuiopzaiutrewasdfghjklqwertyuiopzasxcdferf123456.--"); // SVC4528
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
- }
-
- @Test
- public void deleteEcompCredentialsUserNameExceedMaxLength() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerName(
- "_XXXBCD-.abcdqwertyuiopasdfghjklzxcvbnmqw1234567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890pf34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfgghjklqwertyuiopzaiutrewasdfghjklqwertyuiopzasxcdferf123456.--"); // SVC4528
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
- }
-
- @Test
- public void deleteEcompCredentialsHttpCspUserIdHeaderIsMissing() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse createConsumerRest = ConsumerRestUtils.deleteConsumerHttpCspAtuUidIsMissing(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
- createConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(DELETE_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc());
- expectedEcomConsumerAuditJavaObject.setModifier("");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- DELETE_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void deleteEcompCredentialsNameIsUpperCase() throws Exception {
- consumerDataDefinition.setConsumerName("benny");
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerName("BENNY");
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- deleteConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(DELETE_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
- // Get Consumer to verify that consumer user was not deleted
- consumerDataDefinition.setConsumerName("benny");
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- }
-
- @Test
- public void getEcompCredentialsMethodGet() throws Exception {
- // Create Consumer
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- // Validate actual consumerData to returned from response
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- DbUtils.deleteFromEsDbByPattern("_all");
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCCESS_DELETE_GET);
- // Delete consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void getEcompUserAlreayDeleted() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- // Delete ECOMP consumer
- RestResponse deleteConsumerRest = ConsumerRestUtils.deleteConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS_DELETE_GET,
- deleteConsumerRest.getErrorCode().intValue());
- DbUtils.deleteFromEsDbByPattern("_all");
- // Try to get ECOMP consumer already deleted
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
- }
-
- @Test
- public void getEcompUserByTester() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer by Tester user
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncTesterUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncTesterUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Get Consumer by Admin
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void getEcompUserByOps() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer by Ops user
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncOpsUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncOpsUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Get Consumer by Admin
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void getEcompUserByGovernor() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer by Ops user
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncGovernorUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncGovernorUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Get Consumer by Admin
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void getEcompUserByDesigner() throws Exception {
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // Get Consumer by Designer user
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncDesignerUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_OPERATION,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncDesignerUserDetails, ActionStatus.RESTRICTED_OPERATION);
- // Get Consumer by Admin
- getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-
- @Test
- public void getEcompUserByNoExistingIUser() throws Exception {
- User noSdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- noSdncUserDetails.setRole("blabla");
- noSdncUserDetails.setUserId("bt750h");
- // Get Consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, noSdncUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_RESTRICTED_ACCESS,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_ACCESS.name());
- ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit();
- expectedEcomConsumerAuditJavaObject.setAction(GET_ECOMP_USER_CREDENTIALS);
- expectedEcomConsumerAuditJavaObject.setEcomUser(consumerDataDefinition.getConsumerName());
- expectedEcomConsumerAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedEcomConsumerAuditJavaObject.setDesc(errorInfo.getAuditDesc(""));
- expectedEcomConsumerAuditJavaObject.setModifier("(" + noSdncUserDetails.getUserId() + ")");
- AuditValidationUtils.validateEcompConsumerAudit(expectedEcomConsumerAuditJavaObject,
- GET_ECOMP_USER_CREDENTIALS);
- }
-
- @Test
- public void getEcompCredentialsUserDoesNotExist() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
-
- }
-
- @Test
- public void getEcompCredentialsUserNameIsNull() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- consumerDataDefinition.setConsumerName(null);
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_NOT_FOUND,
- getConsumerRest.getErrorCode().intValue());
- // Audit validation
- AuditValidationUtils.deleteEcompConsumerAuditFailure(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, ActionStatus.ECOMP_USER_NOT_FOUND, consumerDataDefinition.getConsumerName());
- }
-
- @Test
- public void getEcompCredentialsUserNameMaxLength() throws Exception {
- consumerDataDefinition.setConsumerName(
- "_ABCD-.abcdqwertyuiopasdfghjklzxcvbnmqw1234567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfg34567890pf34567890poiutrewasdfghjklqwertyuiopzaiutrewasdfgghjklqwertyuiopzaiutrewasdfghjklqwertyuiopzasxcdferf123456.-"); // SVC4528
- RestResponse createConsumerRest = ConsumerRestUtils.createConsumer(consumerDataDefinition,
- sdncAdminUserDetails);
- assertEquals("Check response code after create Consumer", STATUS_CODE_SUCSESS_CREATED,
- createConsumerRest.getErrorCode().intValue());
- // parse updated response to javaObject
- ConsumerDataDefinition getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(createConsumerRest);
- // Validate actual consumerData to returned from response
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Get Consumer
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse getConsumerRest = ConsumerRestUtils.getConsumer(consumerDataDefinition, sdncAdminUserDetails);
- assertEquals("Check response code after get Consumer", STATUS_CODE_SUCCESS,
- getConsumerRest.getErrorCode().intValue());
- getConsumerDataObject = ConsumerRestUtils.parseComsumerResp(getConsumerRest);
- ConsumerRestUtils.validateConsumerReqVsResp(consumerDataDefinition, getConsumerDataObject);
- // Audit validation
- AuditValidationUtils.ecompConsumerAuditSuccess(GET_ECOMP_USER_CREDENTIALS, consumerDataDefinition,
- sdncAdminUserDetails, STATUS_CODE_SUCCESS_DELETE_GET);
- // Delete consumer
- ConsumerRestUtils.deleteConsumer(consumerDataDefinition, sdncAdminUserDetails);
- }
-}
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
deleted file mode 100644
index eed10581e2..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java
+++ /dev/null
@@ -1,1719 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.imports;
-
-import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang.WordUtils;
-import org.junit.Rule;
-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.*;
-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.*;
-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.*;
-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 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());
- @Rule
- public static TestName name = new TestName();
-
- Gson gson = new Gson();
-
- public ImportCsarResourceTest() {
- super(name, ImportCsarResourceTest.class.getName());
- }
-
- private String buildAssertMessage(String expectedString, String actualString) {
- return String.format("expected is : %s , actual is: %s", expectedString, actualString);
- }
-
- /**
- *
- * User Story : US640615 [BE] - Extend create VF API with Import TOSCA CSAR
- */
-
- @Test(enabled = true)
- public void createResourceFromCsarHappy() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("AF7F231969C5463F9C968570070E8877");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- String expectedCsarUUID = resourceDetails.getCsarUUID();
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, resource.getCsarUUID()), expectedCsarUUID.equals(resource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resource.getUniqueId());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, getResource.getCsarUUID()), expectedCsarUUID.equals(getResource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
- }
-
- @Test(enabled = true)
- public void emptyStringInCsarUUIDFieldTest() throws Exception {
- String emptyString = "";
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID(emptyString);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(null, resource.getComponentInstances());
-
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(emptyString, resource.getCsarUUID()), resource.getCsarUUID() == emptyString);
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resource.getUniqueId());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(emptyString, getResource.getCsarUUID()), getResource.getCsarUUID() == emptyString);
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
- }
-
- @Test(enabled = true)
- public void createResourceFromScratchTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(null, resource.getComponentInstances());
-
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(null, resource.getCsarUUID()), resource.getCsarUUID() == null);
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resource.getUniqueId());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(null, getResource.getCsarUUID()), getResource.getCsarUUID() == null);
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
- }
-
- @Test(enabled = true)
- public void fileNotCsarTypeTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("valid_vf_zip");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_NOT_FOUND.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void missingToscaMetadataFolderTest() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("toscaFolderNotExists");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void missingToscaMetaFileTest() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("toscaMetaFileNotExists");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void toscaMetaFileOutsideTheFolderTest() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("toscaMetaOutsideTheFolder");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void caseSensitiveTest_1() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("caseSensitiveTest_1");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void caseSensitiveTest_2() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("caseSensitiveTest_2");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void missingOneLineInToscaMetaFileTest() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("missingOneLineInToscaMeta");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void noCSARVersionTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("noCSARVersion");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void noCreatedByValueTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("noCreatedByValue");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void noEntryDefinitionsValueTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("noEntryDefinitionsValue");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void noTOSCAMetaFileVersionValueTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("noTOSCAMetaFileVersionValue");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void invalidCsarVersionInMetaFileTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("invalidCsarVersion");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
-
- resourceDetails.setCsarUUID("invalidCsarVersion2");
- createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
-
- resourceDetails.setCsarUUID("invalidCsarVersion3");
- createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
-
- resourceDetails.setCsarUUID("invalidCsarVersion4");
- createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
-
- resourceDetails.setCsarUUID("invalidCsarVersion5");
- createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
-
- }
-
- @Test(enabled = true)
- public void validCsarVersionInMetaFileTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("validCsarVersion");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- String expectedCsarUUID = resourceDetails.getCsarUUID();
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, resource.getCsarUUID()), expectedCsarUUID.equals(resource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resource.getUniqueId());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, getResource.getCsarUUID()), expectedCsarUUID.equals(getResource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
- }
-
- @Test(enabled = true)
- public void underscoreInToscaMetaFileVersionNameTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("underscoreInsteadOfDash");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void missingEntryDefintionInMetaFileTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("missingEntryDefintionPair");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = false)
- public void noNewLineAfterBLock0Test() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("noNewLineAfterBLock0");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void moreThanOneYamlFileTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("moreThenOneYamlFile");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- String expectedCsarUUID = resourceDetails.getCsarUUID();
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, resource.getCsarUUID()), expectedCsarUUID.equals(resource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resource.getUniqueId());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, getResource.getCsarUUID()), expectedCsarUUID.equals(getResource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
- }
-
- @Test(enabled = true)
- public void moreThanOneMetaFileTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("moreThanOneMetaFile");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- String expectedCsarUUID = resourceDetails.getCsarUUID();
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, resource.getCsarUUID()), expectedCsarUUID.equals(resource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resource.getUniqueId());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, getResource.getCsarUUID()), expectedCsarUUID.equals(getResource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
- }
-
- @Test(enabled = true)
- public void csarNotContainsYamlAndMetaFilesTest() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("notContainYamlAndMetaFiles");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void csarNotContainsYamlFileTest() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("notContainYamlFile");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- variables.add("Definitions/tosca_mock_vf.yaml");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.YAML_NOT_FOUND_IN_CSAR.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void missingCsarFileTest() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("abc");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_NOT_FOUND.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void longNamesInToscaMetaFileTest_1() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("longNamesInToscaMetaFile1");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void longNamesInToscaMetaFileTest_2() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("longNamesInToscaMetaFile2");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void longNamesInToscaMetaFileTest_3() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("longNamesInToscaMetaFile3");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void longNamesInToscaMetaFileTest_4() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("longNamesInToscaMetaFile4");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void longNamesInToscaMetaFileTest_5() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("longNamesInToscaMetaFile5");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- // possible to have more than four lines in block 0
- // @Test (enabled = true)
- public void fiveLinesAsBlock0Test() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- resourceDetails.setCsarUUID("fiveLinesAsBlock0");
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- List<String> variables = new ArrayList<String>();
- variables.add(resourceDetails.getCsarUUID());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.CSAR_INVALID_FORMAT.name(), variables, createResource.getResponse());
- }
-
- @Test(enabled = true)
- public void lifecycleChangingToResourceFromCsarTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("valid_vf");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
-
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertTrue("0.1".equals(resource.getVersion()));
- assertTrue(LifeCycleStatesEnum.CHECKOUT.getComponentState().equals(resource.getLifecycleState().toString()));
-
- String designerUserId = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId();
- String testerUserId = ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId();
- String csarUniqueId = resourceDetails.getUniqueId();
- assertNotNull(csarUniqueId);
-
- RestResponse lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
-/* lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.STARTCERTIFICATION);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);*/
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.CERTIFY);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
-
- resource = ResponseParser.parseToObjectUsingMapper(lifecycleChangeResponse.getResponse(), Resource.class);
- Map<String, String> allVersions = resource.getAllVersions();
- assertEquals(2, allVersions.keySet().size());
- assertEquals(2, allVersions.values().size());
- Set<String> keySet = allVersions.keySet();
- assertTrue(keySet.contains("1.0"));
- assertTrue(keySet.contains("1.1"));
- }
-
- @Test(enabled = true)
- public void csarWithJsonPromEnvTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("VSPPackageJsonProp.csar");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
-
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
- }
-
- @Test(enabled = true)
- public void uploadArtifactToResourceFromCsarTest() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("valid_vf");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
-
- User designer = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- ArtifactReqDetails artifactDetails = ElementFactory.getDefaultArtifact("firstArtifact");
- String firstArtifactLabel = artifactDetails.getArtifactLabel();
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, designer, resourceDetails.getUniqueId());
- ArtifactRestUtils.checkSuccess(addInformationalArtifactToResource);
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resourceDetails.getUniqueId());
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- Map<String, ArtifactDefinition> informationalArtifacts = resource.getArtifacts();
- assertEquals(1, informationalArtifacts.keySet().size());
- Set<String> keySet = informationalArtifacts.keySet();
- assertTrue(keySet.contains(firstArtifactLabel.toLowerCase()));
- Collection<ArtifactDefinition> values = informationalArtifacts.values();
- assertEquals(1, values.size());
- Iterator<ArtifactDefinition> iterator = values.iterator();
- while (iterator.hasNext()) {
- ArtifactDefinition actualArtifact = iterator.next();
- assertTrue(firstArtifactLabel.equals(actualArtifact.getArtifactDisplayName()));
- }
-
- RestResponse lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designer.getUserId(), LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designer.getUserId(), LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
-
- ArtifactReqDetails artifactDetails2 = ElementFactory.getDefaultArtifact("secondArtifact");
- artifactDetails2.setArtifactName("secondArtifact");
- addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails2, designer, resourceDetails.getUniqueId());
- ArtifactRestUtils.checkSuccess(addInformationalArtifactToResource);
-
- getResourceResponse = ResourceRestUtils.getResource(resourceDetails.getUniqueId());
- resource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- informationalArtifacts = resource.getArtifacts();
- assertEquals(2, informationalArtifacts.keySet().size());
- keySet = informationalArtifacts.keySet();
- assertTrue(keySet.contains(firstArtifactLabel.toLowerCase()));
- assertTrue(keySet.contains(artifactDetails2.getArtifactLabel().toLowerCase()));
- values = informationalArtifacts.values();
- assertEquals(2, values.size());
- ArtifactDefinition[] actualArtifacts = values.toArray(new ArtifactDefinition[2]);
- assertTrue(firstArtifactLabel.equals(actualArtifacts[0].getArtifactDisplayName()));
- assertTrue(artifactDetails2.getArtifactLabel().equals(actualArtifacts[1].getArtifactDisplayName()));
- }
-
- /*
- * // @Test (enabled = true) public void createUpdateImportResourceFromCsarArtifactsWereNotChangedTest() throws Exception { // User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); // //back original scar RestResponse
- * copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar"); BaseRestUtils.checkSuccess(copyRes);
- *
- * // resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); // RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails); resourceDetails.setName("test5");
- * resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts.csar"); resourceDetails.setCsarVersion("1"); // String invariantUUID = resource.getInvariantUUID(); // // RestResponse changeResourceState =
- * LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN); // assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- *
- * // BaseRestUtils.checkSuccess(copyRes); // //change name (temporary) resourceDetails.setCsarVersion("2"); resourceDetails.setName("test6"); createResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails,
- * resourceDetails.getUniqueId()); Resource updatedResource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); Map<String, ArtifactDefinition> updatedArtifacts = updatedResource.getDeploymentArtifacts(); for
- * (Entry<String, ArtifactDefinition> artifactEntry : resource.getDeploymentArtifacts().entrySet()) { if (updatedArtifacts.containsKey(artifactEntry.getKey())) { ArtifactDefinition currArt = updatedArtifacts.get(artifactEntry.getKey());
- * assertEquals(currArt.getArtifactVersion(), artifactEntry.getValue().getArtifactVersion()); assertEquals(currArt.getArtifactUUID(), artifactEntry.getValue().getArtifactUUID()); assertEquals(currArt.getArtifactChecksum(),
- * artifactEntry.getValue().getArtifactChecksum()); } } // resourceDetails = ElementFactory.getDefaultResource(); // resourceDetails.setName("test5"); // resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts.csar"); }
- */
-
- @Test(enabled = true)
- public void createImportResourceFromCsarDissotiateArtifactFromGroupTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
-
- // create new resource from Csar
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts.csar");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- String invariantUUID = resource.getInvariantUUID();
-
- // add artifact from metadata (resource metadata should be updated)
- // RestResponse addInformationalArtifactToResource =
- // ArtifactRestUtils.addInformationalArtifactToResource(ElementFactory.getDefaultArtifact(),
- // sdncModifierDetails, resourceDetails.getUniqueId());
- // ArtifactRestUtils.checkSuccess(addInformationalArtifactToResource);
- resourceDetails.setName("test4");
- RestResponse updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertEquals(invariantUUID, resource.getInvariantUUID());
-
- // wrong RI (without node types, resource shouldn't be updated)
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_dissociate.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
- // change name (temporary)
- resourceDetails.setName("test4");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertEquals(invariantUUID, resource.getInvariantUUID());
-
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
- }
-
- @Test(enabled = true)
- public void createImportResourceFromCsarNewgroupTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
-
- // create new resource from Csar
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts.csar");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- String invariantUUID = resource.getInvariantUUID();
-
- // update scar
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_UpdateToscaAndArtifacts.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- resourceDetails.setName("test2");
- // change resource metaData (resource should be updated)
- resourceDetails.setDescription("It is new description bla bla bla");
- RestResponse updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
- assertEquals(invariantUUID, resource.getInvariantUUID());
-
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
- }
-
- @Test(enabled = true)
- public void createImportResourceFromCsarGetGroupTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- // RestResponse copyRes =
- // copyCsarRest(sdncModifierDetails,"VF_RI2_G4_withArtifacts_a.csar","VF_RI2_G4_withArtifacts.csar");
-
- // create new resource from Csar
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("VSPPackage");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- String invariantUUID = resource.getInvariantUUID();
- List<GroupDefinition> groups = resource.getGroups();
-
- GroupDefinition groupWithArtifact = groups.stream().filter(p -> p.getArtifacts() != null && !p.getArtifacts().isEmpty()).findFirst().get();
-
- RestResponse groupRest = GroupRestUtils.getGroupById(resource, groupWithArtifact.getUniqueId(), sdncModifierDetails);
- BaseRestUtils.checkSuccess(groupRest);
-
- GroupDefinition groupWithoutArtifact = groups.stream().filter(p -> p.getArtifacts() == null || p.getArtifacts().isEmpty()).findFirst().get();
-
- groupRest = GroupRestUtils.getGroupById(resource, groupWithoutArtifact.getUniqueId(), sdncModifierDetails);
- BaseRestUtils.checkSuccess(groupRest);
- }
-
- @Test(enabled = true)
- public void createImportResourceFromCsarUITest() throws Exception {
- RestResponse getResource = null;
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- String payloadName = "valid_vf.csar";
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
- String rootPath = System.getProperty("user.dir");
- Path path = null;
- byte[] data = null;
- String payloadData = null;
-
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
-
- // create new resource from Csar
- resourceDetails.setCsarUUID(payloadName);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- RestResponse changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // change composition (resource should be updated)
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_b.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- // change name
- resourceDetails.setName("test1");
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(2, resource.getComponentInstances().size());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // change name
- resourceDetails.setName("test2");
- // change resource metaData (resource should be updated)
- resourceDetails.setDescription("It is new description bla bla bla");
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(2, resource.getComponentInstances().size());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // wrong RI (without node types, resource shouldn't be updated)
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_c.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- // change name
- resourceDetails.setName("test3");
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkErrorResponse(createResource, ActionStatus.INVALID_NODE_TEMPLATE, "Definitions/tosca_mock_vf.yaml", "nodejs", "tosca.nodes.Weber");
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(null, resource);
- getResource = ResourceRestUtils.getResourceByNameAndVersion(sdncModifierDetails.getUserId(), "test3", resourceDetails.getVersion());
- BaseRestUtils.checkErrorResponse(getResource, ActionStatus.RESOURCE_NOT_FOUND, "test3");
-
- // create new resource from other Csar
- resourceDetails = ElementFactory.getDefaultImportResource();
- path = Paths.get(rootPath + "/src/main/resources/ci/VF_RI2_G4_withArtifacts.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setPayloadName("VF_RI2_G4_withArtifacts.csar");
- resourceDetails.setName("test4");
- resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts.csar");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // wrong RI (with node types) resource shouldn't be created
- resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts_b.csar");
- path = Paths.get(rootPath + "/src/main/resources/ci/VF_RI2_G4_withArtifacts_b.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setPayloadName("VF_RI2_G4_withArtifacts_b.csar");
- resourceDetails.setName("test5");
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkErrorResponse(createResource, ActionStatus.INVALID_NODE_TEMPLATE, "Definitions/VF_RI2_G1.yaml", "ps04_port_0", "org.openecomp.resource.cp.nodes.heat.network.neutron.Portur");
- }
-
- @Test(enabled = true)
- public void createUpdateImportResourceFromCsarUITest() throws Exception {
- RestResponse getResource = null;
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- String payloadName = "valid_vf.csar";
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
- String rootPath = System.getProperty("user.dir");
- Path path = null;
- byte[] data = null;
- String payloadData = null;
-
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
-
- // create new resource from Csar
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- RestResponse changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // change composition and update resource
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_b.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setUniqueId(resource.getUniqueId());
- // change name
- RestResponse updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resource.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertEquals(2, resource.getComponentInstances().size());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // change name
- resourceDetails.setName("test2");
- // change resource metaData (resource should be updated)
- resourceDetails.setDescription("It is new description bla bla bla");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resource.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertEquals(2, resource.getComponentInstances().size());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // try to update resource with wrong RI (without node types, resource
- // shouldn't be updated)
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_c.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- // change name
- resourceDetails.setName("test3");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resource.getUniqueId());
- BaseRestUtils.checkErrorResponse(updateResource, ActionStatus.INVALID_NODE_TEMPLATE, "Definitions/tosca_mock_vf.yaml", "nodejs", "tosca.nodes.Weber");
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertEquals(null, resource);
- getResource = ResourceRestUtils.getResourceByNameAndVersion(sdncModifierDetails.getUserId(), "test3", resourceDetails.getVersion());
- BaseRestUtils.checkErrorResponse(getResource, ActionStatus.RESOURCE_NOT_FOUND, "test3");
- }
-
- @Test(enabled = true)
- public void createUpdateImportResourceFromCsarTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = null;
- RestResponse getResource = null;
- ResourceReqDetails resourceDetails = null;
- RestResponse updateResource = null;
- RestResponse createResource = null;
- Resource resource = null;
- RestResponse changeResourceState = null;
-
- // create new resource from Csar
- copyRes = copyCsarRest(sdncModifierDetails, "valid_vf_a.csar", "valid_vf.csar");
- resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("valid_vf.csar");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
- String invariantUUID = resource.getInvariantUUID();
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // change composition and update resource
- copyRes = copyCsarRest(sdncModifierDetails, "valid_vf_b.csar", "valid_vf.csar");
- BaseRestUtils.checkSuccess(copyRes);
- // change name
- resourceDetails.setName("test1");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resource.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertEquals(2, resource.getComponentInstances().size());
- assertEquals(invariantUUID, resource.getInvariantUUID());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "valid_vf_a.csar", "valid_vf.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- // change name
- resourceDetails.setName("test2");
- // change resource metaData and update resource
- resourceDetails.setDescription("It is new description bla bla bla");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resource.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
- assertEquals(invariantUUID, resource.getInvariantUUID());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "valid_vf_a.csar", "valid_vf.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- // try to update resource with wrong RI (without node types, resource
- // shouldn't be updated)
- copyRes = copyCsarRest(sdncModifierDetails, "valid_vf_c.csar", "valid_vf.csar");
- BaseRestUtils.checkSuccess(copyRes);
- // change name (temporary)
- resourceDetails.setName("test3");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resource.getUniqueId());
- BaseRestUtils.checkErrorResponse(updateResource, ActionStatus.INVALID_NODE_TEMPLATE, "Definitions/tosca_mock_vf.yaml", "nodejs", "tosca.nodes.Weber");
-
- getResource = ResourceRestUtils.getResourceByNameAndVersion(sdncModifierDetails.getUserId(), "test3", resourceDetails.getVersion());
- BaseRestUtils.checkErrorResponse(getResource, ActionStatus.RESOURCE_NOT_FOUND, "test3");
- getResource = ResourceRestUtils.getResourceByNameAndVersion(sdncModifierDetails.getUserId(), "test2", resourceDetails.getVersion());
- BaseRestUtils.checkSuccess(getResource);
-
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "valid_vf_a.csar", "valid_vf.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- // create new resource from Csar
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("TEST01");
- resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts.csar");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // scar with wrong RI
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_b.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
- resourceDetails.setDescription("BLA BLA BLA");
- // wrong RI (with node types) resource shouldn't be created
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId());
- BaseRestUtils.checkErrorResponse(updateResource, ActionStatus.INVALID_NODE_TEMPLATE, "Definitions/VF_RI2_G1.yaml", "ps04_port_0", "org.openecomp.resource.cp.nodes.heat.network.neutron.Portur");
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
- }
-
- @Test(enabled = true)
- public void createUpdateImportResourceFromCsarWithArtifactsTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = null;
- ResourceReqDetails resourceDetails = null;
- RestResponse updateResource = null;
- RestResponse createResource = null;
- Resource resource = null;
- RestResponse changeResourceState = null;
-
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("TEST01");
- resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts.csar");
- resourceDetails.setCsarVersion("1");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- // create new resource from Csar
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
- List<String> requiredArtifactsOld = resource.getDeploymentArtifacts().get("heat5").getRequiredArtifacts();
- assertTrue(requiredArtifactsOld != null && !requiredArtifactsOld.isEmpty() && requiredArtifactsOld.size() == 3);
- assertTrue(requiredArtifactsOld.contains("hot-nimbus-pcm-volumes_v1.0.yaml"));
- assertTrue(requiredArtifactsOld.contains("nested-pcm_v1.0.yaml"));
- assertTrue(requiredArtifactsOld.contains("hot-nimbus-oam-volumes_v1.0.yaml"));
-
- // update scar with new artifacts
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_updated.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
- resourceDetails.setDescription("BLA BLA BLA");
- resourceDetails.setCsarVersion("2");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
-
- List<String> requiredArtifactsNew = resource.getDeploymentArtifacts().get("heat5").getRequiredArtifacts();
- assertTrue(requiredArtifactsNew != null && !requiredArtifactsNew.isEmpty() && requiredArtifactsNew.size() == 3);
- assertTrue(requiredArtifactsNew.contains("hot-nimbus-swift-container_v1.0.yaml"));
- assertTrue(requiredArtifactsNew.contains("hot-nimbus-oam-volumes_v1.0.yaml"));
- assertTrue(requiredArtifactsNew.contains("nested-oam_v1.0.yaml"));
-
- // back original scar
- copyRes = copyCsarRest(sdncModifierDetails, "VF_RI2_G4_withArtifacts_a.csar", "VF_RI2_G4_withArtifacts.csar");
- BaseRestUtils.checkSuccess(copyRes);
- }
-
- @Test(enabled = true)
- public void createUpdateImportWithPropertiesFromCsarUITest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- String payloadName = "valid_vf.csar";
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
- String rootPath = System.getProperty("user.dir");
- Path path = null;
- byte[] data = null;
- String payloadData = null;
-
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
-
- // create new resource from Csar
- resourceDetails.setCsarUUID(payloadName);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- RestResponse changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // change composition (add new RI with specified property values)
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_d.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- // change name
- resourceDetails.setName("test1");
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(6, resource.getComponentInstances().size());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- // change composition (add new specified property values to existing RI)
- path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_f.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- // change name
- resourceDetails.setName("test2");
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(6, resource.getComponentInstances().size());
-
- }
-
- public static RestResponse copyCsarRest(User sdncModifierDetails, String sourceCsarUuid, String targetCsarUuid) throws Exception {
-
- Config config = Utils.getConfig();
- String url = String.format(Urls.COPY_CSAR_USING_SIMULATOR, config.getCatalogBeHost(), config.getCatalogBePort(), sourceCsarUuid, targetCsarUuid);
- String userId = sdncModifierDetails.getUserId();
- Map<String, String> headersMap = prepareHeadersMap(userId);
- HttpRequest http = new HttpRequest();
-
- RestResponse copyCsarResponse = http.httpSendPost(url, "dummy", headersMap);
- if (copyCsarResponse.getErrorCode() != 200) {
- return null;
- }
- return copyCsarResponse;
-
- }
-
- public static RestResponse getCsarRest(User sdncModifierDetails, String sourceCsarUuid) throws Exception {
-
- Config config = Utils.getConfig();
- String url = String.format(Urls.GET_CSAR_USING_SIMULATOR, config.getCatalogBeHost(), config.getCatalogBePort(), sourceCsarUuid);
- String userId = sdncModifierDetails.getUserId();
- Map<String, String> headersMap = prepareHeadersMap(userId);
- HttpRequest http = new HttpRequest();
-
- RestResponse copyCsarResponse = http.httpSendGet(url, headersMap);
- if (copyCsarResponse.getErrorCode() != 200) {
- return null;
- }
- return copyCsarResponse;
-
- }
-
- @Test(enabled = true)
- public void updateResourceFromCsarHappy() throws Exception {
- RestResponse copyRes = copyCsarRest(ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), "valid_vf_a.csar", "valid_vf.csar");
- BaseRestUtils.checkSuccess(copyRes);
- // create
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("valid_vf");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- String expectedCsarUUID = resourceDetails.getCsarUUID();
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, resource.getCsarUUID()), expectedCsarUUID.equals(resource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getResource(resource.getUniqueId());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, getResource.getCsarUUID()), expectedCsarUUID.equals(getResource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
-
- RestResponse updateResource = ResourceRestUtils.updateResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
-
- }
-
- @Test(enabled = true)
- public void createResourceFromCsarWithGroupsHappy() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csarWithGroups");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
-
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- assertEquals("verify there are 2 groups", 2, resource.getGroups().size());
-
- Map<String, String> compNameToUniqueId = resource.getComponentInstances().stream().collect(Collectors.toMap(p -> p.getName(), p -> p.getUniqueId()));
-
- // Verify 2 members on group1
- // members: [ app_server, mongo_server ]
- String[] membersNameGroup1 = { "app_server", "mongo_server" };
- verifyMembersInResource(resource, compNameToUniqueId, "group1", membersNameGroup1);
- // Verify 4 members on group2
- // members: [ mongo_db, nodejs, app_server, mongo_server ]
- String[] membersNameGroup2 = { "app_server", "mongo_server", "mongo_db", "nodejs" };
- verifyMembersInResource(resource, compNameToUniqueId, "group2", membersNameGroup2);
-
- // Check OUT
- resourceDetails.setUniqueId(resource.getUniqueId());
- RestResponse changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- changeResourceState = LifecycleRestUtils.changeResourceState(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
-
- Resource checkedOutResource = ResponseParser.parseToObjectUsingMapper(changeResourceState.getResponse(), Resource.class);
- compNameToUniqueId = checkedOutResource.getComponentInstances().stream().collect(Collectors.toMap(p -> p.getName(), p -> p.getUniqueId()));
-
- // Verify 2 members on group1
- // members: [ app_server, mongo_server ]
- verifyMembersInResource(checkedOutResource, compNameToUniqueId, "group1", membersNameGroup1);
- // Verify 4 members on group2
- // members: [ mongo_db, nodejs, app_server, mongo_server ]
- verifyMembersInResource(checkedOutResource, compNameToUniqueId, "group2", membersNameGroup2);
-
- }
-
- private void verifyMembersInResource(Resource resource, Map<String, String> compNameToUniqueId, String groupName, String[] membersName) {
- GroupDefinition groupDefinition = resource.getGroups().stream().filter(p -> p.getName().equals(groupName)).findFirst().get();
- assertEquals("Verify number of members", membersName.length, groupDefinition.getMembers().size());
- Map<String, String> createdMembers = groupDefinition.getMembers();
- Arrays.asList(membersName).forEach(p -> {
- assertTrue("check member name exist", createdMembers.containsKey(p));
- });
-
- verifyMembers(createdMembers, compNameToUniqueId);
- }
-
- @Test(enabled = true)
- public void createResourceFromCsarWithGroupsAndPropertiesHappy() throws Exception {
-
- RestResponse importNewGroupTypeByName = ImportRestUtils.importNewGroupTypeByName("myHeatStack1", UserRoleEnum.ADMIN);
- // BaseRestUtils.checkCreateResponse(importNewGroupTypeByName);
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csarWithGroupsWithProps");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
-
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
-
- assertEquals("verify there are 2 groups", 2, resource.getGroups().size());
-
- Map<String, String> compNameToUniqueId = resource.getComponentInstances().stream().collect(Collectors.toMap(p -> p.getName(), p -> p.getUniqueId()));
-
- // Verify 2 members on group1
- // members: [ app_server, mongo_server ]
- List<GroupDefinition> groupDefinition1 = resource.getGroups().stream().filter(p -> p.getName().equals("group1")).collect(Collectors.toList());
- assertEquals("Verify number of members", 2, groupDefinition1.get(0).getMembers().size());
- Map<String, String> createdMembers = groupDefinition1.get(0).getMembers();
- verifyMembers(createdMembers, compNameToUniqueId);
-
- List<PropertyDataDefinition> properties = groupDefinition1.get(0).getProperties();
- assertEquals("Verify number of members", 2, properties.size());
-
- PropertyDataDefinition heatFiles = properties.stream().filter(p -> p.getName().equals("heat_files")).findFirst().get();
- assertNotNull("check heat files not empty", heatFiles);
- List<String> heatFilesValue = new ArrayList<>();
- heatFilesValue.add("heat1.yaml");
- heatFilesValue.add("heat2.yaml");
- String heatFilesJson = gson.toJson(heatFilesValue);
- log.debug(heatFiles.getValue());
- assertEquals("check heat files value", heatFilesJson, heatFiles.getValue());
-
- PropertyDataDefinition urlCredential = properties.stream().filter(p -> p.getName().equals("url_credential")).findFirst().get();
- assertNotNull("check heat files not empty", urlCredential);
- log.debug(urlCredential.getValue());
- assertEquals("check url credential", "{\"protocol\":\"protocol1\",\"keys\":{\"keya\":\"valuea\",\"keyb\":\"valueb\"}}", urlCredential.getValue());
- }
-
- @Test(enabled = true)
- public void createResourceFromCsarWithGroupsAndPropertyInvalidValue() throws Exception {
-
- RestResponse importNewGroupTypeByName = ImportRestUtils.importNewGroupTypeByName("myHeatStack1", UserRoleEnum.ADMIN);
- // BaseRestUtils.checkCreateResponse(importNewGroupTypeByName);
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csarWithGroupsInvalidPropertyValue");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- BaseRestUtils.checkStatusCode(createResource, "Check bad request error", false, 400);
-
- }
-
- @Test(enabled = true)
- public void createResourceFromCsarWithGroupsAndInvalidPropertyName() throws Exception {
-
- RestResponse importNewGroupTypeByName = ImportRestUtils.importNewGroupTypeByName("myHeatStack1", UserRoleEnum.ADMIN);
- // BaseRestUtils.checkCreateResponse(importNewGroupTypeByName);
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csarWithGroupsPropertyNotExist");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- BaseRestUtils.checkStatusCode(createResource, "Check bad request error", false, 400);
- BaseRestUtils.checkErrorResponse(createResource, ActionStatus.GROUP_PROPERTY_NOT_FOUND, "url_credential111", "group1", "org.openecomp.groups.MyHeatStack1");
-
- }
-
- @Test(enabled = true)
- public void createResourceFromCsarGroupTypeNotExist() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csarWithGroupsInvalidGroupType");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- BaseRestUtils.checkStatusCode(createResource, "Check bad request error", false, 400);
- BaseRestUtils.checkErrorResponse(createResource, ActionStatus.GROUP_TYPE_IS_INVALID, "org.openecomp.groups.stamGroupType");
-
- }
-
- @Test(enabled = true)
- public void createResourceFromCsarMemberNotExist() throws Exception {
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csarWithGroupsInvalidMember");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- BaseRestUtils.checkStatusCode(createResource, "Check bad request error", false, 400);
- BaseRestUtils.checkErrorResponse(createResource, ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, "mycomp", "mygroup", ValidationUtils.normaliseComponentName(resourceDetails.getName()), "VF");
-
- }
-
- @Test(enabled = true)
- public void createResourceFromCsarMemberNotAllowed() throws Exception {
-
- RestResponse importNewGroupTypeByName = ImportRestUtils.importNewGroupTypeByName("myHeatStack2", UserRoleEnum.ADMIN);
-
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csarWithGroupsNotAllowedMember");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- BaseRestUtils.checkStatusCode(createResource, "Check bad request error", false, 400);
- BaseRestUtils.checkErrorResponse(createResource, ActionStatus.GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE, "nodejs", "group1", "org.openecomp.groups.MyHeatStack2");
-
- }
-
- @Test(enabled = true)
- public void getResourceFromCsarUuidHappy() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("tam");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(6, resource.getComponentInstances().size());
-
- String expectedCsarUUID = resourceDetails.getCsarUUID();
- String expectedToscaResourceName = "org.openecomp.resource.vf." + WordUtils.capitalize(resourceDetails.getName().toLowerCase());
-
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, resource.getCsarUUID()), expectedCsarUUID.equals(resource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, resource.getToscaResourceName()), expectedToscaResourceName.equals(resource.getToscaResourceName()));
-
- RestResponse getResourceResponse = ResourceRestUtils.getLatestResourceFromCsarUuid(resource.getCsarUUID());
- Resource getResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), Resource.class);
- assertTrue("csarUUID : " + buildAssertMessage(expectedCsarUUID, getResource.getCsarUUID()), expectedCsarUUID.equals(getResource.getCsarUUID()));
- assertTrue("toscaResourceName : " + buildAssertMessage(expectedToscaResourceName, getResource.getToscaResourceName()), expectedToscaResourceName.equals(getResource.getToscaResourceName()));
- }
-
- @Test(enabled = true)
- public void getResourceFromCsarResourceNotFound() throws Exception {
- String csarUUID = "tam";
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID(csarUUID);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
-
- RestResponse resResponse = ResourceRestUtils.getLatestResourceFromCsarUuid(csarUUID);
-
- BaseRestUtils.checkStatusCode(resResponse, "Check bad request error", false, 400);
- BaseRestUtils.checkErrorResponse(resResponse, ActionStatus.RESOURCE_FROM_CSAR_NOT_FOUND, csarUUID);
-
- }
-
- @Test(enabled = true)
- public void getResourceFromMissingCsar() throws Exception {
- String csarUUID = "abcdefg12345";
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID(csarUUID);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
-
- RestResponse resResponse = ResourceRestUtils.getLatestResourceFromCsarUuid(csarUUID);
-
- BaseRestUtils.checkStatusCode(resResponse, "Check bad request error", false, 400);
- BaseRestUtils.checkErrorResponse(resResponse, ActionStatus.RESOURCE_FROM_CSAR_NOT_FOUND, csarUUID);
-
- }
-
- @Test(enabled = true)
- public void createUpdateCertifiedImportResourceFromCsarTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes = copyCsarRest(sdncModifierDetails, "valid_vf_a.csar", "valid_vf.csar");
- RestResponse updateResponse = null;
- String oldName = null;
- // create new resource from Csar
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("valid_vf.csar");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
- String invariantUUID = resource.getInvariantUUID();
-
- // change metadata
- // resource name, icon, vendor name, category, template derivedFrom
- oldName = resourceDetails.getName();
- resourceDetails.setName("test1");
- resourceDetails.setIcon("newicon");
- resourceDetails.setVendorName("newname");
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkErrorResponse(createResource, ActionStatus.VSP_ALREADY_EXISTS, "valid_vf.csar", oldName);
-
- updateResponse = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResponse);
-
- LifecycleRestUtils.certifyResource(resourceDetails);
- // change metadata
- // resource name, icon, vendor name, category, template derivedFrom
- resourceDetails.setName("test2");
- resourceDetails.setIcon("new icon1");
- resourceDetails.setVendorName("new name1");
- resourceDetails.setDescription("bla bla bla");
- updateResponse = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails, resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResponse);
- resource = ResponseParser.parseToObjectUsingMapper(updateResponse.getResponse(), Resource.class);
- assertEquals(5, resource.getComponentInstances().size());
- assertEquals(invariantUUID, resource.getInvariantUUID());
- assertEquals(resource.getName(), "test1");
- assertEquals(resource.getIcon(), "newicon");
- assertEquals(resource.getVendorName(), "newname");
- assertEquals(resource.getDescription(), "bla bla bla");
- assertEquals(resource.getTags().contains("test2"), false);
- }
-
- @Test
- public void createImportRIRelationByCapNameFromCsarUITest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- String payloadName = "vmmc_relate_by_cap_name.csar";
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
- String rootPath = System.getProperty("user.dir");
- Path path = null;
- byte[] data = null;
- String payloadData = null;
-
- path = Paths.get(rootPath + "/src/test/resources/CI/csars/vmmc_relate_by_cap_name.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
-
- // create new resource from Csar
- resourceDetails.setCsarUUID(payloadName);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- // assert all relations created
- assertEquals(80, resource.getComponentInstancesRelations().size());
- }
-
- @Test
- public void createImportRIRelationByCapNameFromCsarUITest2() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- String payloadName = "vf_relate_by_cap_name.csar";
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
- String rootPath = System.getProperty("user.dir");
- Path path = null;
- byte[] data = null;
- String payloadData = null;
-
- path = Paths.get(rootPath + "/src/test/resources/CI/csars/vf_relate_by_cap_name.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
-
- // create new resource from Csar
- resourceDetails.setCsarUUID(payloadName);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- // assert relations created: 1.by name: virtual_linkable. 2.by name:
- // link
- Map<String, ComponentInstance> nodes = resource.getComponentInstances().stream().collect(Collectors.toMap(n -> n.getName(), n -> n));
- Map<String, CapabilityDefinition> capabilities = nodes.get("elinenode").getCapabilities().get("tosca.capabilities.network.Linkable").stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
- String cp1Uid = nodes.get("cp1node").getUniqueId();
- String cp2Uid = nodes.get("cp2node").getUniqueId();
- Map<String, List<RequirementCapabilityRelDef>> mappedByReqOwner = resource.getComponentInstancesRelations().stream().collect(Collectors.groupingBy(e -> e.getFromNode()));
- assertEquals(mappedByReqOwner.get(cp1Uid).get(0).getRelationships().get(0).getRelation().getCapabilityUid(), capabilities.get("virtual_linkable").getUniqueId());
- assertEquals(mappedByReqOwner.get(cp2Uid).get(0).getRelationships().get(0).getRelation().getCapabilityUid(), capabilities.get("link").getUniqueId());
- }
-
- @Test(enabled = true)
- public void importCsarCheckVfHeatEnv() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("csar_1");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
-
- Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts();
- assertNotNull(deploymentArtifacts);
- // 2 lisence, 1 heat, 1 heatenv
- assertEquals(4, deploymentArtifacts.size());
-
- ArtifactDefinition artifactHeat = deploymentArtifacts.get("heat0");
- assertNotNull(artifactHeat);
-
- ArtifactDefinition artifactHeatEnv = deploymentArtifacts.get("heat0env");
- assertNotNull(artifactHeatEnv);
-
- assertEquals(artifactHeat.getUniqueId(), artifactHeatEnv.getGeneratedFromId());
- assertEquals("VF HEAT ENV", artifactHeatEnv.getArtifactDisplayName());
- assertEquals("HEAT_ENV", artifactHeatEnv.getArtifactType());
- assertEquals("VF Auto-generated HEAT Environment deployment artifact", artifactHeatEnv.getDescription());
-
- String designerUserId = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId();
- String testerUserId = ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId();
- RestResponse lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
-/* lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.STARTCERTIFICATION);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);*/
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.CERTIFY);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(lifecycleChangeResponse.getResponse(), Resource.class);
-
-
- User modifier = new User();
- modifier.setUserId(designerUserId);
-
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(
- "newtestservice1", ServiceCategoriesEnum.MOBILITY, designerUserId,
- ServiceInstantiationType.A_LA_CARTE.getValue());
-
- RestResponse serviceRes = ServiceRestUtils.createService(serviceDetails, modifier);
- ResourceRestUtils.checkCreateResponse(serviceRes);
- Service service = ResponseParser.parseToObjectUsingMapper(serviceRes.getResponse(), Service.class);
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory.getComponentInstance(certifiedResource);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails, modifier, service.getUniqueId(), service.getComponentType());
- BaseRestUtils.checkCreateResponse(createResourceInstanceResponse);
- RestResponse serviceByGet = ServiceRestUtils.getService(service.getUniqueId());
- service = ResponseParser.parseToObjectUsingMapper(serviceByGet.getResponse(), Service.class);
-
- List<ComponentInstance> componentInstances = service.getComponentInstances();
- assertNotNull(componentInstances);
-
- assertEquals(1, componentInstances.size());
- ComponentInstance ci = componentInstances.get(0);
- Map<String, ArtifactDefinition> instDepArtifacts = ci.getDeploymentArtifacts();
- assertNotNull(instDepArtifacts);
- ArtifactDefinition instArtifactHeat = instDepArtifacts.get("heat0");
- assertNotNull(instArtifactHeat);
-
- ArtifactDefinition instArtifactHeatEnv = instDepArtifacts.get("heat0env");
- assertNotNull(instArtifactHeatEnv);
- assertEquals(artifactHeat.getUniqueId(), instArtifactHeatEnv.getGeneratedFromId());
- assertEquals("HEAT ENV", instArtifactHeatEnv.getArtifactDisplayName());
- assertEquals("HEAT_ENV", instArtifactHeatEnv.getArtifactType());
-
- assertEquals(artifactHeat.getUniqueId(), instArtifactHeat.getUniqueId());
- //different artifacts
- assertTrue( !artifactHeatEnv.getUniqueId().equals(instArtifactHeat.getUniqueId()) );
-
-
- }
-
- @Test(enabled = true)
- public void createAndUpdateCsarCheckVfHeatEnv() throws Exception {
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setCsarUUID("orig2G_org");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
-
- Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts();
- assertNotNull(deploymentArtifacts);
-
- assertEquals(13, deploymentArtifacts.size());
-
- ArtifactDefinition artifactHeat = deploymentArtifacts.get("heat0");
- assertNotNull(artifactHeat);
-
- ArtifactDefinition artifactHeatEnv = deploymentArtifacts.get("heat0env");
- assertNotNull(artifactHeatEnv);
-
- assertEquals(artifactHeat.getUniqueId(), artifactHeatEnv.getGeneratedFromId());
- assertEquals("VF HEAT ENV", artifactHeatEnv.getArtifactDisplayName());
- assertEquals("HEAT_ENV", artifactHeatEnv.getArtifactType());
- assertEquals("VF Auto-generated HEAT Environment deployment artifact", artifactHeatEnv.getDescription());
-
- List<GroupDefinition> groups = resource.getGroups();
- assertEquals(2, groups.size());
- GroupDefinition group1 = groups.stream().filter(p -> p.getName().contains("module-0")).findAny().get();
- GroupDefinition group2 = groups.stream().filter(p -> p.getName().contains("module-1")).findAny().get();
- assertEquals(11, group1.getArtifacts().size());
- assertEquals(3, group2.getArtifacts().size());
-
- resourceDetails.setCsarUUID("orig2G_update");
-
- RestResponse updateResource = ResourceRestUtils.updateResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
-
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
-
-
- Map<String, ArtifactDefinition> deploymentArtifactsUpd = resource.getDeploymentArtifacts();
- assertNotNull(deploymentArtifactsUpd);
-
- assertEquals(13, deploymentArtifactsUpd.size());
-
- ArtifactDefinition artifactHeatUpd = deploymentArtifacts.get("heat0");
- assertNotNull(artifactHeatUpd);
-
- ArtifactDefinition artifactHeatEnvUpd = deploymentArtifacts.get("heat0env");
- assertNotNull(artifactHeatEnvUpd);
-
- groups = resource.getGroups();
- assertEquals(2, groups.size());
- assertEquals(7, groups.get(0).getArtifacts().size());
- assertEquals(7, groups.get(1).getArtifacts().size());
-
-
- }
-
- @Test
- public void importInnerVfcWithArtifactsSucceed() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- String rootPath = System.getProperty("user.dir");
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
-
- String payloadName = "ImportArtifactsToVFC.csar";
- Path path = Paths.get(rootPath + "/src/test/resources/CI/csars/ImportArtifactsToVFC.csar");
- byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
-
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
- List<ComponentInstance> componentInstances = resource.getComponentInstances();
- List<ComponentInstance> reducedComponentInstances = componentInstances.stream()
- .filter(ci->ci.getNormalizedName().contains("server_sm"))
- .collect(Collectors.toList());
- assertTrue(!reducedComponentInstances.isEmpty() && reducedComponentInstances.size() == 2);
- reducedComponentInstances.stream().forEach(ci->isValidArtifacts(ci));
-
- payloadName = "ImportArtifactsToVFC_empty.csar";
- path = Paths.get(rootPath + "/src/test/resources/CI/csars/ImportArtifactsToVFC_empty.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setName(resourceDetails.getName()+"2");
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
-
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
- componentInstances = resource.getComponentInstances();
- reducedComponentInstances = componentInstances.stream()
- .filter(ci->ci.getNormalizedName().contains("server_sm"))
- .collect(Collectors.toList());
- assertTrue(!reducedComponentInstances.isEmpty() && reducedComponentInstances.size() == 2);
- reducedComponentInstances.stream()
- .forEach(ci->assertTrue(
- (ci.getDeploymentArtifacts()==null || ci.getDeploymentArtifacts().isEmpty()) &&
- (ci.getArtifacts()==null || ci.getArtifacts().isEmpty()))
- );
- }
-
- private void isValidArtifacts(ComponentInstance ci) {
- assertTrue(!ci.getDeploymentArtifacts().isEmpty() && ci.getDeploymentArtifacts().size() == 11);
- ci.getDeploymentArtifacts().values().stream()
- .forEach(a->assertTrue(a.getArtifactName().startsWith("Some")));
-
- assertTrue(!ci.getArtifacts().isEmpty() && ci.getArtifacts().size() == 1);
- ci.getArtifacts().values().stream()
- .forEach(a->assertTrue(a.getArtifactName().startsWith("Process")));
- }
-
- private void verifyMembers(Map<String, String> createdMembers, Map<String, String> compNameToUniqueId) {
- for (Map.Entry<String, String> entry : createdMembers.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- String comparedValue = compNameToUniqueId.get(key);
-
- assertEquals("compare instance ids", comparedValue, value);
- }
-
- }
-
- private static Map<String, String> prepareHeadersMap(String userId) {
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
- if (userId != null) {
- headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId);
- }
- return headersMap;
- }
-
-}
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
deleted file mode 100644
index f529f00cf9..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java
+++ /dev/null
@@ -1,1511 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.imports;
-
-import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.HttpStatus;
-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.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-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.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.*;
-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;
-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.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.validation.AuditValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
-import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.util.GeneralUtility;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-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();
-
- 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 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);
-
- System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode());
-
- }
-
- 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"));
- }
-
- // @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);
-
- }
-
- 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"));
-
- }
-}
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
deleted file mode 100644
index 7338645f57..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java
+++ /dev/null
@@ -1,2871 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.imports;
-
-import org.apache.http.client.ClientProtocolException;
-import org.junit.Rule;
-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.elements.SchemaDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-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;
-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.*;
-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;
-import org.openecomp.sdc.ci.tests.utils.DbUtils;
-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.*;
-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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.AssertJUnit;
-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
- *
- */
-
-public class ImportToscaResourceTest extends ComponentBaseTest {
- private static Logger logger = LoggerFactory.getLogger(ImportToscaResourceTest.class.getName());
- protected Utils utils = new Utils();
-
- public ImportToscaResourceTest() {
- super(name, ImportToscaResourceTest.class.getName());
- }
-
- public ImportReqDetails importReqDetails;
- protected static User sdncUserDetails;
- protected static User testerUser;
- protected String testResourcesPath;
- protected ResourceReqDetails resourceDetails;
- private HashSet<String> capabilitySources;
- private int actualNumOfReqOrCap;
-
- @Rule
- public static TestName name = new TestName();
-
- @BeforeMethod
- public void before() throws Exception {
- importReqDetails = ElementFactory.getDefaultImportResource();
- sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- testerUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- resourceDetails = ElementFactory.getDefaultResource();
- String sourceDir = config.getResourceConfigDir();
- final String workDir = "importToscaResourceByCreateUrl";
- testResourcesPath = sourceDir + File.separator + workDir;
- capabilitySources = new HashSet<String>();
- actualNumOfReqOrCap = 0;
- }
-
- @DataProvider
- private static final Object[][] getYmlWithInValidListProperties() throws IOException, Exception {
- return new Object[][] { { "ListPropertyFalure02.yml", "[false,\"truee\"]", "boolean" },
- { "ListPropertyFalure03.yml", "[false,3]", "boolean" },
- { "ListPropertyFalure04.yml", "[false,3.56]", "boolean" },
- { "ListPropertyFalure05.yml", "[10000,3.56]", "integer" },
- { "ListPropertyFalure06.yml", "[10000,\"aaaa\"]", "integer" },
- { "ListPropertyFalure07.yml", "[10000,true]", "integer" },
- { "ListPropertyFalure08.yml", "[10.5,true]", "float" },
- { "ListPropertyFalure09.yml", "[10.5,\"asdc\"]", "float" }, // type
- // float
- { "ListPropertyFalure11.yml", "[10.5,\"500.0@\"]", "float" }, // property
- // list
- // float
- // type
- // contain
- // @
- // in
- // default
- // value
- { "ListPropertyFalure12.yml", "[10000,\"3#\"]", "integer" }, // property
- // list
- // integer
- // type
- // contain
- // #
- // in
- // default
- // value
- { "ListPropertyFalure13.yml", "[false,\"true%\"]", "boolean" }, // property
- // list
- // boolean
- // type
- // contain
- // %
- // in
- // default
- // value
- { "ListPropertyFalure14.yml", "[false,\"falsee\",true]", "boolean" },
- { "ListPropertyFalure15.yml", "[10.5,\"10.6x\",20.5,30.5]", "float" } // float
- // with
- // value
- // 10.6x
- // instead
- // 10.6f
-
- };
- }
-
- @DataProvider
- private static final Object[][] getYmlWithInValidMapProperties() throws IOException, Exception {
- return new Object[][] { { "MapPropertyFalure02.yml", "[false,\"truee\"]", "boolean" },
- { "MapPropertyFalure03.yml", "[false,3]", "boolean" },
- { "MapPropertyFalure04.yml", "[false,3.56]", "boolean" },
- { "MapPropertyFalure05.yml", "[10000,3.56]", "integer" },
- { "MapPropertyFalure06.yml", "[10000,\"aaaa\"]", "integer" },
- { "MapPropertyFalure07.yml", "[10000,true]", "integer" },
- { "MapPropertyFalure08.yml", "[10.5,true]", "float" },
- { "MapPropertyFalure09.yml", "[10.5,\"asdc\"]", "float" }, // type
- // float
- { "MapPropertyFalure11.yml", "[10.5,\"500.0@\"]", "float" }, // property
- // list
- // float
- // type
- // contain
- // @
- // in
- // default
- // value
- { "MapPropertyFalure12.yml", "[10000,\"3#\"]", "integer" }, // property
- // list
- // integer
- // type
- // contain
- // #
- // in
- // default
- // value
- { "MapPropertyFalure13.yml", "[false,\"true%\"]", "boolean" }, // property
- // list
- // boolean
- // type
- // contain
- // %
- // in
- // default
- // value
- { "MapPropertyFalure14.yml", "[false,\"falsee\",true]", "boolean" },
- { "MapPropertyFalure15.yml", "[10.5,\"10.6x\",20.5,30.5]", "float" } // float
- // with
- // value
- // 10.6x
- // instead
- // 10.6f
-
- };
- }
-
- @DataProvider
- private static final Object[][] getYmlWithInValidOccurrences() throws IOException, Exception {
- return new Object[][] { { "occurencyFalure01.yml" }, // requirements [2
- // , 0]
- { "occurencyFalure02.yml" }, // requirements [-1, 2]
- { "occurencyFalure03.yml" }, // requirements [1 ,-2]
- { "occurencyFalure05.yml" }, // requirements MAX occurrences not
- // exist [ 1 , ]
- { "occurencyFalure06.yml" }, // requirements [ 0 , 0 ]
- { "occurencyFalure08.yml" }, // requirements [ 1.0 , 2.0 ]
- { "occurencyFalure09.yml" }, // requirements [ "1" , "2" ]
- { "occurencyFalure10.yml" }, // requirements [ ]
- { "occurencyFalure11.yml" }, // requirements [ UNBOUNDED ,
- // UNBOUNDED ]
- { "occurencyFalure31.yml" }, // capability [ 2, 1]
- { "occurencyFalure32.yml" }, // capability [-1, 2]
- { "occurencyFalure33.yml" }, // capability [1, -2]
- { "occurencyFalure35.yml" }, // capability MAX occurrences not
- // exist [ 1 , ]
- { "occurencyFalure36.yml" }, // capability [ 0 , 0 ]
- { "occurencyFalure38.yml" }, // capability [ 1.0 , 2.0 ]
- { "occurencyFalure39.yml" }, // capability [ "1" , "2" ]
- { "occurencyFalure40.yml" }, // capability [ ]
- { "occurencyFalure41.yml" } // capability [ UNBOUNDED ,
- // UNBOUNDED ]
- };
- }
-
- @DataProvider
- private static final Object[][] getInvalidYmlWithOccurrences() throws IOException, Exception {
- return new Object[][] { { "occurencyFalure04.yml" }, // requirements MIN
- // occurrences
- // not exist [ ,
- // 1]
- { "occurencyFalure07.yml" }, // requirements [ @ , 1 ]
- { "occurencyFalure34.yml" }, // capability MIN occurrences not
- // exist [ , 1]
- { "occurencyFalure37.yml" } // capability [ 0 , # ]
-
- };
- }
-
- // US656928
- protected final String importMapPropertySuccess = "importMapPropertySuccessFlow.yml";
- protected final String importAttributeSuccess = "importAttributeSuccessFlow.yml";
- protected final String importSuccessFile = "myCompute.yml";
- protected final String derivedFromMyCompute = "derivedFromMyCompute.yml";
- protected final String importSuccessVFFile = "myComputeVF.yml";
- protected final String importNoDerivedFromFile = "myComputeDerivedFromNotExists.yml";
- protected final String importInvalidDefinitionVersionFile = "myComputeIncorrectDefenitionVersionValue.yml";
- protected final String importIncorrectNameSpaceFormatFile = "myComputeIncorrectNameSpaceFormat.yml";
- protected final String importNoDefenitionVersionFile = "myComputeNoDefenitionVersion.yml";
- protected final String importNodeTypesTwiceFile = "myComputeWithNodeTypesTwice.yml";
- protected final String importTopologyTemplateFile = "myComputeWithTopologyTemplate.yml";
- protected final String importNoContentFile = "noContent.yml";
- protected final String importWithOccurrences = "myComputeOccurencySuccess.yml";
- protected final String importListPropertyBadDefault = "importListPropertyBadDefault.yml";
- protected final String importListPropertyGoodDefault = "importListPropertyGoodDefault.yml";
- protected final String importListPropertySuccess = "importListPropertySuccessFlow.yml";
- // US631462
- protected final String importDuplicateRequirements = "importDuplicateRequirements.yml";
- protected final String importDuplicateCapability = "importDuplicateCapability.yml";
- protected final String importCapabilityNameExistsOnParent = "importCapabilityNameExistsOnParent.yml";
- protected final String importRequirementNameExistsOnParent = "importRequirementNameExistsOnParent.yml";
- protected final String importToscaResourceReqCapDerivedFromParent = "derivedFromWebAppDerivedReqCap.yml";
- protected final String missingCapInReqDef = "missingCapInReqDefinition.yml";
- protected final String missingCapInCapDef = "missingCapInCapDefinition.yml";
-
- // US558432 - Support for Capability/Requirement "occurences" Import
- @Test(dataProvider = "getYmlWithInValidOccurrences")
- public void importToscaResourceWithOccurrencesFailuresFlow01(String ymlFileWithInvalidCapReqOccurrences)
- throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFileWithInvalidCapReqOccurrences);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_OCCURRENCES.name(), new ArrayList<String>(),
- importResourceResponse.getResponse());
- }
-
- @Test(dataProvider = "getInvalidYmlWithOccurrences")
- public void importToscaResourceWithOccurrencesFailuresFlow02(String ymlFileWithInvalidCapReqOccurrences)
- throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFileWithInvalidCapReqOccurrences);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_YAML_FILE.name(), new ArrayList<String>(),
- importResourceResponse.getResponse());
- }
-
- @Test
- public void importToscaResource() throws Exception {
-
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importSuccessFile);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
- AssertJUnit.assertTrue("response code is not 201, returned :" + importResourceResponse.getErrorCode(),
- importResourceResponse.getErrorCode() == 201);
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- AssertJUnit.assertTrue("validate toscaResourceName field",
- resourceJavaObject.getToscaResourceName().equals(parseToscaNodeYaml.getNodeName()));
- AssertJUnit.assertTrue("validate resourceType field",
- resourceJavaObject.getResourceType().equals(ResourceTypeEnum.VFC));
- // find derived from resource details
- // Validate resource details after import-create resource including
- // capabilities, interfaces from derived_from resource
-
- // Validate audit message
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceWithOccurrencesSuccessFlow() throws Exception {
-
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importWithOccurrences);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
- AssertJUnit.assertTrue("response code is not 201, returned :" + importResourceResponse.getErrorCode(),
- importResourceResponse.getErrorCode() == 201);
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- AssertJUnit.assertTrue("validate toscaResourceName field",
- resourceJavaObject.getToscaResourceName().equals(parseToscaNodeYaml.getNodeName()));
- AssertJUnit.assertTrue("validate resourceType field",
- resourceJavaObject.getResourceType().equals(ResourceTypeEnum.VFC));
- String requirementsType = "tosca.capabilities.Attachment";
- String capabilitType = "tosca.capabilities.Endpoint.Admin";
- // Verify Occurrences of requirements and capabilities in resource
- verifyRequirementsOccurrences(resourceJavaObject, requirementsType);
- verifyCapabilitiesOccurrences(resourceJavaObject, capabilitType);
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- // ------------------------------Success---------------------------------
-
- @Test(enabled = false)
- public void importToscaResourceVFResType() throws Exception {
-
- String resourceType = ResourceTypeEnum.VF.toString();
-
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importSuccessVFFile);
- // importReqDetails.setResourceType(resourceType);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
- assertTrue("response code is not 201, returned :" + importResourceResponse.getErrorCode(),
- importResourceResponse.getErrorCode() == 201);
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- assertTrue("validate toscaResourceName field",
- resourceJavaObject.getToscaResourceName().equals(parseToscaNodeYaml.getNodeName()));
- assertTrue(
- "validate resourceType field, expected - " + resourceType + ", actual - "
- + resourceJavaObject.getResourceType(),
- resourceJavaObject.getResourceType().toString().equals(resourceType));
-
- // Validate audit message
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- // ------------------------------Failure---------------------------------
-
- @Test
- public void importToscaResourceDerivedFromNotExist() throws Exception {
-
- String fileName = importNoDerivedFromFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- // List<String> derivedFrom = new ArrayList<String>() ;
- // derivedFrom.add("hh");
- // importReqDetails.setDerivedFrom(derivedFrom);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.PARENT_RESOURCE_NOT_FOUND.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PARENT_RESOURCE_NOT_FOUND.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceIncorrectDefinitionVersion() throws Exception {
-
- String fileName = importInvalidDefinitionVersionFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_TOSCA_TEMPLATE.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceIncorrectSpaceNameFormat() throws Exception {
-
- String fileName = importIncorrectNameSpaceFormatFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_RESOURCE_NAMESPACE.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_RESOURCE_NAMESPACE.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceNoDefinitionVersion() throws Exception {
-
- String fileName = importNoDefenitionVersionFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_TOSCA_TEMPLATE.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceNoContent() throws Exception {
-
- String fileName = importNoContentFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_RESOURCE_PAYLOAD.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_RESOURCE_PAYLOAD.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceWithTopologyTemplate() throws Exception {
-
- String fileName = importTopologyTemplateFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.NOT_RESOURCE_TOSCA_TEMPLATE.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_RESOURCE_TOSCA_TEMPLATE.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceWithNodeTypesTwice() throws Exception {
-
- String fileName = importNodeTypesTwiceFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.NOT_SINGLE_RESOURCE.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_SINGLE_RESOURCE.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- // failed case - uniqueness of toscaResourceName - RESOURCE_ALREADY_EXISTS
- @Test
- public void importToscaResourceTwice() throws Exception {
- String fileName = importSuccessFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
- assertTrue("response code is not 201, returned :" + importResourceResponse.getErrorCode(),
- importResourceResponse.getErrorCode() == 201);
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- RestResponse checkInresponse = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CHECKIN);
- assertTrue("checkIn resource request returned status:" + checkInresponse.getErrorCode(),
- checkInresponse.getErrorCode() == 200);
-
- // Validate audit message
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
-
- // import the same tosca resource with different resourceName
- DbUtils.cleanAllAudits();
-
- importReqDetails.setName("kuku");
- List<String> tags = new ArrayList<String>();
- tags.add(importReqDetails.getName());
- importReqDetails.setTags(tags);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_ALREADY_EXISTS.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name(), variables,
- importResourceResponse.getResponse());
-
- expectedResourceAuditJavaObject = ElementFactory.getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(importReqDetails.getToscaResourceName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
-
- }
-
- @Test
- public void importToscaResourceWithTheSameNameAsCreatedResourceBefore() throws Exception {
-
- // create resource
- String fileName = importSuccessFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
-
- resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName(importReqDetails.getName());
-
- RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncUserDetails);
- int status = response.getErrorCode();
- assertEquals("create request returned status:" + status, 201, status);
- assertNotNull("resource uniqueId is null:", resourceDetails.getUniqueId());
- Resource resourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
- // assertNull("validate toscaResourceName field",
- // resourceJavaObject.getToscaResourceName());
-
- // import the same tosca resource
- DbUtils.cleanAllAudits();
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_ALREADY_EXISTS.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
-
- }
-
- @Test
- public void importToscaResourceInvalidChecksum() throws Exception {
- String fileName = importSuccessFile;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), "invalidMd5Sum");
-
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- headersMap);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- assertNotNull("check response object is not null after import tosca resource", importResourceResponse);
- assertNotNull("check error code exists in response after import tosca resource",
- importResourceResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_RESOURCE_CHECKSUM.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_RESOURCE_CHECKSUM.name(), variables,
- importResourceResponse.getResponse());
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceInvalidResType() throws Exception {
-
- String resourceType = "invalidResourceType";
-
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importSuccessFile);
- importReqDetails.setResourceType(resourceType);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
- assertNotNull("check response object is not null after import resouce", importResourceResponse);
- assertNotNull("check error code exists in response after import resource",
- importResourceResponse.getErrorCode());
- assertEquals("Check response code after import resource", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
-
- List<String> variables = new ArrayList<>();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
- importResourceResponse.getResponse());
-
- // Validate audit message
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void derivedTemplateImportedSecondResourceAsFirstImportedNodeType() throws Exception {
-
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importSuccessFile);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
- assertTrue("response code is not 201, returned :" + importResourceResponse.getErrorCode(),
- importResourceResponse.getErrorCode() == 201);
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- assertTrue("validate toscaResourceName field",
- resourceJavaObject.getToscaResourceName().equals(parseToscaNodeYaml.getNodeName()));
- assertTrue(
- "validate resourceType field, expected - " + importReqDetails.getResourceType() + ", actual - "
- + resourceJavaObject.getResourceType(),
- resourceJavaObject.getResourceType().toString().equals(importReqDetails.getResourceType()));
-
- // Validate audit message
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
-
- RestResponse certifyResource = LifecycleRestUtils.certifyResource(importReqDetails);
- assertTrue("certify resource request returned status:" + certifyResource.getErrorCode(),
- certifyResource.getErrorCode() == 200);
-
- // import second resource template derived from first resource
- DbUtils.cleanAllAudits();
- importReqDetails.setName("kuku");
- List<String> tags = new ArrayList<String>();
- tags.add(importReqDetails.getName());
- importReqDetails.setTags(tags);
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- derivedFromMyCompute);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- assertTrue("response code is not 201, returned :" + importResourceResponse.getErrorCode(),
- importResourceResponse.getErrorCode() == 201);
- parseToscaNodeYaml = utils.parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- Resource resourceJavaObject2 = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- assertTrue("validate toscaResourceName field",
- resourceJavaObject2.getToscaResourceName().equals(parseToscaNodeYaml.getNodeName()));
- assertTrue(
- "validate resourceType field, expected - " + importReqDetails.getResourceType() + ", actual - "
- + resourceJavaObject2.getResourceType(),
- resourceJavaObject2.getResourceType().toString().equals(importReqDetails.getResourceType()));
-
- // Validate audit message
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject2 = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject2.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject2.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject2.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject2.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject2,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
-
- }
-
- @Test
- public void importToscaResourceListPropertyGoodDefault() throws Exception {
-
- String fileName = importListPropertyGoodDefault;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- assertTrue("response code is not 201, returned :" + importResourceResponse.getErrorCode(),
- importResourceResponse.getErrorCode() == 201);
-
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- assertTrue("Properties size : " + resourceJavaObject.getProperties().size(),
- resourceJavaObject.getProperties().size() == 1);
- assertTrue("Property type : " + resourceJavaObject.getProperties().get(0).getType(),
- resourceJavaObject.getProperties().get(0).getType().equals(ToscaPropertyType.LIST.getType()));
- assertTrue(
- "actual Default values : " + resourceJavaObject.getProperties().get(0).getDefaultValue()
- + " , expected : " + "[false, true]",
- resourceJavaObject.getProperties().get(0).getDefaultValue().equals("[\"false\",\"true\"]"));
-
- }
-
- @Test
- public void importToscaResourceListPropertyBadDefault() throws Exception {
-
- String fileName = importListPropertyBadDefault;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE.name());
- assertEquals("Check response code after tosca resource import", errorInfo.getCode(),
- importResourceResponse.getErrorCode());
- ArrayList<String> variables = new ArrayList<>();
- variables.add("my_prop");
- variables.add("list");
- variables.add("boolean");
- variables.add("[12,true]");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE.name(), variables,
- importResourceResponse.getResponse());
-
- }
-
- // Benny US580744 - Add support for TOSCA "list" type - import
-
- @Test
- public void importToscaResourceListPropertySuccessFlow() throws Exception {
- String fileName = importListPropertySuccess;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- ResourceRestUtils.checkCreateResponse(importResourceResponse);
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- // Verify Properties List in resource
- verifyResourcePropertiesList(resourceJavaObject);
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- // DE198534
- @Test(dataProvider = "getYmlWithInValidListProperties") // invalid default
- // values
- public void importToscaResourceListPropertyFailureFlows(String ymlFileWithInvalidPropertyDefualtValues,
- String defualtValues, String enterySchemaType) throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFileWithInvalidPropertyDefualtValues);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("my_property");
- variables.add("list");
- variables.add(enterySchemaType);
- variables.add(defualtValues);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE.name(), variables,
- importResourceResponse.getResponse());
- }
-
- // BUG DE198650
- @Test
- public void importToscaResourceListPropertyNonSupportEntrySchemaType() throws Exception {
- String ymlFile = "ListPropertyFalure01.yml";
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFile);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("booolean"); // property entry_schema data type
- variables.add("my_boolean");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROPERTY_INNER_TYPE.name(), variables,
- importResourceResponse.getResponse());
- }
-
- // BUG DE198676
- @Test // (enabled=false)
- public void importToscaResourceListPropertyNonSupportedPropertyType() throws Exception { // Not
- // "list"
- // type
- String ymlFile = "ListPropertyFalure16.yml";
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFile);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("koko"); // property data type (koko instead list)
- variables.add("my_boolean");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROPERTY_TYPE.name(), variables,
- importResourceResponse.getResponse());
- }
-
- /// US656928 - [BE] - Add support for TOSCA "map" type - Phase 1 import
- @Test
- public void importToscaResourceMapPropertySuccessFlow() throws Exception {
- String fileName = importMapPropertySuccess;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- ResourceRestUtils.checkCreateResponse(importResourceResponse);
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
- // Verify Properties MAP in resource
- verifyResourcePropertiesMap(resourceJavaObject);
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test(dataProvider = "getYmlWithInValidMapProperties") // invalid default
- // values
- public void importToscaResourceMapPropertyFailureFlows(String ymlFileWithInvalidPropertyDefualtValues,
- String defualtValues, String enterySchemaType) throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFileWithInvalidPropertyDefualtValues);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("my_property");
- variables.add("map");
- variables.add(enterySchemaType);
- variables.add(defualtValues);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE.name(), variables,
- importResourceResponse.getResponse());
- }
-
- @Test
- public void importToscaResourceMaptPropertyNonSupportedPropertyType() throws Exception { // Not
- // "Map"
- // type
- String ymlFile = "MapPropertyFalure16.yml";
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFile);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("koko"); // property data type (koko instead list)
- variables.add("my_boolean");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROPERTY_TYPE.name(), variables,
- importResourceResponse.getResponse());
- }
-
- @Test
- public void importToscaResourceMissingCapabilityInReqDefinition() throws Exception {
-
- String fileName = missingCapInReqDef;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_CAPABILITY_TYPE.name());
- String missingCapName = "org.openecomp.capabilities.networkInterfaceNotFound";
- BaseRestUtils.checkErrorResponse(importResourceResponse, ActionStatus.MISSING_CAPABILITY_TYPE, missingCapName);
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, Arrays.asList(missingCapName));
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType("org.openecomp.resource.vSCP-03-16");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceMissingCapabilityInCapDefinition() throws Exception {
-
- String fileName = missingCapInCapDef;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- logger.debug("import tosca resource response: {}", importResourceResponse.getResponseMessage());
-
- // Validate audit message
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_CAPABILITY_TYPE.name());
- String missingCapName = "org.openecomp.capabilities.networkInterfaceNotFound";
- BaseRestUtils.checkErrorResponse(importResourceResponse, ActionStatus.MISSING_CAPABILITY_TYPE, missingCapName);
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, Arrays.asList(missingCapName));
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType("org.openecomp.resource.vSCP-03-16");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceDuplicateRequirements() throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importDuplicateRequirements);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("requirement");
- variables.add("local_storage");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME.name(), variables,
- importResourceResponse.getResponse());
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceDuplicateCapabilities() throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importDuplicateCapability);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("capability");
- variables.add("scalable");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME.name(), variables,
- importResourceResponse.getResponse());
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceRequirementNameExistsOnParent() throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importRequirementNameExistsOnParent);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("requirement");
- variables.add("local_storage");
- variables.add("Compute");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED.name(),
- variables, importResourceResponse.getResponse());
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceCapabilityNameExistsOnParent() throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importCapabilityNameExistsOnParent);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertTrue(importResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("capability");
- variables.add("binding");
- variables.add("Compute");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED.name(),
- variables, importResourceResponse.getResponse());
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgFailure(errorInfo, variables);
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- @Test
- public void importToscaResourceReqCapDerivedFromParent() throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- importToscaResourceReqCapDerivedFromParent);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- BaseRestUtils.checkCreateResponse(importResourceResponse);
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType("org.openecomp.resource.MyWebApp");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- /************************ Shay ************************/
-
- @Test
- public void caseRequirementInsensitiveTest() throws Exception {
- String fileName = "CaseInsensitiveReqTest_1.yml";
- int expectedNumOfRequirements = 2;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
- importReqDetails.setRequirements(testResourcesPath, fileName, sdncUserDetails, null);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
-/* 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())*/;
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String fileName2 = "CaseInsensitiveReqTest_2.yml";
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName2);
- importReqDetails.setName("secondImportedResource");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails, null);
- requirements = importReqDetails.getRequirements();
- requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- checkImportedAssetAssociated(importReqDetails);
-
- }
-
- private void checkImportedAssetAssociated(ImportReqDetails importDetails) throws IOException, Exception {
- RestResponse importResourceResponse;
- ImportReqDetails importReqDetails2 = ElementFactory.getDefaultImportResource();
- importReqDetails2 = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails2, testResourcesPath,
- "BindingAsset.yml");
- importReqDetails2.setName("bindingAsset");
- importReqDetails2.setTags(Arrays.asList(importReqDetails2.getName()));
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails2, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- ResourceReqDetails vf = ElementFactory.getDefaultResourceByType("VF100", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncUserDetails.getUserId(),
- ResourceTypeEnum.VF.toString());
- RestResponse createResourceResponse = ResourceRestUtils.createResource(vf, sdncUserDetails);
- ResourceRestUtils.checkCreateResponse(createResourceResponse);
-
-//TODO Andrey should click on certify button
- /*LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- LifecycleRestUtils.changeResourceState(importReqDetails2, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);*/
- LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFY);
- LifecycleRestUtils.changeResourceState(importReqDetails2, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFY);
-
- RestResponse response = ResourceRestUtils.createResourceInstance(importDetails, sdncUserDetails,
- vf.getUniqueId());
- ResourceRestUtils.checkCreateResponse(response);
- ComponentInstance riCap = ResponseParser.parseToObject(response.getResponse(), ComponentInstance.class);
-
- response = ResourceRestUtils.createResourceInstance(importReqDetails2, sdncUserDetails, vf.getUniqueId());
- ResourceRestUtils.checkCreateResponse(response);
- ComponentInstance riReq = ResponseParser.parseToObject(response.getResponse(), ComponentInstance.class);
-
- RestResponse getResourceBeforeAssociate = ComponentRestUtils
- .getComponentRequirmentsCapabilities(sdncUserDetails, vf);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceBeforeAssociate.getResponse(), CapReqDef.class);
-
- String capbilityUid = capReqDef.getCapabilities().get("tosca.capabilities.network.Bindable").get(0)
- .getUniqueId();
- String requirementUid = capReqDef.getRequirements().get("tosca.capabilities.network.Bindable").get(0)
- .getUniqueId();
-
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- requirementDef.setFromNode(riReq.getUniqueId());
- requirementDef.setToNode(riCap.getUniqueId());
-
- RelationshipInfo pair = new RelationshipInfo();
- pair.setRequirementOwnerId(riReq.getUniqueId());
- pair.setCapabilityOwnerId(riCap.getUniqueId());
- pair.setRequirement("VirtualBinding");
- RelationshipImpl relationship = new RelationshipImpl();
- relationship.setType("tosca.capabilities.network.Bindable");
- pair.setRelationships(relationship);
- pair.setCapabilityUid(capbilityUid);
- pair.setRequirementUid(requirementUid);
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
- relationships.add(capReqRel);
- capReqRel.setRelation(pair);
- requirementDef.setRelationships(relationships);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, sdncUserDetails,
- vf.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- }
-
- @Test
- public void caseCapabilitiesInsensitiveTest() throws Exception {
- String fileName = "CaseInsensitiveCapTest_1.yml";
- int expectedNumOfCapabilities = 6;
-
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setCapabilities(testResourcesPath, fileName, sdncUserDetails, null);
- Map<String, Object> capabilities = importReqDetails.getCapabilities();
- Map<String, Object> capabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetails,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
-
- //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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String fileName2 = "CaseInsensitiveCapTest_2.yml";
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName2);
- importReqDetails.setName("secondImportedResource");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setCapabilities(testResourcesPath, fileName2, sdncUserDetails, null);
- capabilities = importReqDetails.getCapabilities();
- capabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetails,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
-
- }
-
- @Test
- public void fatherAndChildHaveDifferentRequirementsTest() throws Exception {
- String fileName = "DifferentReqFromCompute.yml";
- int expectedNumOfRequirements = 3;
-
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, fileName, sdncUserDetails, "Compute");
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- checkImportedAssetAssociated(importReqDetails);
- }
-
- @Test
- public void fatherHasNoRequirementsTest() throws Exception {
- String fatherFileName = "CPHasNoReqCap.yml";
- String childFileName = "DerivedFromCPWithOwnReq.yml";
- int expectedNumOfRequirements = 3;
-
- importReqDetails.setName("father");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-//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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String derivedFromResourceName = importReqDetails.getName();
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromResourceName);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- }
-
- @Test
- public void childHasSameReqNameAndTypeLikeFatherTest() throws Exception {
- String childFileName = "SameReqAsCompute.yml";
- int expectedNumOfRequirements = 2;
-
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails, null);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
- }
-
- @Test
- public void childHasSameCapNameAndTypeLikeFatherTest() throws Exception {
- String childFileName = "SameCapAsCompute.yml";
- int expectedNumOfCapabilities = 6;
-
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setCapabilities(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- "Compute");
- Map<String, Object> capabilities = importReqDetails.getCapabilities();
- Map<String, Object> capabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetails,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
- }
-
- @Test
- public void childGetsAllRequirementsOfFatherAndGrandfatherTest() throws Exception {
- int expectedNumOfRequirements = 4;
-
- String fatherFileName = "DifferentReqFromCompute.yml";
- importReqDetails.setName("father");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-//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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String derivedFromName = importReqDetails.getName();
- String childFileName = "DifferentReqCapFromCompute1.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- }
-
- @Test
- public void childOverridesGrandfatherRequirementsTest() throws Exception {
- int expectedNumOfRequirements = 3;
-
- String fatherFileName = "DifferentReqFromCompute.yml";
- importReqDetails.setName("father");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- /*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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String derivedFromName = importReqDetails.getName();
- String childFileName = "SameReqAsCompute_DerivedFromMyCompute1.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
- }
-
- @Test
- public void childAndGrandfatherHaveDifferenetReqiurementTypeTest() throws Exception {
- int expectedNumOfRequirements = 3;
- int expectedNumOfCapabilities = 6;
-
- String fatherName = "father";
- String fatherFileName = "DifferentReqFromCompute.yml";
- importReqDetails.setName(fatherName);
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-//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())*/;
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String fatherUniqueId = importReqDetails.getUniqueId();
- ImportReqDetails importReqDetailsFather = importReqDetails;
-
- String childFileName = "importRequirementNameExistsOnParent_DerivedFromMyCompute1.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_INVALID_CONTENT, importResourceResponse.getErrorCode().intValue());
- ArrayList<String> variables = new ArrayList<>();
- variables.add("requirement");
- variables.add("local_storage");
- variables.add(fatherName);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED.name(),
- variables, importResourceResponse.getResponse());
-
- importReqDetails.setUniqueId(fatherUniqueId);
-
- importReqDetailsFather.setRequirements(testResourcesPath, fatherFileName, sdncUserDetails, "Compute");
- Map<String, Object> requirements = importReqDetailsFather.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetailsFather,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetailsFather.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- importReqDetailsFather.setCapabilities(testResourcesPath, fatherFileName, sdncUserDetails, "Compute");
- Map<String, Object> capabilities = importReqDetailsFather.getCapabilities();
- Map<String, Object> capabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetailsFather,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
- importReqDetailsFather.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
- }
-
- @Test
- public void childHasNoReqCapTest() throws Exception {
- int expectedNumOfRequirements = 3;
- int expectedNumOfCapabilities = 6;
-
- String fatherFileName = "DifferentReqFromCompute.yml";
- importReqDetails.setName("father");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-//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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String derivedFromName = importReqDetails.getName();
- String childFileName = "CPHasNoReqCap_DerivedFromMyCompute1.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- importReqDetails.setCapabilities(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> capabilities = importReqDetails.getCapabilities();
- Map<String, Object> capabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetails,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
- }
-
- @Test
- public void fatherAndChildGetReqCapFromGrandfatherTest() throws Exception {
- int expectedNumOfRequirements = 2;
- int expectedNumOfCapabilities = 6;
-
- String fatherFileName = "MyFatherCompute_NoReqCap.yml";
- importReqDetails.setName("father");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-//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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String derivedFromName = importReqDetails.getName();
- String childFileName = "myChildCompute_NoReqCap.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- importReqDetails.setCapabilities(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> capabilities = importReqDetails.getCapabilities();
- Map<String, Object> capabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetails,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
- }
-
- @Test
- public void reverseInheritanceTest() throws Exception {
- int expectedNumOfRequirements = 2;
- int expectedNumOfCapabilities = 2;
-
- String fatherName = "father";
- String fatherFileName = "myFatherWebApp_derviedFromDocker.yml";
- importReqDetails.setName(fatherName);
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-//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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String fatherUniqueId = importReqDetails.getUniqueId();
- ImportReqDetails importReqDetailsFather = importReqDetails;
- String childFileName = "myChildWebApp_DerivedFromContainer.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_INVALID_CONTENT, importResourceResponse.getErrorCode().intValue());
- ArrayList<String> variables = new ArrayList<>();
- variables.add("requirement");
- variables.add("host");
- variables.add(fatherName);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED.name(),
- variables, importResourceResponse.getResponse());
-
- importReqDetails.setUniqueId(fatherUniqueId);
- importReqDetailsFather.setRequirements(testResourcesPath, fatherFileName, sdncUserDetails, "Root");
- Map<String, Object> requirements = importReqDetailsFather.getRequirements();
- Map<String, Object> requirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetailsFather,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
- importReqDetailsFather.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
-
- importReqDetailsFather.setCapabilities(testResourcesPath, fatherFileName, sdncUserDetails, "Root");
- Map<String, Object> capabilities = importReqDetailsFather.getCapabilities();
- Map<String, Object> capabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetailsFather,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
- importReqDetailsFather.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
- }
-
- // DE202329 - TDP -154379
- @Test(enabled = true)
- public void requirementWithMissingTypeTest() throws Exception {
- String fatherName = "father";
- String fatherFileName = "DerivedFromWebApplication_HasNoReqType.yml";
- importReqDetails.setName(fatherName);
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_INVALID_CONTENT, importResourceResponse.getErrorCode().intValue());
- ArrayList<String> variables = new ArrayList<>();
- variables.add("diff");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_CAPABILITY_TYPE.name(), variables,
- importResourceResponse.getResponse());
-
- }
-
- @Test
- public void TwinBrothersHaveSameReqCapTest() throws Exception {
- int expectedNumOfRequirements = 4;
- int expectedNumOfCapabilities = 7;
-
- String derivedFromName = "father";
- String fatherFileName = "DifferentReqFromCompute.yml";
- importReqDetails.setName(derivedFromName);
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fatherFileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-//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());*/
- RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
-
- String childFileName = "DifferentReqCapFromCompute1.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("child");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- childFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- Map<String, Object> childRequirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- Map<String, Object> childCapabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetails,
- expectedNumOfCapabilities - 1);
-
- String twinFileName = "DifferentReqCapFromCompute2.yml";
- importReqDetails = ElementFactory.getDefaultImportResource();
- importReqDetails.setName("twin");
- importReqDetails.setTags(Arrays.asList(importReqDetails.getName()));
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- twinFileName);
- importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails, null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- importReqDetails.setRequirements(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> requirements = importReqDetails.getRequirements();
- Map<String, Object> twinRequirementsFromResponse = parseReqOrCapFromResponse("requirements", importReqDetails,
- expectedNumOfRequirements);
- assertEquals(requirements.keySet().size(), twinRequirementsFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(requirements, twinRequirementsFromResponse);
-
- importReqDetails.setCapabilities(testResourcesPath, importReqDetails.getPayloadName(), sdncUserDetails,
- derivedFromName);
- Map<String, Object> capabilities = importReqDetails.getCapabilities();
- Map<String, Object> twinCapabilitiesFromResponse = parseReqOrCapFromResponse("capabilities", importReqDetails,
- expectedNumOfCapabilities);
- assertEquals(capabilities.keySet().size(), twinCapabilitiesFromResponse.keySet().size());
- importReqDetails.compareRequirementsOrCapabilities(capabilities, twinCapabilitiesFromResponse);
-
- assertEquals(childRequirementsFromResponse.keySet().size(), twinRequirementsFromResponse.keySet().size());
- assertEquals(childCapabilitiesFromResponse.keySet().size(), twinCapabilitiesFromResponse.keySet().size());
- }
-
- /*
- * invariantUUID - US672129
- */
-
- private void checkInvariantUuidIsImmutableInDifferentAction(ImportReqDetails importReqDetails) throws Exception {
- // create resource
- importReqDetails.setName("import");
- String invariantUuidDefinedByUser = "abcd1234";
- RestResponse importResourceResponse = importResourceWithRequestedInvariantUuid(importReqDetails,
- invariantUuidDefinedByUser);
- String invariantUUIDcreation = ResponseParser.getInvariantUuid(importResourceResponse);
- assertFalse(checkInvariantUuidEqual(invariantUuidDefinedByUser, importResourceResponse));
-
- // get resource
- RestResponse getResource = ResourceRestUtils.getResource(importReqDetails.getUniqueId());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, getResource));
-
- // checkin resource
- RestResponse changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CHECKIN);
- 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));
-
- // checkin resource
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CHECKIN);
- 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));
-
- // checkin resource
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CHECKIN);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-//TODO Andrey should click on certify button
- /*// certification request
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-
- // start certification
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
-
- // certify
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFY);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
- String certifiedUniqueId = importReqDetails.getUniqueId();
-
- // update resource
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceReqDetails updatedResourceReqDetails = new ResourceReqDetails(importReqDetails,
- importReqDetails.getVersion());
- updatedResourceReqDetails.setDescription("updatedDescription");
- updatedResourceReqDetails.setVendorRelease("1.2.3.4");
- RestResponse updateResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceReqDetails,
- sdncUserDetails, importReqDetails.getUniqueId());
- assertEquals(STATUS_CODE_SUCCESS, updateResponse.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, updateResponse));
-
- /* // 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));
-//TODO Andrey should click on certify button
-/* // certification request
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-
- // start certification
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
-
- /*// cancel certification
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
- LifeCycleStatesEnum.CANCELCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
-
- /*// start certification
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-
- // failure
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
- LifeCycleStatesEnum.FAILCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
-
- // upload artifact
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ArtifactReqDetails artifactDetails = ElementFactory.getDefaultArtifact();
- ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails, sdncUserDetails,
- importReqDetails.getUniqueId());
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-
- // create instance
- resourceDetails.setResourceType(ResourceTypeEnum.VF.toString());
- ResourceRestUtils.createResource(resourceDetails, sdncUserDetails);
- importReqDetails.setUniqueId(certifiedUniqueId);
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(importReqDetails);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncUserDetails, resourceDetails.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals(STATUS_CODE_CREATED, createResourceInstanceResponse.getErrorCode().intValue());
- getResource = ResourceRestUtils.getResource(importReqDetails.getUniqueId());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, getResource));
- }
-
- private boolean checkInvariantUuidEqual(String expectedInvariantUuid, RestResponse response) {
- String invariantUUIDFromResponse = ResponseParser.getInvariantUuid(response);
- return expectedInvariantUuid.equals(invariantUUIDFromResponse);
- }
-
- @Test
- public void checkCPHasImmutableInvariantUuidTest() throws Exception {
- String filename = "FatherHasNoReqCap.yml";
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- filename);
- checkResourceHasImmutableInvariantUuidTest(importReqDetails);
- }
-
- @Test
- public void checkVFCHasImmutableInvariantUuidTest() throws Exception {
- String filename = "computeCap11.yml";
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- filename);
- checkResourceHasImmutableInvariantUuidTest(importReqDetails);
- }
-
- public void checkResourceHasImmutableInvariantUuidTest(ImportReqDetails importReqDetails) throws Exception {
- // invariantUuid is null
- importReqDetails.setName("first");
- RestResponse importResourceResponse = importResourceWithRequestedInvariantUuid(importReqDetails, null);
- String invariantUUIDcreation = ResponseParser.getInvariantUuid(importResourceResponse);
- assertNotNull(invariantUUIDcreation);
-
- ResourceRestUtils.deleteResource(importReqDetails.getUniqueId(), sdncUserDetails.getUserId());
-
- // invariantUuid is empty
- importReqDetails.setName("second");
- String invariantUuidDefinedByUser = "";
- importResourceResponse = importResourceWithRequestedInvariantUuid(importReqDetails, invariantUuidDefinedByUser);
- invariantUUIDcreation = ResponseParser.getInvariantUuid(importResourceResponse);
- assertNotNull(invariantUUIDcreation);
-
- ResourceRestUtils.deleteResource(importReqDetails.getUniqueId(), sdncUserDetails.getUserId());
-
- checkInvariantUuidIsImmutableInDifferentAction(importReqDetails);
- }
-
- private static RestResponse importResourceWithRequestedInvariantUuid(ImportReqDetails importDetails,
- String invariantUuid) throws Exception {
- importDetails.setInvariantUUID(invariantUuid);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importDetails, sdncUserDetails,
- null);
- assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
- return importResourceResponse;
- }
-
- private Map<String, Object> parseReqOrCapFromResponse(String parsedFieldName, ImportReqDetails importReqDetails,
- int expectedNumOfReqCap) throws ClientProtocolException, IOException {
- RestResponse getResource = ResourceRestUtils.getResource(importReqDetails.getUniqueId());
- assertTrue(getResource.getErrorCode().equals(STATUS_CODE_SUCCESS));
- Map<String, Object> parsedFieldFromResponseToMap = ResponseParser.getJsonValueAsMap(getResource,
- parsedFieldName);
- Iterator<String> iterator = parsedFieldFromResponseToMap.keySet().iterator();
- actualNumOfReqOrCap = 0;
- while (iterator.hasNext()) {
- String next = iterator.next();
- List<Object> object = (List<Object>) parsedFieldFromResponseToMap.get(next);
- actualNumOfReqOrCap += object.size();
- }
- assertEquals(expectedNumOfReqCap, actualNumOfReqOrCap);
- return parsedFieldFromResponseToMap;
- }
-
- // ---------------------------------
-
- private void verifyResourcePropertiesList(Resource resourceJavaObject) { // use
- // importListPropertySuccessFlow.yml
- boolean isPropertyAppear = false;
- List<PropertyDefinition> propertiesList = resourceJavaObject.getProperties();
- for (PropertyDefinition pro : propertiesList) {
- switch (pro.getName()) {
- case "my_boolean":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[false,true]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "my_boolean_array":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[true,false]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "duplicate_boolean_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[true,false,true]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_values_Insensitive":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[true,false,true]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "my_integers":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[0,1000,-1000,50]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "my_integers_array":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[10,-1000,0]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "duplicate_integers_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[10,10,-1000,0]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "my_string":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("[\"asdc\",\"$?^@ecomp$!#%()_-~@+*^...;;/w#\",\"uc\"]"));
- // assertTrue("Check Property default values ",
- // pro.getDefaultValue().equals("[\"asdc\",\"@=~!@#$%^&*()_+=?><:-w\",\"uc\"]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "my_string_array":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("[\"AAA\",\"~$~#bbb%^*_-\",\"qwe\",\"1.3\",\"500\",\"true\"]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "duplicate_string_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("[\"asdc\",\"asdc\",\"uc\"]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_null_value":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[\"asdc\",\"uc\"]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_space_value":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[\"asdc\",\"uc\"]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_array_null_value":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("[\"aaa\",\"bbb\",\"500\"]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "my_float":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[6,1000.000001,-3.0]"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "my_float_array":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[0.01,-5.0,2.1]"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "duplicate_float_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[0.0,0.0,4.555555]"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_no_default_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "integer_no_default_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "string_no_default_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "boolean_no_default_values":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "integer_null_value":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[1000,2000]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "boolean_null_value":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[true,false]"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "float_null_value":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[6,-3.0]"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_space_value":
- assertTrue("Check Property Type ", pro.getType().equals("list"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("[6,-3.0]"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
-
- }
- assertTrue(isPropertyAppear);
- isPropertyAppear = false;
- }
-
- }
-
- private void verifyRequirementsOccurrences(Resource resourceJavaObject, String requirementsType) {
- boolean isRequirementAppear = false;
- // List<RequirementDefinition> requerments =
- // resourceJavaObject.getRequirements().get("tosca.capabilities.Attachment");
- List<RequirementDefinition> requerments = resourceJavaObject.getRequirements().get(requirementsType);
-
- for (RequirementDefinition req : requerments) {
- switch (req.getName()) {
- case "local_storage100":
- assertTrue("Check Min Requirement Occurrences ", req.getMinOccurrences().equals("1"));
- assertTrue("Check Max Requirement Occurrences ", req.getMaxOccurrences().equals("UNBOUNDED"));
- isRequirementAppear = true;
- break;
- case "local_storage200":
- assertTrue("Check Min Requirement Occurrences ", req.getMinOccurrences().equals("1"));
- assertTrue("Check Max Requirement Occurrences ", req.getMaxOccurrences().equals("1"));
- isRequirementAppear = true;
- break;
- case "local_storage300":
- assertTrue("Check Min Requirement Occurrences ", req.getMinOccurrences().equals("1"));
- assertTrue("Check Max Requirement Occurrences ", req.getMaxOccurrences().equals("10"));
- isRequirementAppear = true;
- break;
- case "local_storage400":
- assertTrue("Check Min Requirement Occurrences ", req.getMinOccurrences().equals("1"));
- assertTrue("Check Max Requirement Occurrences ", req.getMaxOccurrences().equals("10000000"));
- isRequirementAppear = true;
- break;
- case "local_storage500":
- assertTrue("Check Min Requirement Occurrences ", req.getMinOccurrences().equals("2"));
- assertTrue("Check Max Requirement Occurrences ", req.getMaxOccurrences().equals("3"));
- isRequirementAppear = true;
- break;
- case "local_storageNoOccurrences600":
- assertTrue("Check Min Requirement Occurrences ", req.getMinOccurrences().equals("1"));
- assertTrue("Check Max Requirement Occurrences ", req.getMaxOccurrences().equals("1"));
- isRequirementAppear = true;
- break;
- }
- assertTrue(isRequirementAppear);
- isRequirementAppear = false;
- }
-
- }
-
- private void verifyCapabilitiesOccurrences(Resource resourceJavaObject, String capabilitType) {
- boolean isCapabilityAppear = false;
- // List<CapabilityDefinition> capabilities =
- // resourceJavaObject.getCapabilities().get("tosca.capabilities.Endpoint.Admin");
- List<CapabilityDefinition> capabilities = resourceJavaObject.getCapabilities().get(capabilitType);
-
- for (CapabilityDefinition cap : capabilities) {
- switch (cap.getName()) {
- case "endpointNoOccurrence":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals("1"));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals("UNBOUNDED"));
- isCapabilityAppear = true;
- break;
- case "endpoint200":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals("1"));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals("2"));
- isCapabilityAppear = true;
- break;
- case "endpoint300":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals("1"));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals("1"));
- isCapabilityAppear = true;
- break;
- case "endpoint400":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals("1"));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals("10"));
- isCapabilityAppear = true;
- break;
- case "endpoint500":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals("1"));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals("10000000"));
- isCapabilityAppear = true;
- break;
- case "endpoint600":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals("1"));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals("UNBOUNDED"));
- isCapabilityAppear = true;
- break;
- case "endpoint700":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals("2"));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals("4"));
- isCapabilityAppear = true;
- break;
-
- }
- assertTrue(isCapabilityAppear);
- isCapabilityAppear = false;
- }
-
- }
-
- private void verifyResourcePropertiesMap(Resource resourceJavaObject) { // use
- // importMapPropertySuccessFlow.yml
- boolean isPropertyAppear = false;
- List<PropertyDefinition> propertiesList = resourceJavaObject.getProperties();
- for (PropertyDefinition pro : propertiesList) {
- switch (pro.getName()) {
- case "string_prop01":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\"val1\",\"keyB\":\"val2\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop02":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\"val1\",\"keyB\":\"val2\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop03":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\"val1\",\"keyB\":\"val2\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop04":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\"10\",\"keyB\":\"true\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop05":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":\"Big\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop06":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\"aaaA\",\"keyB\":null}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop07":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop08":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\"\",\"keyB\":\"abcd\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop09":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\" \",\"keyB\":\"abcd\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop10":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\" aaaa\",\"keyB\":\" bbbb\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop11":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\"aaaa \",\"keyB\":\"bbbb \"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop12":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":\" aaaa \",\"keyB\":\" bbbb ccccc \"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop13":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":\"aaaa\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop14":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":\" aaaa \"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop15":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":\"AbcD\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop16":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":\"AbcD\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop17":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":\"AbcD\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop18":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":\"AbcD\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop19":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":\"AbcD\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop20":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue()
- .equals("{\"keyA\":\"aaaa\",\"keya\":\"aaaa\",\"Keya\":\"Aaaa\",\"KEYA\":\"nnnn\"}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop21":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null,\"keyC\":null}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "string_prop22":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("string"));
- isPropertyAppear = true;
- break;
- case "integer_prop01":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":1,\"keyB\":1000}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop02":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null,\"keyC\":null}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop03":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":800,\"keyB\":-600}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop04":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":-600}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop05":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":100,\"keyB\":0}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop06":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":100,\"keyB\":0}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop07":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":100,\"keyB\":100}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop08":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":100,\"keyB\":200}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop09":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":100,\"keyB\":200}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop10":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":2222}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop11":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null,\"keyC\":null,\"keyD\":null}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop12":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "integer_prop13":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":200}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("integer"));
- isPropertyAppear = true;
- break;
- case "boolean_prop01":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":true,\"keyB\":false,\"keyC\":false}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop02":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":true,\"keyB\":false,\"keyC\":false}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop03":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null,\"keyC\":null,\"keyD\":null}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop04":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null,\"keyC\":null,\"keyD\":null}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop05":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":true,\"keyB\":false,\"keyC\":false}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop06":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":true,\"keyB\":true,\"keyC\":false}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop07":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop08":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":true,\"keyB\":false}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "boolean_prop09":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":false,\"keyB\":true}"));
- assertTrue("Check entrySchema Property Type ",
- pro.getSchema().getProperty().getType().equals("boolean"));
- isPropertyAppear = true;
- break;
- case "float_prop01":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":1.2,\"keyB\":3.56,\"keyC\":33}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop02":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":0.0,\"keyB\":0.0,\"keyC\":0}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop03":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null,\"keyC\":null,\"keyD\":null}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop04":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":1.2,\"keyB\":3.56,\"keyC\":33}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop05":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":33,\"keyB\":1.2,\"keyC\":3.607,\"keyD\":0}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop06":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":33,\"keyB\":1.2,\"keyC\":3.607}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop07":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":null,\"keyB\":null,\"keyC\":null,\"keyD\":null}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop08":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertEquals("Check Property default values ", pro.getDefaultValue(), null);
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop09":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":0.01,\"keyB\":null}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop10":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ", pro.getDefaultValue().equals("{\"keyA\":0.00020}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- case "float_prop11":
- assertTrue("Check Property Type ", pro.getType().equals("map"));
- assertTrue("Check Property default values ",
- pro.getDefaultValue().equals("{\"keyA\":3.56,\"keyB\":33}"));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType().equals("float"));
- isPropertyAppear = true;
- break;
- }
- assertTrue(isPropertyAppear);
- isPropertyAppear = false;
- }
-
- }
-
- @Test
- public void importToscaResourceAttributeSuccessFlow() throws Exception {
-
- String fileName = importAttributeSuccess;
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
- null);
- ResourceRestUtils.checkCreateResponse(importResourceResponse);
- Resource resourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- ToscaNodeTypeInfo parseToscaNodeYaml = utils
- .parseToscaNodeYaml(Decoder.decode(importReqDetails.getPayloadData()));
-
- HashMap<String, PropertyDefinition> attr = new HashMap<>();
-
- PropertyDefinition newAttr2 = new PropertyDefinition();
- newAttr2.setName("networks");
- newAttr2.setType("map");
- newAttr2.setDefaultValue("{\"keyA\" : val1 , \"keyB\" : val2}");
- SchemaDefinition schema = new SchemaDefinition();
- PropertyDataDefinition prop = new PropertyDataDefinition();
- prop.setType("string");
- schema.setProperty(prop);
- newAttr2.setSchema(schema);
- attr.put("networks", newAttr2);
-
- PropertyDefinition newAttr1 = new PropertyDefinition();
- newAttr1.setName("public_address");
- newAttr1.setType("string");
- attr.put("public_address", newAttr1);
-
- PropertyDefinition newAttr3 = new PropertyDefinition();
- newAttr3.setName("ports");
- newAttr3.setDescription("this is my description");
- attr.put("ports", newAttr3);
-
- PropertyDefinition newAttr = new PropertyDefinition();
- newAttr.setDefaultValue("myDefault");
- newAttr.setName("private_address");
- newAttr.setStatus("supported");
- newAttr.setType("string");
- attr.put("private_address", newAttr);
-
- // verify Resource Attributes
- validateResourceAttribute(resourceJavaObject, attr);
-
- // TO DO
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory
- .getDefaultImportResourceAuditMsgSuccess();
- expectedResourceAuditJavaObject.setResourceName(importReqDetails.getName());
- expectedResourceAuditJavaObject.setModifierName(sdncUserDetails.getFullName());
- expectedResourceAuditJavaObject.setModifierUid(sdncUserDetails.getUserId());
- expectedResourceAuditJavaObject.setToscaNodeType(parseToscaNodeYaml.getNodeName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- AuditingActionEnum.IMPORT_RESOURCE.getName(), null, false);
- }
-
- private void validateResourceAttribute(Resource resource, Map<String, PropertyDefinition> attr) {
- List<PropertyDefinition> resList = resource.getAttributes();
- int size = resList.size();
- String attributeName;
- for (int i = 0; i < size; i++) {
- attributeName = resList.get(i).getName();
- assertEquals(attr.get(attributeName).getDefaultValue(), resList.get(i).getDefaultValue());
- assertEquals(attr.get(attributeName).getName(), resList.get(i).getName());
- assertEquals(attr.get(attributeName).getDescription(), resList.get(i).getDescription());
- assertEquals(attr.get(attributeName).getStatus(), resList.get(i).getStatus());
- }
- }
-
-}
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
deleted file mode 100644
index 473e4f2e36..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.imports;
-
-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.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.GroupDefinition;
-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.ImportReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.common.api.Constants;
-import org.testng.annotations.Test;
-
-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
- public static TestName name = new TestName();
-
- Gson gson = new Gson();
- public static String userDefinedNodeYaml = "mycompute2.yml";
- public static String rootPath = System.getProperty("user.dir");
- public static String csarFolderPath = "/src/test/resources/CI/csars/";
-
- public ImportUpdateResourseCsarTest() {
- super(name, ImportUpdateResourseCsarTest.class.getName());
- }
-
- @Test
- public void createUpdateImportResourceFromCsarTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
- RestResponse updateResource = null;
- RestResponse createResource = null;
- Resource resource = null;
- String payloadName = "orig2G.csar";
- String rootPath = System.getProperty("user.dir");
- Path path = Paths.get(rootPath + csarFolderPath + "orig2G.csar");
- byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setName("TEST01");
- resourceDetails.setCsarUUID("orig2G.csar");
- resourceDetails.setCsarVersion("1");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- // create new resource from Csar
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- // update scar with new artifacts
- path = Paths.get(rootPath + csarFolderPath + "orig2G_update.csar");
- data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
- resourceDetails.setDescription("update");
- resourceDetails.setCsarVersion("2");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- }
-
- @Test
- public void createUpdateImportResourceFromCsarWithArtifactsGroupNamingTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes;
- ResourceReqDetails resourceDetails;
- RestResponse updateResource;
- RestResponse createResource;
- Resource resource;
-
- // back original scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "VF_RI2_G4_withArtifacts_group_naming_a.csar", "VF_RI2_G4_withArtifacts_group_naming.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("TEST01");
- resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts_group_naming.csar");
- resourceDetails.setCsarVersion("1");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- // create new resource from Csar
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- List<GroupDefinition> groups = resource.getGroups();
- assertTrue(groups != null && groups.size() == 6);
- assertTrue(groups.stream()
- .filter(g -> g.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)
- && !Pattern.compile(Constants.MODULE_NEW_NAME_PATTERN).matcher(g.getName()).matches())
- .count() == 0);
- // update scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "VF_RI2_G4_withArtifacts_group_naming_delete_update.csar", "VF_RI2_G4_withArtifacts_group_naming.csar");
- BaseRestUtils.checkSuccess(copyRes);
- resourceDetails.setDescription("BLA BLA BLA");
- resourceDetails.setCsarVersion("2");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- groups = resource.getGroups();
- assertTrue(groups != null && groups.size() == 5);
- // back original scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "VF_RI2_G4_withArtifacts_group_naming_a.csar", "VF_RI2_G4_withArtifacts_group_naming.csar");
- BaseRestUtils.checkSuccess(copyRes);
- resourceDetails.setDescription("BLA BLA BLA");
- resourceDetails.setCsarVersion("3");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- groups = resource.getGroups();
- assertTrue(groups != null && groups.size() == 6);
- assertTrue(groups.stream()
- .filter(g -> g.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)
- && !Pattern.compile(Constants.MODULE_NEW_NAME_PATTERN).matcher(g.getName()).matches())
- .count() == 0);
- }
-
- @Test
- public void createUpdateDeleteAllRequiredArtifactsTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes;
- ResourceReqDetails resourceDetails;
- RestResponse updateResource;
- RestResponse createResource;
- Resource resource;
- String artifactName = "heatnested7";
-
- ImportReqDetails resourceDetails0 = ElementFactory.getDefaultImportResource();
- createResource = importUserDefinedNodeType(userDefinedNodeYaml, sdncModifierDetails, resourceDetails0);
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
-
- // back original scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails, "orig2GV001_a.csar", "orig2GV001.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("TEST01");
- resourceDetails.setCsarUUID("orig2GV001.csar");
- resourceDetails.setCsarVersion("1");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- // create new resource from Csar
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
-
- BaseRestUtils.checkCreateResponse(createResource);
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertTrue(resource.getDeploymentArtifacts().get(artifactName).getRequiredArtifacts().size() == 2);
- List<GroupDefinition> groups = resource.getGroups();
- // update scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "orig2GV006-remove-all-nested-artifacts.csar", "orig2GV001.csar");
- BaseRestUtils.checkSuccess(copyRes);
- resourceDetails.setDescription("BLA BLA BLA");
- resourceDetails.setCsarVersion("2");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertTrue(resource.getDeploymentArtifacts().get(artifactName).getRequiredArtifacts().size() == 0);
- groups = resource.getGroups();
- // back original scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails, "orig2GV001_a.csar", "orig2GV001.csar");
- BaseRestUtils.checkSuccess(copyRes);
- }
-
- // First create from orig2GV006-remove-all-nested-artifacts.csar (without
- // requiredArtifact)
- // Submit for testing
- // Login as tester -> Certification
- // Login as designer
- // then update to orig2GV008-change-nested-oam-fileContent.csar (with
- // requiredArtifact)
- // Expected: requiredArtifact: ["hot-nimbus-psm_v1.0.yaml",
- // "hot-nimbus-swift-container_v1.0.yaml"]
- // Actual: no requiredArtifact
- @Test
- public void createUpdateAddRequiredArtifactsTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse copyRes;
- ResourceReqDetails resourceDetails;
- RestResponse updateResource;
- RestResponse createResource;
- Resource resource;
- String artifactName = "heatnested7";
-
- ImportReqDetails resourceDetails0 = ElementFactory.getDefaultImportResource();
- createResource = importUserDefinedNodeType(userDefinedNodeYaml, sdncModifierDetails, resourceDetails0);
- BaseRestUtils.checkCreateResponse(createResource);
- createResource = LifecycleRestUtils.certifyResource(resourceDetails0);
- BaseRestUtils.checkSuccess(createResource);
-
- // back original scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "orig2GV006-remove-all-nested-artifacts.csar", "orig2GV001.csar");
- BaseRestUtils.checkSuccess(copyRes);
-
- resourceDetails = ElementFactory.getDefaultResource();
- resourceDetails.setName("TEST01");
- resourceDetails.setCsarUUID("orig2GV001.csar");
- resourceDetails.setCsarVersion("1");
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- // create new resource from Csar
- createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- createResource = LifecycleRestUtils.certifyResource(resourceDetails);
- BaseRestUtils.checkSuccess(createResource);
-
- resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- assertTrue(resource.getDeploymentArtifacts().get(artifactName).getRequiredArtifacts().size() == 0);
- List<GroupDefinition> groups = resource.getGroups();
- // update scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails,
- "orig2GV008-change-nested-oam-fileContent.csar", "orig2GV001.csar");
- BaseRestUtils.checkSuccess(copyRes);
- resourceDetails.setDescription("BLA BLA BLA");
- resourceDetails.setCsarVersion("2");
- updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId());
- BaseRestUtils.checkSuccess(updateResource);
- resource = ResponseParser.parseToObjectUsingMapper(updateResource.getResponse(), Resource.class);
- assertTrue(resource.getDeploymentArtifacts().get(artifactName).getRequiredArtifacts().size() == 2);
- groups = resource.getGroups();
- // back original scar
- copyRes = ImportCsarResourceTest.copyCsarRest(sdncModifierDetails, "orig2GV001_a.csar", "orig2GV001.csar");
- BaseRestUtils.checkSuccess(copyRes);
- }
-
- private RestResponse importUserDefinedNodeType(String payloadName, User sdncModifierDetails,
- ImportReqDetails resourceDetails) throws Exception {
-
- Path path = Paths.get(rootPath + csarFolderPath + payloadName);
- byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
-
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(ResourceTypeEnum.VFC.name());
- return ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- }
-
-}
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
deleted file mode 100644
index 99caea6863..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java
+++ /dev/null
@@ -1,1464 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.product;
-
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-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;
-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.*;
-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;
-
- @Rule
- public static TestName name = new TestName();
-
- public ChangeServiceInstanceVersionTest() {
- super(name, ChangeServiceInstanceVersionTest.class.getName());
- }
-
- @BeforeMethod
- public void before() throws Exception {
- firstVfInstanceName = null;
- secoundVfInstanceName = null;
- firstVfInstanceUniqueId = null;
- secondVfInstanceUniqueId = null;
- serviceInstanceToReplaceUniqueId = null;
- expectedServiceName = null;
- expectedPosX = null;
- expectedPosY = null;
- actualServiceInstanceName = null;
- actualPosX = null;
- actualPosY = null;
- init();
- createComponents();
- }
-
- private void createComponents() throws Exception {
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- createAtomicResource(resourceDetailsVFC_01);
- changeResourceStateToCertified(resourceDetailsVFC_01);
- createAtomicResource(resourceDetailsCP_01);
- changeResourceStateToCertified(resourceDetailsCP_01);
- createAtomicResource(resourceDetailsVL_01);
- changeResourceStateToCertified(resourceDetailsVL_01);
- createAtomicResource(resourceDetailsVFC_02);
- changeResourceStateToCertified(resourceDetailsVFC_02);
- createAtomicResource(resourceDetailsCP_02);
- changeResourceStateToCertified(resourceDetailsCP_02);
- createAtomicResource(resourceDetailsVL_02);
- changeResourceStateToCertified(resourceDetailsVL_02);
- createVF(resourceDetailsVF_02);
- createVF(resourceDetailsVF_01);
- // create check-In services
- createService(serviceDetails_01);
- createService(serviceDetails_02);
- createService(serviceDetails_03);
- createProduct(productDetails_01);
- createProduct(productDetails_02);
-
- // add resourceDetailsCP_01 ,resourceDetailsVFC_01 and
- // resourceDetailsCP_01 to resourceDetailsVF_01 and certify
- // resourceDetailsVF_01
- certifyVf(resourceDetailsVF_01, resourceDetailsVFC_02, resourceDetailsCP_01);
- // add resourceDetailsCP_02 ,resourceDetailsVFC_02 and
- // resourceDetailsVL_02 to resourceDetailsVF_02 and certify
- // resourceDetailsVF_02
- certifyVf(resourceDetailsVF_02, resourceDetailsVFC_02, resourceDetailsCP_02);
- RestResponse createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails); // serviceDetails_01 has certified
- // resourceDetailsVF_01
- firstVfInstanceName = ResponseParser.getNameFromResponse(createVFInstanceResponse);
- createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02,
- sdncDesignerDetails); // serviceDetails_01 has certified
- // resourceDetailsVF_02
- secoundVfInstanceName = ResponseParser.getUniqueIdFromResponse(createVFInstanceResponse);
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- }
-
- @Test
- public void changeServiceInstanceVersionByPm() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
-
- @Test
- public void changeServiceInstanceVersionByAdmin() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // service [0.2] state to CERTIFICATIONREQUEST
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT,
- true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
-
- @Test
- public void changeServiceInstanceToOlderVersion() throws Exception {
- // Get VF Instance UniquId [Service version 0.1]
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ComponentInstance actualComponentInstance = service.getComponentInstances().get(0);
- firstVfInstanceUniqueId = actualComponentInstance.getUniqueId();
- String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse);
-
- // Checkout service [0.2]
- RestResponse changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01,
- sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // Adding service instance (serviceDetails_01 V0.2) to product without
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to Older version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
- true);
- // RestResponse changeServiceInstanceVersionResponse =
- // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
- // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
- // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
-
- // DE190201
- @Test
- public void changeServiceInstanceVersionToCertifiedVersion() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- /*
- * String serviceNewUniqueUid =
- * ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- * serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- */
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.CERTIFY);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- // RestResponse changeServiceInstanceVersionResponse =
- // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
- // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
- // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
-
- // DE191927
- @Test(enabled = false)
- public void changeServiceInstanceVersionThenReCheckInProduct() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- /////////////////////
- productOldUniqueId = productDetails_01.getUniqueId();
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- /////////////////////////////////////////////
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
-
- @Test
- public void changeServiceInstanceToHisVersion() throws Exception {
- // Get VF Instance UniquId [Service version 0.1]
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse);
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
- true);
- // RestResponse changeServiceInstanceVersionResponse =
- // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
- // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
- // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
-
- @Test
- public void changeServiceInstanceVersionByAdminNotByProductOwner() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
-
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT,
- true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
-
- }
-
- @Test
- public void changeServiceInstanceVersionByPmNotByProductOwner() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // change uniqueId after product check-out in expected Req&Cap
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId);
- // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1
- // instead sdncPmDetails1)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
- productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails2,
- ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void changeServiceInstanceVersionByTester() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // change uniqueId after product check-out in expected Req&Cap
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1
- // instead sdncPmDetails1)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
- productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid,
- sdncTesterDetails, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void changeServiceInstanceVersionProductIsNotCheckOut() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // CHANGE Service Instance VERSION for Non checkedOut product
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productOldUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- // DE191727
- @Test(enabled = false)
- public void changeServiceInstanceVersionServiceIsInCheckOutState() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // change uniqueId after product check-out in expected Req&Cap
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // CHANGE Service Instance VERSION to service in checkOut state
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
- productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1,
- ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(serviceNewUniqueUid);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
-
- }
-
- @Test
- public void changeServiceInstanceVersionServiceInstanceDoesNotExist() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // change service instance to newer version
- String serviceUniqueUidNotExist = "1234567890";
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceUniqueUidNotExist, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(serviceUniqueUidNotExist);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- // DE189392
- @Test(enabled = false)
- public void changeServiceInstanceNonExistingProduct() throws Exception {
- // Adding service instance (serviceDetails_01) to product saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // change service instance to newer version - Non existing Product
- String productNewUniqueIdNotExist = "1234567890";
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueIdNotExist,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(productNewUniqueIdNotExist);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void changeServiceInstanceVersionToNonExisitingServiceVersion() throws Exception {
- // Adding service instance (serviceDetails_01) to product saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // change service instance to Non-existing version
- String serviceUniqueUidNotExist = "1234567890";
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceUniqueUidNotExist, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
- true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(serviceUniqueUidNotExist);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void changeServiceInstanceComponentTypeIsNotProduct() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version for NON-Component Type =
- // Product (e.g. service)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.SERVICE, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void changeServiceInstanceComponentTypeNotSupported() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version for NON-Component Type =
- // Product (e.g. service)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1,
- ComponentTypeEnum.SERVICE_INSTANCE, true);
- assertEquals("Check response code ", STATUS_CODE_UNSUPPORTED_ERROR,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("null");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void SeveralServiceInstanceFromSameServiceVersionChangeVersionOnlyForOneServiceInstance() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
-
- @Test
- public void changeServiceInstanceVersionByNonAsdcUser() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- nonAsdcUser.setUserId("bt760h");
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void changeServiceInstanceVersionEmptyUserId() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- nonAsdcUser.setUserId("");
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_MISSING_INFORMATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- ////////////////////////////////////
- private void updateNewComponentInstanceId(RestResponse createServiceInstanceResp, String productNewUniqueId)
- throws Exception {
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- }
-
- private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- /*restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- } else
- return restResponse;
- if (restResponse.getErrorCode() == 200) {*/
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, 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);
-
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, computeResource,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
- sdncDesignerDetails, resource.getUniqueId());
- ResourceRestUtils.checkSuccess(response);
-
- String capOwnerId = toCompInstId;
- User user = sdncDesignerDetails;
- ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
-
- fulfillCpRequirement(resource, fromCompInstId, toCompInstId, capOwnerId, user, containerCompType);
-
- RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
- ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
- }
-}
diff --git a/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
deleted file mode 100644
index f9ce315ebf..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java
+++ /dev/null
@@ -1,1161 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.product;
-
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.*;
-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);
- 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 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 {
- /*
- * RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN); ResourceRestUtils.checkSuccess(restResponse);
- */
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.STARTCERTIFICATION);
- } else
- return restResponse;
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.CERTIFY);
- if (restResponse.getErrorCode() == 200) {
- serviceDetails.setVersion("1.0");
- serviceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- serviceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
- serviceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
- String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId");
- serviceDetails.setUniqueId(uniqueIdFromRresponse);
- }
- }
- return restResponse;
- }
-
- @Test
- public void deleteServiceInstanceTest() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
-
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- String compInstId2 = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
-
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(compInstId, productDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
-
- deleteServiceInstanceResp = deleteServiceInstance(compInstId2, productDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 0, 0);
- }
-
- @Test
- public void returnedServiceInstanceTypeAttributeTest() throws Exception {
- String expectedServiceType = ComponentTypeEnum.SERVICE.getValue().toUpperCase();
-
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- ComponentInstanceRestUtils.checkComponentInstanceType(createServiceInstanceResp, expectedServiceType);
-
- RestResponse getProductResp = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPsDetails1.getUserId());
- ProductRestUtils.checkSuccess(getProductResp);
- Product productObject = ResponseParser.parseToObjectUsingMapper(getProductResp.getResponse(), Product.class);
- List<ComponentInstance> productComponentInstances = productObject.getComponentInstances();
- for (ComponentInstance comp : productComponentInstances) {
- String actualOriginType = comp.getOriginType().getValue().toUpperCase();
- assertTrue(expectedServiceType.equals(actualOriginType));
- }
-
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_02);
- serviceInstanceReqDetails.setUniqueId(serviceUniqueIdFromResponse);
- serviceInstanceReqDetails.setComponentUid(serviceDetails_01.getUniqueId());
- RestResponse updateResourceInstance = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ComponentInstanceRestUtils.checkSuccess(updateResourceInstance);
- ComponentInstanceRestUtils.checkComponentInstanceType(updateResourceInstance, expectedServiceType);
-
- }
-}
diff --git a/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
deleted file mode 100644
index e22318eda7..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java
+++ /dev/null
@@ -1,2540 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.product;
-
-import 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;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.ci.tests.api.Urls;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit;
-import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.Convertor;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.*;
-import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils;
-import org.openecomp.sdc.common.api.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-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());
- @Rule
- public static TestName name = new TestName();
-
- public static String INITIAL_PRODUCT_VERSION = "0.1";
- public static String CREATE_AUDIT_ACTION = "Create";
- public static String UPDATE_AUDIT_ACTION = "Update";
- public static String COMPONENT_TYPE = "Product";
-
- private ProductReqDetails productReqDetails;
- private RestResponse createProduct;
- private Product product;
-
- public ProductCrudTest() {
- super(name, ProductCrudTest.class.getName());
- }
-
- @Test // (enabled=false)
- public void createAndGetAll() throws Exception {
- createProductAndGet(UserRoleEnum.DESIGNER);
- }
-
- private void createProductAndGet(UserRoleEnum user) throws Exception, IOException {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
-
- RestResponse catalog = CatalogRestUtils.getCatalog(user.getUserId());
- assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_SUCCESS,
- catalog.getErrorCode().intValue());
-
- try {
- JsonElement jElement = new JsonParser().parse(catalog.getResponse());
- JsonObject jObject = jElement.getAsJsonObject();
- JsonArray products = (JsonArray) jObject.get("products");
- assertEquals("Check product array size", 1, products.size());
- Iterator<JsonElement> iter = products.iterator();
- while (iter.hasNext()) {
- JsonElement next = iter.next();
- Product product = ResponseParser.parseToObjectUsingMapper(next.toString(), Product.class);
- assertNotNull(product);
- assertEquals("Check product name", productReqDetails.getName(), product.getName());
- // Map<String, String> allVersions = product.getAllVersions();
- // assertEquals("Check product name", 1, allVersions.size());
- }
-
- } catch (Exception e) {
- log.debug("exception", e);
- }
- }
-
- @Test
- public void getAllNoProcduts() throws Exception {
-
- RestResponse catalog = CatalogRestUtils.getCatalog();
- assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_SUCCESS,
- catalog.getErrorCode().intValue());
-
- try {
- JsonElement jElement = new JsonParser().parse(catalog.getResponse());
- JsonObject jObject = jElement.getAsJsonObject();
- JsonArray products = (JsonArray) jObject.get("products");
- assertEquals("Check product array size", 0, products.size());
- } catch (Exception e) {
- log.debug("exception", e);
- }
-
- }
-
- @Test
- public void getAllNoAttHeader() throws Exception {
- String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort());
-
- List<String> headersToRemove = new ArrayList<String>();
- headersToRemove.add(HttpHeaderEnum.USER_ID.getValue());
-
- RestResponse catalog = CatalogRestUtils.sendGetAndRemoveHeaders(url, null, headersToRemove);
- assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION,
- catalog.getErrorCode().intValue());
-
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
- catalog.getResponse());
- }
-
- @Test
- public void getAllWrongUser() throws Exception {
- RestResponse catalog = CatalogRestUtils.getCatalog("kj8976");
- assertEquals("Check response code after get catalog", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- catalog.getErrorCode().intValue());
-
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- catalog.getResponse());
- }
-
- @Test // (enabled=false)
- public void getAllWithProductStrategist_User() throws Exception {
- createProductAndGet(UserRoleEnum.PRODUCT_STRATEGIST1);
- }
-
- @Test // (enabled=false)
- public void getAllWithProductManager_User() throws Exception {
- createProductAndGet(UserRoleEnum.PRODUCT_MANAGER1);
- }
-
- @Test // (enabled=false)
- public void createProductNoCategories() throws Exception {
- createProductWithCategories(null);
- }
-
- @Test // (enabled=false)
- public void createProductOneGrouping() throws Exception {
- // Category1->[Subcategory1->[Grouping1]]
- createProductWithCategories(defaultCategories);
- }
-
- @Test // (enabled=false)
- public void createProductTwoGroupingsSameSubCategory() throws Exception {
- // Category1->Subcategory1->[Grouping1, Grouping11]
- List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory();
- createProductWithCategories(addSecondGroupingToDefaultCategory);
- }
-
- @Test // (enabled=false)
- public void createProductTwoSubsDifferentGroupings() throws Exception {
- // Category1->[Subcategory1->[Grouping1,
- // Grouping11],Subcategory2->[Grouping12]]
- List<CategoryDefinition> addSubcategoryAndGroupingToDefaultCategory = addSubcategoryAndGroupingToDefaultCategory();
- createProductWithCategories(addSubcategoryAndGroupingToDefaultCategory);
- }
-
- @Test // (enabled=false)
- public void createManyGroupingsDiffCategories() throws Exception {
- // [Category1->[Subcategory1->[Grouping1,
- // Grouping11],Subcategory2->[Grouping12]],
- // Category2->[Subcategory1->[Grouping1],Subcategory2->[Grouping1]],
- // Category3->[Subcategory1->[Grouping11],Subcategory2->[Grouping11,
- // Grouping22]]]
- List<CategoryDefinition> addSubcategoryAndGroupingToDefaultCategory = addManyGroupingsDiffCategories();
- createProductWithCategories(addSubcategoryAndGroupingToDefaultCategory);
- }
-
- @Test // (enabled=false)
- public void createProductEmptyUserId() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- User emptyUser = new User();
- emptyUser.setUserId("");
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, emptyUser);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION,
- createProduct.getErrorCode().intValue());
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION,
- emptyUser);
- ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(
- expectedProduct, CREATE_AUDIT_ACTION, emptyUser, ActionStatus.MISSING_INFORMATION,
- Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING);
- constructFieldsForAuditValidation.setCURR_STATE("");
- AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION);
- }
-
- @Test // (enabled=false)
- public void createProductNonExistingUserId() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- User notExistingUser = new User();
- notExistingUser.setUserId("jj6444");
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, notExistingUser);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- createProduct.getErrorCode().intValue());
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION,
- notExistingUser);
- ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(
- expectedProduct, CREATE_AUDIT_ACTION, notExistingUser, ActionStatus.RESTRICTED_OPERATION,
- Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING);
- constructFieldsForAuditValidation.setCURR_STATE("");
- AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION);
- }
-
- @Test // (enabled=false)
- public void createProductInvalidJson() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- RestResponse createProduct = ProductRestUtils.createProduct_Invalid_Json(productManager1.getUserId());
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- createProduct.getErrorCode().intValue());
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION,
- productManager1);
- ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(
- expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.INVALID_CONTENT,
- Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING);
- constructFieldsForAuditValidation.setRESOURCE_NAME("");
- constructFieldsForAuditValidation.setCURR_STATE("");
- AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION);
- }
-
- @Test // (enabled=false)
- public void createProductAdminRoleNotAllowed() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- User wrongRole = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, wrongRole);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- createProduct.getErrorCode().intValue());
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION,
- wrongRole);
- ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(
- expectedProduct, CREATE_AUDIT_ACTION, wrongRole, ActionStatus.RESTRICTED_OPERATION,
- Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING);
- constructFieldsForAuditValidation.setCURR_STATE("");
- AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION);
- }
-
- @Test // (enabled=false)
- public void createProductProductStrategistRoleNotAllowed() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- User wrongRole = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST3);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, wrongRole);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- createProduct.getErrorCode().intValue());
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION,
- wrongRole);
- ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(
- expectedProduct, CREATE_AUDIT_ACTION, wrongRole, ActionStatus.RESTRICTED_OPERATION,
- Constants.EMPTY_STRING, Constants.EMPTY_STRING, null, null, Constants.EMPTY_STRING);
- constructFieldsForAuditValidation.setCURR_VERSION("");
- constructFieldsForAuditValidation.setCURR_STATE("");
- AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION);
- }
-
- @Test // (enabled=false)
- public void getProductSuccessFlow() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
-
- RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- assertEquals("Check response code after getting created Product", BaseRestUtils.STATUS_CODE_SUCCESS,
- getProductRes.getErrorCode().intValue());
-
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.GET_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void getNonExistedProduct() throws Exception {
-
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
-
- RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- assertEquals("Check response code after getting created Product", BaseRestUtils.STATUS_CODE_SUCCESS,
- getProductRes.getErrorCode().intValue());
-
- Product product = ResponseParser.parseToObjectUsingMapper(getProductRes.getResponse(), Product.class);
- assertEquals("Assert on product icon", productReqDetails.getName(), product.getName());
-
- RestResponse deleteProductRes = ProductRestUtils.deleteProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- assertEquals("Check response code for deletign Product", BaseRestUtils.STATUS_CODE_SUCCESS,
- deleteProductRes.getErrorCode().intValue());
-
- RestResponse getProductAfterDeleteRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- assertEquals("Check response code after getting deleted Product", BaseRestUtils.STATUS_CODE_NOT_FOUND,
- getProductAfterDeleteRes.getErrorCode().intValue());
- }
-
- @Test // (enabled=false)
- public void getProductMissingHeader() throws Exception {
-
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
-
- productManager1.setUserId(null);
- RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- assertEquals("Check response code after getting created Producuct with userId extracted from header",
- BaseRestUtils.STATUS_CODE_MISSING_INFORMATION, getProductRes.getErrorCode().intValue());
-
- }
-
- @Test // (enabled=false)
- public void getProductNonExistingUser() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
-
- productManager1.setUserId("bt1111");
- RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- assertEquals("Check response code after getting created Producuct with non exsisting user",
- BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION, getProductRes.getErrorCode().intValue());
- }
-
- @Test // (enabled=false)
- public void createProductAndGetProductWithDifferentUser() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
- User sdncProductStrategistUserAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- sdncProductStrategistUserAdminDetails.getUserId());
- assertEquals("Check response code after getting created Product different user role",
- BaseRestUtils.STATUS_CODE_SUCCESS, getProductRes.getErrorCode().intValue());
- }
-
- // US594753 - Update Product metadata
-
- // If user update "product name" we need to remove the old product name from
- // "Tags" and add the new product name instead - will handled in mew US
- @Test(enabled = false)
- public void updateProductAllFieldsByPM() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- // Update product
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("NewProductName");
- List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory();
- productReqDetails.setFullName("New Full name");
- productReqDetails.setActive("false");
- productReqDetails.setContacts(
- Arrays.asList(productManager2.getUserId().toLowerCase(), productManager1.getUserId().toLowerCase()));
- productReqDetails.setDescription("New Product Description");
- productReqDetails.setIcon("asdfghjklqwertyuiozxcvbfv");
- productReqDetails.setProjectCode("98765");
- productReqDetails.setCategories(addSecondGroupingToDefaultCategory);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // productReqDetails.setTags(Arrays.asList(productReqDetails.getName(),
- // productOldName));
- productReqDetails.setTags(Arrays.asList(productReqDetails.getName()));
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductByPS() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("New discription");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productStrategistUser1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- }
-
- @Test // (enabled=false)
- public void updateProductByAdmin() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("New discription");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, designerUser);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- }
-
- @Test // (enabled=false)
- public void updateProductByNonPmUser() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- // Update product name
- productReqDetails.setDescription("New discription");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, designerUser);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- }
-
- @Test // (enabled=false)
- public void updateProductByNonAsdcUser() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- // Update product name
- productReqDetails.setDescription("New discription");
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- nonAsdcUser.setUserId("bt789k");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, nonAsdcUser);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- }
-
- @Test // (enabled=false)
- public void updateProductUserIdIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- // Update product name
- productReqDetails.setDescription("New discription");
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- nonAsdcUser.setUserId("");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, nonAsdcUser);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_MISSING_INFORMATION,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- }
-
- @Test // (enabled=false)
- public void updateProductByNonProductOwner() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- ProductRestUtils.checkCreateResponse(createProduct);
- Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("New discription");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.GET_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductNotInCheckoutState() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- ProductRestUtils.checkCreateResponse(createProduct);
- Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- // Update product name
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- String valueFromJsonResponse = ResponseParser.getValueFromJsonResponse(changeProductLifeCycle.getResponse(),
- "lastUpdateDate");
- expectedProduct.setLastUpdateDate(Long.parseLong(valueFromJsonResponse));
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductNameIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("abbreviated");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductNameIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager2,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- // List<String> tags = productReqDetails.getTags();
- // tags.removeAll(tags);
- productReqDetails.setTags(new ArrayList<>());
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName(null); // no update will be performed
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2);
- ProductRestUtils.checkSuccess(updateProduct);
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager2);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(product.getName().toLowerCase());
- expectedProduct.setName(product.getName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductNameLessThanMinLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("ABC"); // no update will be performed
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("abbreviated");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(),
- varibales, updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- // If user update "product name" we need to remove the old product name from
- // "Tags" and add the new product name instead - will handled in mew US
- @Test(enabled = false)
- public void updateProductNameHasMinLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager2,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("NewP");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setTags(Arrays.asList(productReqDetails.getName()));
- productReqDetails.setLastUpdaterUserId(productManager2.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager2.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager2);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- // If user update "product name" we need to remove the old product name from
- // "Tags" and add the new product name instead - will handled in mew US
- // DE193857 - Normalized Name is not removing special characters
- @Test(enabled = false)
- public void updateProductNameMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- // Update product name
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("Ac_2B3U4k mSKnob-u.j-uGgP");
- String newNormalizedName = "ac2b3u4kmsknobujuggp";
- String newName = "Ac_2B3U4k MSKnob-u.j-uGgP";
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setTags(Arrays.asList(newName));
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(newNormalizedName);
- expectedProduct.setName(newName);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductNameExceedMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("Ac_2B3U4k mSKnob-u.j-uGgPx");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("abbreviated");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(),
- varibales, updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductNameAlreadyExist() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager2);
- ProductRestUtils.checkCreateResponse(createProduct);
- Product product1 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product1, productManager2,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setName("Product2000");
- // productReqDetails.setTags(Arrays.asList(productReqDetails.getName()));
- createProduct = ProductRestUtils.createProduct(productReqDetails, productManager2);
- ProductRestUtils.checkCreateResponse(createProduct);
- Product product2 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product2, productManager2,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product2, productManager2,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product2.getUniqueId());
- productReqDetails.setUUID(product2.getUUID());
- productReqDetails.setName(product1.getName());
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager2);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_ALREADY_EXISTS,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add(product1.getName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager2.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product2.getUniqueId());
- expectedProduct.setVersion(product2.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- // DE193857 - Normalized Name is not removing special characters
- // If user update "product name" we need to remove the old product name from
- // "Tags" and add the new product name instead - will handled in mew US
- @Test(enabled = false)
- public void updateProductNameAllowedCharacters() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- // Update product name
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("A_BU4k m&K=o#b-u.j-uG'g+P"); // Allowed
- // characters
- // [a-z,A-Z,0-9]
- // , ‘ ‘
- // (space),
- // ampersand
- // "&", dash
- // “-“, plus
- // "+", period
- // ".",
- // apostrophe
- // "'", hashtag
- // "#", equal
- // "=", period
- // ":", at "@",
- // and
- // underscore
- // "_"
- String newNormalizedName = "abu4km&kobujuggp";
- String newName = "A_BU4k M&K=o#b-u.j-uG'g+P";
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setTags(Arrays.asList(newName));
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(newNormalizedName);
- expectedProduct.setName(newName);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- // If user update "product name" we need to remove the old product name from
- // "Tags" and add the new product name instead - will handled in mew US
- @Test(enabled = false)
- public void updateProductNameRemoveSpaceFromBeginning() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName(" asdfg");
- String newNormalizedName = "asdfg";
- String newName = "Asdfg";
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // productReqDetails.setTags(Arrays.asList(newName, productOldName));
- productReqDetails.setTags(Arrays.asList(newName));
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(newNormalizedName);
- expectedProduct.setName(newName);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- // If user update "product name" we need to remove the old product name from
- // "Tags" and add the new product name instead - will handled in mew US
- @Test(enabled = false)
- public void updateProductNameRemoveSpaceFromEnd() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("asdfg fc ");
- String newNormalizedName = "asdfgfc";
- String newName = "Asdfg Fc";
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // productReqDetails.setTags(Arrays.asList(newName, productOldName));
- productReqDetails.setTags(Arrays.asList(newName));
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(newNormalizedName);
- expectedProduct.setName(newName);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- //// DE193857 - Normalized Name is not removing special characters
- // If user update "product name" we need to remove the old product name from
- //// "Tags" and add the new product name instead - will handled in mew US
- @Test(enabled = false)
- public void updateProductNameRemoveExtraNonAlphanumericChars() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("A__k &&==##---u..hG'''+++");
- String newNormalizedName = "akhg";
- String newName = "A_k &=#-u.hG'+";
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // productReqDetails.setTags(Arrays.asList(newName, productOldName));
- productReqDetails.setTags(Arrays.asList(newName));
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(newNormalizedName);
- expectedProduct.setName(newName);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- // If user update "product name" we need to remove the old product name from
- // "Tags" and add the new product name instead - will handled in mew US
- @Test(enabled = false)
- public void updateProductNameValidationStartWithNumber() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("1000Ab");
- String newNormalizedName = productReqDetails.getName().toLowerCase();
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setTags(Arrays.asList(productReqDetails.getName()));
- // productReqDetails.setTags(Arrays.asList(productReqDetails.getName(),
- // productOldName));
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setNormalizedName(newNormalizedName);
- expectedProduct.setName(productReqDetails.getName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductNameValidationStartWithNonAlphaNumeric() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setName("_1000Ab");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("abbreviated");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT.name(),
- varibales, updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductFullNameIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName("");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("full");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_ONE_OF_COMPONENT_NAMES.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductFullNameIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName(null);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setNormalizedName(product.getNormalizedName());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setFullName(product.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductFullNameHasMinLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName("asdc");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setNormalizedName(product.getNormalizedName());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setFullName(productReqDetails.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductFullNameHasMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName(
- "1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setNormalizedName(product.getNormalizedName());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setFullName(productReqDetails.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductFullNamelessThanMinLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName("123");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("full");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(),
- varibales, updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductFullNameExceedMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName(
- "1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjkx");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("full");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH.name(),
- varibales, updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- // DE193947
- @Test
- public void updateProductFullNameWithSpecialCharacters() throws Exception {
- char invalidChars[] = { '~', '!', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|',
- '\\', ',', '$', '#', '@', '+' };
- String fullName = "avbng";
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- for (int i = 0; i < invalidChars.length; i++) {
- productReqDetails.setFullName(fullName + invalidChars[i]);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS,
- updateProduct.getErrorCode().intValue());
- }
- }
-
- @Test // (enabled=false)
- public void updateProductFullNameValidCharactersCharacters01() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName("qwertyuiopasdfghjklzxcvbnm1234567890<b>Bold<</b>");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setNormalizedName(product.getNormalizedName());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setFullName("qwertyuiopasdfghjklzxcvbnm1234567890Bold&lt;");
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductFullNameRemoveExtraSpaces() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setFullName("Abbaaa a1");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setNormalizedName(product.getNormalizedName());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setFullName("Abbaaa a1");
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription(null);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test(enabled = false)
- public void updateProductDescriptionValidCharacters01() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("~!@#$%^&*()_+<>?qwertyuiopasdfghjklzxcvbnm1234567890#");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setDescription("~!@#$%^&amp;*()_+&lt;&gt;?qwertyuiopasdfghjklzxcvbnm1234567890#");
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionValidCharacters02() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("qwertyuiopasdfghjklzxcvbnm1234567890<b>Bold<</b>");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setDescription("qwertyuiopasdfghjklzxcvbnm1234567890Bold<");
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionInValidCharacters() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("מה");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_DESCRIPTION.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionRemoveSpacesFromBeginning() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription(" abcd12345 g");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setDescription(" abcd12345 g");
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionRemoveSpacesFromTheEnd() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setDescription("abcd12345 gdf ");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setDescription("abcd12345 gdf ");
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- String description = "1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfg";
- productReqDetails.setDescription(description);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setDescription(description);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductDescriptionExceedMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- String description = "01234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjk aa1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfg";
- productReqDetails.setDescription(description);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("1024");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(),
- varibales, updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductTagIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(Arrays.asList(""));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- varibales.add("tag");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductTagIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(null);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setTags(product.getTags());
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductTagsNameValidationProductNameIsNotInTag() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(Arrays.asList("Abc"));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
- new ArrayList<String>(), updateProduct.getResponse());
- }
-
- @Test // (enabled=false)
- public void createProductSingleTagMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(
- Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345678"));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setTags(productReqDetails.getTags());
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductSingleTagExceedMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(Arrays.asList(productReqDetails.getName(),
- "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("1024");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductAllTagsMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(
- Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345601",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345602",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345603",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345604",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345605",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345606",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345607"));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setTags(productReqDetails.getTags());
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductAllTagsExceedMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(
- Arrays.asList(productReqDetails.getName(), "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345601",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345602",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345603",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345604",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345605",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345606",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345607",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345608",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh1234569",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345610",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345611",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345612",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345613",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345614",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345615",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345616",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345617",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345618",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh12345619",
- "Abba1234567890asdfghjkl123zxcvbnm432asdfgh123456"));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("1024");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductTagsDuplicateTagRemoved() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setTags(Arrays.asList(productReqDetails.getName(), "KoKo", "KoKo"));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata updated
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setTags(Arrays.asList(productReqDetails.getName(), "KoKo"));
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductContactsIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setContacts(Arrays.asList(""));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductContactsIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setContacts(null);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductContactsInvalidFormat() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setContacts(Arrays.asList("bt750345"));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(COMPONENT_TYPE);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductConvertContactsToLowerCase() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setContacts(Arrays.asList(productManager2.getUserId().toUpperCase()));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct
- .setContacts(Arrays.asList(productManager2.getUserId().toLowerCase(), productManager1.getUserId()));
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductContactsNotAllowedAsdcUsers() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setContacts(Arrays.asList(productStrategistUser1.getUserId()));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(productStrategistUser1.getUserId());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PRODUCT_CONTACT.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductContactsNotAsdcUser() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- String nonAsdcUserUserId = "bt567h";
- productReqDetails.setContacts(Arrays.asList(nonAsdcUserUserId));
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(nonAsdcUserUserId);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PRODUCT_CONTACT.name(), varibales,
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductProjectCodeIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setProjectCode("");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_PROJECT_CODE.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductProjectCodeIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setProjectCode(null);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setProjectCode(product.getProjectCode());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductProjectCodeLessThanMinCharacters() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setProjectCode("9870");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROJECT_CODE.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductProjectCodeHasnMinCharacters() throws Exception { // min
- // =5
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setProjectCode("98700");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setProjectCode(productReqDetails.getProjectCode());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductProjectCodeHasnMaxCharacters() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setProjectCode("1234567890");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setProjectCode(productReqDetails.getProjectCode());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductProjectCodeExceedMaxCharacters() throws Exception {// Max
- // =10
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setProjectCode("12345678901");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROJECT_CODE.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setProjectCode(product.getProjectCode());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductProjectCodeIsNotNumeric() throws Exception {
- // Max =10
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setProjectCode("1234a");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROJECT_CODE.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setProjectCode(product.getProjectCode());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIconIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setIcon("");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> variables = new ArrayList<String>();
- variables.add(COMPONENT_TYPE);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), variables,
- updateProduct.getResponse());
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIcon(product.getIcon());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIconIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setIcon(null);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- // Get Product and verify that metadata didn't change
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIcon(product.getIcon());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIconMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setIcon("A_a-1-2--b__BB1234567890A"); // Max length =
- // 25
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIcon(productReqDetails.getIcon());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIconExceedMaxLength() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setIcon("A_a-1-2--b__BB1234567890A_");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> variables = new ArrayList<String>();
- variables.add(COMPONENT_TYPE);
- variables.add("25");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), variables,
- updateProduct.getResponse());
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIcon(product.getIcon());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIconInValidCharacters() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- String icon = "asdfg"; // Allowed characters [a-zA-Z0-9], dash (‘-‘),
- // underscore (‘_’).
- char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/',
- '|', '\\', ',' };
- RestResponse updateProduct;
- for (int i = 0; i < invalidChars.length; i++) {
- productReqDetails.setIcon(icon + invalidChars[i]);
- updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ArrayList<String> variables = new ArrayList<String>();
- variables.add(COMPONENT_TYPE);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), variables,
- updateProduct.getResponse());
- }
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIcon(product.getIcon());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIsActiveIsEmpty() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setActive("");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIsActive(false);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIsActiveIsTrue() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setActive("true");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIsActive(true);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIsActiveIsNull() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(defaultCategories);
- productReqDetails.setActive("true");
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- ProductRestUtils.checkCreateResponse(createProduct);
- Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setActive(null);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIsActive(true);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIsActiveIsFalse() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setActive("false");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- expectedProduct.setIsActive(false);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductIsActiveHasInvalidValue() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setActive("eeeee");
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), new ArrayList<String>(),
- updateProduct.getResponse());
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_INVALID_CONTENT,
- updateProduct.getErrorCode().intValue());
- RestResponse getProduct = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- ProductRestUtils.checkSuccess(getProduct);
- Product expectedProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- expectedProduct.setUniqueId(product.getUniqueId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getProduct.getResponse(), Product.class);
- expectedProduct.setVersion(product.getVersion());
- expectedProduct.setLastUpdaterUserId(productManager1.getUserId());
- expectedProduct.setLastUpdaterFullName(productManager1.getFullName());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductAssociations() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory();
- productReqDetails.setCategories(addSecondGroupingToDefaultCategory);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setCategories(productReqDetails.getCategories());
- expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductAssociations02() throws Exception {
- List<CategoryDefinition> addSecondGroupingToDefaultCategory = addSecondGroupingToDefaultCategory(); // Category1->Subcategory1->[Grouping1,
- // Grouping11]
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(addSecondGroupingToDefaultCategory);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- ProductRestUtils.checkCreateResponse(createProduct);
- Product product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- List<CategoryDefinition> defaultCategory = addSubcategoryAndGroupingToDefaultCategory(); // Category1->[Subcategory1->[Grouping1,
- // Grouping11],Subcategory2->[Grouping12]]
- productReqDetails.setCategories(defaultCategory);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setCategories(productReqDetails.getCategories());
- expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductRemoveAllAssociations() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- List<CategoryDefinition> defaultCategory = new ArrayList<CategoryDefinition>();
- productReqDetails.setCategories(defaultCategory);
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setCategories(productReqDetails.getCategories());
- expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- @Test // (enabled=false)
- public void updateProductAssociationsCategotyIsNull() throws Exception {
- createProducrByPSAndCheckIn();
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- productReqDetails.setUniqueId(product.getUniqueId());
- productReqDetails.setUUID(product.getUUID());
- productReqDetails.setCategories(null);// product categories will not be
- // updated
- RestResponse updateProduct = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- ProductRestUtils.checkSuccess(updateProduct);
- productReqDetails.setLastUpdaterUserId(productManager1.getUserId());
- productReqDetails.setLastUpdaterFullName(productManager1.getFullName());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(updateProduct.getResponse(), Product.class);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, "0.2", productManager1);
- expectedProduct.setUUID(product.getUUID());
- expectedProduct.setInvariantUUID(product.getInvariantUUID());
- expectedProduct.setCategories(product.getCategories());
- expectedProduct.setNormalizedName(productReqDetails.getName().toLowerCase());
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.UPDATE_COMPONENT);
- }
-
- ////////////////////////////////////////////////////////////////////////
-
- private void createProductWithCategories(List<CategoryDefinition> categoryDefinitions) throws Exception {
- ProductReqDetails productReqDetails = (categoryDefinitions != null
- ? ElementFactory.getDefaultProduct(categoryDefinitions) : ElementFactory.getDefaultProduct());
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- String actualUuid = ResponseParser.getUuidFromResponse(createProduct);
- Product expectedProduct = Convertor.constructFieldsForRespValidation(productReqDetails, INITIAL_PRODUCT_VERSION,
- productManager1);
- String normalizedNameFomJsonResponse = ResponseParser.getValueFromJsonResponse(createProduct.getResponse(),
- "normalizedName");
- expectedProduct.setNormalizedName(normalizedNameFomJsonResponse);
- ProductValidationUtils.compareExpectedAndActualProducts(expectedProduct, actualProduct,
- ComponentOperationEnum.CREATE_COMPONENT);
- ExpectedProductAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(
- expectedProduct, CREATE_AUDIT_ACTION, productManager1, ActionStatus.CREATED, Constants.EMPTY_STRING,
- "0.1", null, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, actualUuid);
- AuditValidationUtils.validateAuditProduct(constructFieldsForAuditValidation, CREATE_AUDIT_ACTION);
- }
-
- private void createProducrByPSAndCheckIn() throws Exception {
- productReqDetails = ElementFactory.getDefaultProduct(defaultCategories);
- createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- ProductRestUtils.checkCreateResponse(createProduct);
- product = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
- RestResponse changeProductLifeCycle = ProductRestUtils.changeProductLifeCycle(product, productManager1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeProductLifeCycle);
- }
-
- @Test
- public void checkInvariantUuidIsImmutable() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- String invariantUuidDefinedByUser = "!!!!!!!!!!!!!!!!!!!!!!!!";
- productReqDetails.setInvariantUUID(invariantUuidDefinedByUser);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- BaseRestUtils.checkStatusCode(createProduct, "create request failed", false, 201);
- assertEquals("Check response code after create Product", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
- Product ProductCreation = ResponseParser.convertProductResponseToJavaObject(createProduct.getResponse());
- String invariantUUIDcreation = ProductCreation.getInvariantUUID();
-
- // validate get response
- RestResponse getProductRes = ProductRestUtils.getProduct(productReqDetails.getUniqueId(),
- productManager1.getUserId());
- BaseRestUtils.checkSuccess(getProductRes);
- Product productGetting = ResponseParser.convertProductResponseToJavaObject(getProductRes.getResponse());
- String invariantUUIDgetting = productGetting.getInvariantUUID();
- assertEquals(invariantUUIDcreation, invariantUUIDgetting);
-
- // Update Product with new invariant UUID
- RestResponse restResponseUpdate = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- BaseRestUtils.checkSuccess(restResponseUpdate);
- Product updatedProduct = ResponseParser.convertProductResponseToJavaObject(restResponseUpdate.getResponse());
- String invariantUUIDupdating = updatedProduct.getInvariantUUID();
- assertEquals(invariantUUIDcreation, invariantUUIDupdating);
-
- // Do checkin
- RestResponse restResponseCheckin = LifecycleRestUtils.changeProductState(productReqDetails, productManager1,
- LifeCycleStatesEnum.CHECKIN);
- BaseRestUtils.checkSuccess(restResponseCheckin);
- Product checkinProduct = ResponseParser.convertProductResponseToJavaObject(restResponseCheckin.getResponse());
- String invariantUUIDcheckin = checkinProduct.getInvariantUUID();
- String version = checkinProduct.getVersion();
- assertEquals(invariantUUIDcreation, invariantUUIDcheckin);
- assertEquals(version, "0.1");
-
- // Do checkout
- RestResponse restResponseCheckout = LifecycleRestUtils.changeProductState(productReqDetails, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- BaseRestUtils.checkSuccess(restResponseCheckout);
- Product checkoutProduct = ResponseParser.convertProductResponseToJavaObject(restResponseCheckout.getResponse());
- String invariantUUIDcheckout = checkoutProduct.getInvariantUUID();
- version = checkoutProduct.getVersion();
- assertEquals(invariantUUIDcreation, invariantUUIDcheckout);
- assertEquals(version, "0.2");
-
- }
-
- // US672129 Benny
- private void getProductValidateInvariantUuid(String productUniqueId, String invariantUUIDcreation)
- throws Exception {
- RestResponse getProduct = ProductRestUtils.getProduct(productUniqueId,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId());
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, getProduct.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(getProduct));
- }
-
- @Test // invariantUUID generated when the component is created and never
- // changed
- public void productInvariantUuid() throws Exception {
- ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct();
- String invariantUuidDefinedByUser = "12345";
- productReqDetails.setInvariantUUID(invariantUuidDefinedByUser);
- RestResponse createProduct = ProductRestUtils.createProduct(productReqDetails, productManager1);
- assertEquals("Check response code after create resource", BaseRestUtils.STATUS_CODE_CREATED,
- createProduct.getErrorCode().intValue());
- // invariantUUID generated when the component is created and never
- // changed
- String invariantUUIDcreation = ResponseParser.getInvariantUuid(createProduct);
- getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation);
- // Update Product with new invariant UUID
- RestResponse restResponse = ProductRestUtils.updateProduct(productReqDetails, productManager1);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation);
- // Checkin
- restResponse = LifecycleRestUtils.changeProductState(productReqDetails, productManager1,
- LifeCycleStatesEnum.CHECKIN);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation);
- // Checkout
- restResponse = LifecycleRestUtils.changeProductState(productReqDetails, productManager1,
- LifeCycleStatesEnum.CHECKOUT);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation);
-
- // UnDo-CheckOut
- restResponse = LifecycleRestUtils.changeProductState(productReqDetails, productManager1,
- LifeCycleStatesEnum.UNDOCHECKOUT);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getProductValidateInvariantUuid(productReqDetails.getUniqueId(), invariantUUIDcreation);
-
- }
-
-}
diff --git a/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
deleted file mode 100644
index 8bb637e8dc..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java
+++ /dev/null
@@ -1,1792 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.property;
-
-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.ComponentInstanceProperty;
-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.*;
-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.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.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
- public static TestName name = new TestName();
-
- public ComponentProperty() {
- super(name, ComponentProperty.class.getName());
- }
-
- @DataProvider
- private static final Object[][] propertiesListDefaultValueSuccessFlow() throws IOException, Exception {
- return new Object[][] {
- // integer
- { "integer", "[1,2]", "[1,2]" },
- { "tosca.datatypes.Credential",
- "[{\"protocol\":\"protocol1\",\"token\":\"token1\"},{\"protocol\":\"protocol2\",\"token\":\"token2\"}]",
- "[{\"protocol\":\"protocol1\",\"token\":\"token1\"},{\"protocol\":\"protocol2\",\"token\":\"token2\"}]" },
- { "tosca.datatypes.Credential",
- "[{\"protocol\":\"protocol1\",\"token\":\"token1\"},{\"protocol\":\"protocol<br>2\",\"token\":\"token2 2\"}]",
- "[{\"protocol\":\"protocol1\",\"token\":\"token1\"},{\"protocol\":\"protocol2\",\"token\":\"token2 2\"}]" },
- { "tosca.datatypes.Credential", null, null }, { "tosca.datatypes.Credential", "[]", "[]" },
- { "integer", "[1,2,1,2]", "[1,2,1,2]" }, { "integer", "[1,,2]", "[1,2]" },
- { "integer", "[1,null,2]", "[1,2]" }, { "integer", "[1,2,null]", "[1,2]" },
- { "integer", "[null,1,2]", "[1,2]" }, { "integer", "[1,,2]", "[1,2]" },
- { "integer", "[,1,2]", "[1,2]" },
- // {"integer",
- // "[1000000000000000000000000000000000000000000000000000,2]" ,
- // "[1000000000000000000000000000000000000000000000000000,2]"},
- { "integer", "[100000000,2]", "[100000000,2]" }, // Andrey, in
- // success
- // flow
- // integer
- // max value
- // is
- // 2147483647
- { "integer", null, null }, // no default value
- { "integer",
- "[1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2]",
- "[1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2]" },
- // boolean
- { "boolean", "[true,false]", "[true,false]" },
- { "boolean", "[true,false,false]", "[true,false,false]" },
- { "boolean", "[null,true,false]", "[true,false]" }, { "boolean", "[true,false,null]", "[true,false]" },
- { "boolean", "[true,,false]", "[true,false]" }, { "boolean", "[true,false,]", "[true,false]" },
- { "boolean", "[,true,false]", "[true,false]" }, { "boolean", null, null },
- // DE199713 - Default value for property type Boolean should
- // support also the following values: "true", "t" , "on" , "1" ,
- // "false", "f" , "off" , "0"
- { "boolean", "[on,off]", "[true,false]" }, { "boolean", "[ON,OFF]", "[true,false]" },
- { "boolean", "[On,Off]", "[true,false]" }, { "boolean", "[yes,no]", "[true,false]" },
- { "boolean", "[YES,NO]", "[true,false]" }, { "boolean", "[Yes,No]", "[true,false]" },
- { "boolean", "[y,n]", "[true,false]" }, { "boolean", "[Y,N]", "[true,false]" },
- // float
- { "float", "[10.0,0.0]", "[10.0,0.0]" }, { "float", "[10,0]", "[10,0]" }, // contain
- // integer
- { "float", "[-10,-5.30]", "[-10,-5.30]" }, // Negative numbers
- { "float", "[10,null,0]", "[10,0]" }, { "float", "[null,10,0]", "[10,0]" },
- { "float", "[10,0,null]", "[10,0]" },
- { "float", "[10,0.1111111111111111111111111111111111111111]",
- "[10,0.1111111111111111111111111111111111111111]" },
- { "float", "[10, ,7.3 ]", "[10,7.3]" }, { "float", "[10 , 7.3 , ]", "[10,7.3]" },
- { "float", "[, , 10 , 7.3 , ]", "[10,7.3]" }, { "float", "[4.7f, -5.5f ]", "[4.7,-5.5]" },
- { "float", "[4.7f, 6.3 ,6.3, 4.7f]", "[4.7,6.3,6.3,4.7]" }, // duplicate
- // value
- { "float", null, null }, { "string", "[aaaa , AAAA ]", "[\"aaaa\",\"AAAA\"]" },
-
- { "string",
- "[1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2]",
- "[\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\",\"1\",\"2\"]" },
- { "string", "[aaaa , AAAA, 1, off , true, false ]",
- "[\"aaaa\",\"AAAA\",\"1\",\"off\",\"true\",\"false\"]" },
- { "string", "[aaaa , AAAA, aaaa, Aaaa , aaaa ]", "[\"aaaa\",\"AAAA\",\"aaaa\",\"Aaaa\",\"aaaa\"]" },
- { "string", "[aaaa , AAAA, , ]", "[\"aaaa\",\"AAAA\"]" },
- { "string", "[ , aaaa , AAAA ]", "[\"aaaa\",\"AAAA\"]" },
- { "string", "[ aaaa , , AAAA ]", "[\"aaaa\",\"AAAA\"]" },
- { "string", "[ aaaa , AAAA, null ]", "[\"aaaa\",\"AAAA\"]" },
- { "string", "[ null, aaaa , AAAA ]", "[\"aaaa\",\"AAAA\"]" },
- { "string", "[ aaaa , null , AAAA ]", "[\"aaaa\",\"AAAA\"]" }, { "string", null, null }, // without
- // default
- // values
- // -
- // Property
- // will
- // be
- // without
- // default
- // parameter
- { "string", "[ <b>AAA</b> ]", "[\"AAA\"]" }, // BUG DE199715 -
- // Error 400
- // response
- // received
- // while adding
- // property with
- // default value
- // contain HTML
- // tags.
- // Need to check
- // whether / is
- // legal in yaml
-
- };
- }
-
- @DataProvider
- private static final Object[][] invalidListProperties() throws IOException, Exception {
- return new Object[][] {
-
- { "integer", "[1,aaa]" },
- { "tosca.datatypes.Credential",
- "[{\"protocol\":\"protocol1\",\"token\":\"token1\"},{\"protocol\":\"protocol2\",\"token1\":\"token2\"}]" },
- { "integer", "[1,false]" }, { "integer", "[1,3.5]" }, { "integer", "[1,3#]" },
- { "boolean", "[true,3.5]" }, { "boolean", "[true,1000]" }, { "boolean", "[false,trueee]" },
- { "boolean", "[true,false!]" }, { "float", "[5.0000001,true]" }, { "float", "[0.0001,koko]" },
- { "float", "[0.0001,6.3@]" }, { "float", "[0.0001f,6.3x]" }, };
- }
-
- @DataProvider
- private static final Object[][] updatePropertiesListDefaultValueSuccessFlow() throws IOException, Exception {
- return new Object[][] {
- // integer
- // Setting --- update properties
- // -----------------------------------------------------------------------
- { "integer", "[1,2]", "[1,2]", "integer", "[200,100]", "[200,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[200,100,null]", "[200,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[null, 200,100]", "[200,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[200,null,100]", "[200,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[200,100, ]", "[200,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[ , 200,100 ]", "[200,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[200 , ,100 ]", "[200,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", null, null },
- { "integer", "[1,2]", "[1,2]", "integer", "[200 , 100 , 200, 100]", "[200,100,200,100]" },
- //
- // ////DE199829 update resource property schema_type is not
- // updated
- { "integer", "[1,2]", "[1,2]", "string", "[aaaa , bbbb ]", "[\"aaaa\",\"bbbb\"]" },
- { "integer", "[1,2]", "[1,2]", "boolean", "[true , false ]", "[true,false]" },
- { "integer", "[1,2]", "[1,2]", "float", "[3.5,4.8f ]", "[3.5,4.8]" },
- // {"string", "[aaa,bbb]" , "[\"aaa\",\"bbb\"]","integer","[100,
- // 200]" , "[\"100\",\"200\"]"},
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "integer", "[100, 200]", "[100,200]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "float", "[0.1f, 3.01]", "[0.1,3.01]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "boolean", "[true, false]", "[true,false]" },
- { "float", "[1.2,2.3]", "[1.2,2.3]", "boolean", "[true, false]", "[true,false]" },
- { "float", "[1.2,2.3]", "[1.2,2.3]", "integer", "[100, 200]", "[100,200]" },
- { "float", "[1.2,2.3]", "[1.2,2.3]", "string", "[koko, moko]", "[\"koko\",\"moko\"]" },
- { "boolean", "[true,false]", "[true,false]", "string", "[koko, moko]", "[\"koko\",\"moko\"]" },
- // {"boolean", "[true,false]" ,
- // "[\"true\",\"false\"]","integer","[100, 300000000000000]" ,
- // "[\"100\",\"300000000000000\"]"},// Andrey, value not valid
- // for integer success flow
- { "boolean", "[true,false]", "[true,false]", "integer", "[100,2147483647]", "[100,2147483647]" }, // Andrey,
- // in
- // success
- // flow
- // integer
- // max
- // value
- // is
- // 2147483647
- { "boolean", "[true,false]", "[true,false]", "float", "[3.000000000000002, 5.67f]",
- "[3.000000000000002,5.67]" },
- // ////DE199829
- //
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[xxx, yyy]", "[\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[xxx , yyy ,null]", "[\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[null, xxx, yyy]", "[\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[xxx ,null,yyy]", "[\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[xxx ,yyy, ]", "[\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[ , xxx,yyy ]", "[\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[xxx , ,yyy ]", "[\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[ xxx , yyy , xxx , yyy]",
- "[\"xxx\",\"yyy\",\"xxx\",\"yyy\"]" },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", null, null },
- { "string", "[aaa,bbb]", "[\"aaa\",\"bbb\"]", "string", "[xxx_-x, y__y--y]",
- "[\"xxx_-x\",\"y__y--y\"]" },
- // DE199715
- // {"string", "[aaa,bbb]" , "[\"aaa\",\"bbb\"]", "string" ,
- // "[\"<b>xxx</b>\", \"<b>yyy</b>\"]" , "[\"xxx\",\"yyy\"]"},
- //
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[2.1 , -0.1]", "[2.1,-0.1]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[2.1, 0.1 ,null]", "[2.1,0.1]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[null , 2.1, 0.1]", "[2.1,0.1]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[2.1,null,0.1]", "[2.1,0.1]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[2.1,0.1, ]", "[2.1,0.1]" },
- // {"float", "[1.00,0.02]" , "[1.00,0.02]","float","[ ,
- // 2.00000000000001,0.00000000000000100 ]" ,
- // "[2.00000000000001,0.00000000000000100]"},
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[2.1 , ,0.1 ]", "[2.1,0.1]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", null, null },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[2.1f , ,0.1f ]", "[2.1,0.1]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[2.1 , 0.1 , 2.1, 0.1]", "[2.1,0.1,2.1,0.1]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[200 , 100.11]", "[200,100.11]" },
- { "float", "[1.00,0.02]", "[1.00,0.02]", "float", "[-2.35 , 100.11]", "[-2.35,100.11]" },
- //
- { "boolean", "[true,false]", "[true,false]", "boolean", "[false , false]", "[false,false]" },
- { "boolean", "[true,false]", "[true,false]", "boolean", "[false, true ,null]", "[false,true]" },
- { "boolean", "[true,false]", "[true,false]", "boolean", "[null , false, true]", "[false,true]" },
- { "boolean", "[true,false]", "[true,false]", "boolean", "[false,null,true]", "[false,true]" },
- { "boolean", "[true,false]", "[true,false]", "boolean", "[false ,true , ]", "[false,true]" },
- { "boolean", "[true,false]", "[true,false]", "boolean", "[ , false, true ]", "[false,true]" },
- { "boolean", "[true,false]", "[true,false]", "boolean", "[false , ,true ]", "[false,true]" },
- { "boolean", "[true,false]", "[true,false]", "boolean", null, null }, { "boolean", "[true,false]",
- "[true,false]", "boolean", "[false , true , false, true]", "[false,true,false,true]" }, };
- }
-
- @DataProvider
- private static final Object[][] updatePropertiesListDefaultValueFailureFlow() throws IOException, Exception {
- return new Object[][] {
- // integer
- // Setting --- update properties
- // -----------------------------------------------------------------------
- { "integer", "[1,2]", "[1,2]", "integer", "[aaa,bbb]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[true,false]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[1.0,100]" },
- { "integer", "[1,2]", "[1,2]", "integer", "[@12,100]" },
- { "float", "[0.11,0.22]", "[0.11,0.22]", "float", "[aaa, bbb]" },
- { "float", "[0.11,0.22]", "[0.11,0.22]", "float", "[0.88, false]" },
- { "float", "[0.11,0.22]", "[0.11,0.22]", "float", "[0.88g, 0.3]" },
- { "float", "[0.11,0.22]", "[0.11,0.22]", "float", "[@0.88, 0.3]" },
- { "boolean", "[true, false]", "[true,false]", "boolean", "[true, 100]" },
- { "boolean", "[true, false]", "[true,false]", "boolean", "[false, 0.01]" },
- { "boolean", "[true, false]", "[true,false]", "boolean", "[koko, true]" },
- { "boolean", "[true, false]", "[true,false]", "boolean", "[@false, true]" },
-
- };
- }
-
- // Map properties
- @DataProvider
- private static final Object[][] updatePropertiesMapDefaultValueSuccessFlow() throws IOException, Exception {
- return new Object[][] {
- // entrySchemaType , propertyDefaultValues ,
- // expectedDefaultValue , newEntrySchemaType ,
- // newPropertyDefaultValue , newExpectedDefaultValue
- // integer
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "integer",
- "{\"key1\":200,\"key2\":null , \"key3\":300}", "{\"key1\":200,\"key2\":null,\"key3\":300}" },
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "integer",
- "{\"key1\":null,\"key2\":200 , \"key3\":100}", "{\"key1\":null,\"key2\":200,\"key3\":100}" },
- // string
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "string",
- "{\"key1\":\"aaaa\" , \"key2\":\"aaaa\"}", "{\"key1\":\"aaaa\",\"key2\":\"aaaa\"}" },
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "boolean",
- "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}" },
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "float",
- "{\"key1\":3.5 , \"key2\":4.8f}", "{\"key1\":3.5,\"key2\":4.8}" },
- // string
- { "string", "{\"key1\":aaa , \"key2\":bbb}", "{\"key1\":\"aaa\",\"key2\":\"bbb\"}", "string",
- "{\"key1\":xxx , \"key2\":yyy}", "{\"key1\":\"xxx\",\"key2\":\"yyy\"}" },
- // float
- { "float", "{\"key1\":1.00 , \"key2\":0.02}", "{\"key1\":1.00,\"key2\":0.02}", "float",
- "{\"key1\":2.1, \"key2\":-0.1}", "{\"key1\":2.1,\"key2\":-0.1}" },
- { "float", "{\"key1\":1.00 , \"key2\":0.02}", "{\"key1\":1.00,\"key2\":0.02}", "float",
- "{\"key1\":2.1 , \"key2\":0.1 , \"key3\":null}", "{\"key1\":2.1,\"key2\":0.1,\"key3\":null}" },
- // boolean
- { "boolean", "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{\"key1\":false , \"key2\":false}", "{\"key1\":false,\"key2\":false}" },
- { "boolean", "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{\"key1\":false , \"key2\":true , \"key3\":null}",
- "{\"key1\":false,\"key2\":true,\"key3\":null}" },
- // null
- { "boolean", "{\"key1\":null , \"key2\":false}", "{\"key1\":null,\"key2\":false}", "boolean",
- "{\"key1\":false , \"key2\":true , \"key3\":null}",
- "{\"key1\":false,\"key2\":true,\"key3\":null}" },
- // tosca.datatypes.Credential
- { "tosca.datatypes.Credential",
- "{\"key1\":{\"protocol\":\"protocol<br>1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}",
- "{\"key1\":{\"protocol\":\"protocol1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}",
- "tosca.datatypes.Credential",
- "{\"key1\":{\"protocol\":\"protocol<br>1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}",
- "{\"key1\":{\"protocol\":\"protocol1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}" },
-
- };
- }
-
- @DataProvider
- private static final Object[][] propertiesMapDefaultValueSuccessFlow() throws IOException, Exception {
- return new Object[][] {
-
- // entrySchemaType , propertyDefaultValues ,
- // expectedDefaultValue
- //
- // {"string",
- // "{\"vf_module_id\":{\"get_input\":\"vf_module_id\"},
- // \"vnf_idw\": 2}",
- // "{\"vf_module_id\":{\"get_input\":\"vf_module_id\"},
- // \"vnf_idw\": 2}"},
-
- // tosca.datatypes.Credential
- { "tosca.datatypes.Credential",
- "{\"key1\":{\"protocol\":\"protocol<br>1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}",
- "{\"key1\":{\"protocol\":\"protocol1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}" },
- // integer
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}" },
- { "integer", "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":2}",
- "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":2}" },
- { "integer", "{\"key1\":1,\"key2\":null,\"key3\":1,\"key4\":2}",
- "{\"key1\":1,\"key2\":null,\"key3\":1,\"key4\":2}" },
- { "integer", "{\"key1\":null,\"key2\":1,\"key3\":1,\"key4\":2}",
- "{\"key1\":null,\"key2\":1,\"key3\":1,\"key4\":2}" },
- { "integer", "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":null}",
- "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":null}" },
- { "integer", "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":NULL}",
- "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":null}" },
- { "integer", "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":Null}",
- "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":null}" },
- { "integer", "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":nuLL}",
- "{\"key1\":1,\"key2\":2,\"key3\":1,\"key4\":null}" },
- { "integer", null, null }, // no default value
- // //BUG
- //// {"integer",
- // "{\"key1\":1000000000000000000000000000000000000000000000000000,\"key2\":2}"
- // ,"{\"key1\":1000000000000000000000000000000000000000000000000000,\"key2\":2}"},
- { "boolean", "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":true , \"key2\":false, \"key3\":false }",
- "{\"key1\":true,\"key2\":false,\"key3\":false}" },
- { "boolean", "{\"key1\":null , \"key2\":true, \"key3\":false }",
- "{\"key1\":null,\"key2\":true,\"key3\":false}" },
- { "boolean", "{\"key1\":true , \"key2\":Null, \"key3\":false }",
- "{\"key1\":true,\"key2\":null,\"key3\":false}" },
- { "boolean", "{\"key1\":true , \"key2\":false, \"key3\":nULL }",
- "{\"key1\":true,\"key2\":false,\"key3\":null}" },
- { "boolean", null, null },
- { "boolean", "{\"key1\":on , \"key2\":off}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":ON , \"key2\":OFF}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":On , \"key2\":Off}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":yes , \"key2\":no}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":YES , \"key2\":NO}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":Yes , \"key2\":No}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":y , \"key2\":n}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{\"key1\":Y , \"key2\":N}", "{\"key1\":true,\"key2\":false}" },
- { "boolean", "{null:false}", "{\"null\":false}" },
- // float
- { "float", "{\"key1\":10.0 , \"key2\":0.0}", "{\"key1\":10.0,\"key2\":0.0}" },
- { "float", "{\"key1\":10 , \"key2\":0}", "{\"key1\":10,\"key2\":0}" }, // contain
- // integer
- { "float", "{\"key1\":null , \"key2\":Null}", "{\"key1\":null,\"key2\":null}" }, // contain
- // null
- { "float", "{\"key1\":3.5 , \"key2\":nULL}", "{\"key1\":3.5,\"key2\":null}" },
- // BUG
- { "float", "{\"key1\":3.5 , \"key2\":0.1111111111111111111111111111111111111111}",
- "{\"key1\":3.5,\"key2\":0.1111111111111111111111111111111111111111}" },
- { "float", "{\"key1\":4.7f , \"key2\":-5.5f}", "{\"key1\":4.7,\"key2\":-5.5}" },
- { "float", "{\"key1\":4.7f , \"key2\":-5.5f, \"key3\":-5.5f}",
- "{\"key1\":4.7,\"key2\":-5.5,\"key3\":-5.5}" },
- { "boolean", null, null },
- { "string", "{\"key1\":aaaa , \"key2\":AAAA}", "{\"key1\":\"aaaa\",\"key2\":\"AAAA\"}" },
- { "string", "{\"key1\":off , \"key2\":true , \"key3\":1}",
- "{\"key1\":\"off\",\"key2\":\"true\",\"key3\":\"1\"}" },
- { "string", "{\"key1\":aaaa , \"key2\":Aaaa , \"key3\":aaaa}",
- "{\"key1\":\"aaaa\",\"key2\":\"Aaaa\",\"key3\":\"aaaa\"}" },
- { "string", "{\"key1\":aaaa , \"key2\":bbbb , \"key3\":null}",
- "{\"key1\":\"aaaa\",\"key2\":\"bbbb\",\"key3\":null}" },
- { "string", "{\"key1\":NULL , \"key2\":bbbb , \"key3\":aaaa}",
- "{\"key1\":null,\"key2\":\"bbbb\",\"key3\":\"aaaa\"}" },
- { "string", "{\"key1\":aaaa , \"key2\":Null , \"key3\":bbbb}",
- "{\"key1\":\"aaaa\",\"key2\":null,\"key3\":\"bbbb\"}" },
- { "string", null, null }, // without default values - Property
- // will be without default parameter
- { "string", "{\"key1\":\"<b>AAAA</b>\" }", "{\"key1\":\"AAAA\"}" },
-
- };
- }
-
- @DataProvider
- private static final Object[][] updatePropertiesMapDefaultValueFailureFlow() throws IOException, Exception {
- return new Object[][] {
-
- // integer
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "integer",
- "{\"key1\":aaa , \"key2\":bbb}" },
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "integer",
- "{\"key1\":true , \"key2\":false}" },
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "integer",
- "{\"key1\":1.0 , \"key2\":100}" },
- { "integer", "{\"key1\":1 , \"key2\":2}", "{\"key1\":1,\"key2\":2}", "integer",
- "{\"key1\":12@ , \"key2\":100}" },
- // float
- { "float", "{\"key1\":0.11 , \"key2\":0.22}", "{\"key1\":0.11,\"key2\":0.22}", "float",
- "{\"key1\":aaa , \"key2\":bbb}" },
- { "float", "{\"key1\":0.11 , \"key2\":0.22}", "{\"key1\":0.11,\"key2\":0.22}", "float",
- "{\"key1\":0.88 , \"key2\":false}" },
- { "float", "{\"key1\":0.11 , \"key2\":0.22}", "{\"key1\":0.11,\"key2\":0.22}", "float",
- "{\"key1\":0.88g , \"key2\":0.3}" },
- { "float", "{\"key1\":0.11 , \"key2\":0.22}", "{\"key1\":0.11,\"key2\":0.22}", "float",
- "{\"key1\":@0.88g , \"key2\":0.3}" },
- // boolean
- { "boolean", "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{\"key1\":true , \"key2\":100}" },
- { "boolean", "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{\"key1\":false , \"key2\":0.01}" },
- { "boolean", "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{\"key1\":koko , \"key2\":true}" },
- { "boolean", "{\"key1\":true , \"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{\"key1\":@false , \"key2\":true}" },
- { "boolean", "{\"key1\":true,\"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{:false , \"key2\":true}" },
- { "boolean", "{\"key1\":true,\"key2\":false}", "{\"key1\":true,\"key2\":false}", "boolean",
- "{\"key1\":true , , \"key2\":false}" },
- // tosca.datatypes.Credential
- { "tosca.datatypes.Credential",
- "{\"key1\":{\"protocol\":\"protocol<br>1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}",
- "{\"key1\":{\"protocol\":\"protocol1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token\":\"token2\"}}",
- "tosca.datatypes.Credential",
- "{\"key1\":{\"protocol\":\"protocol<br>1\",\"token\":\"token1\"},\"key2\":{\"protocol\":\"protocol2\",\"token2\":\"token2\"}}" },
-
- };
- }
-
- // US594938 - UPDATE PROPERTY
- // DE199718
- @Test(dataProvider = "updatePropertiesListDefaultValueFailureFlow")
- public void updateDefaultValueOfResourcePropertyListFailureFlow(String entrySchemaType, String propertyDefaltValues,
- String expecteddefaultValues, String newEntrySchemaType, String newPropertyDefaltValues) throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.setPropertyDefaultValue(propertyDefaltValues);
- propertyDetails.getSchema().getProperty().setType(entrySchemaType);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // verify properties return from response
- assertEquals("list", resourcePropertiesFromResponse.getType());
- assertEquals(expecteddefaultValues, resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(propertyDetails.getSchema().getProperty().getType(),
- resourcePropertiesFromResponse.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- // Update resource property type = "list"
- propertyDetails.setPropertyDefaultValue(newPropertyDefaltValues);
- propertyDetails.getSchema().getProperty().setType(newEntrySchemaType);
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, false)
- .right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add(propertyDetails.getName());
- variables.add(propertyDetails.getPropertyType());
- variables.add(propertyDetails.getSchema().getProperty().getType());
- variables.add(newPropertyDefaltValues);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE.name(), variables,
- updatePropertyResponse.getResponse());
- }
-
- @Test
- public void updatePropertyOfDerivedResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty(PropertyTypeEnum.STRING_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String derivedResourcePropertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
- // second resource derived from basicVFC
- Resource vfc1FromBasicVFC = AtomicOperationUtils
- .createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, basicVFC,
- ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true)
- .left().value();
- // add property Type list to second resource
- PropertyReqDetails defaultListProperty = ElementFactory.getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(defaultListProperty, vfc1FromBasicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Update property (list) of derived resource
- RestResponse updatePropertyResponse = AtomicOperationUtils.updatePropertyOfResource(propertyDetails, basicVFC,
- derivedResourcePropertyUniqueId, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updatePropertyResponse.getResponse());
- // Verify resource's priority list did not changed
- verifyResourcePropertyList(basicVFC, propertyDetails, "[\"a\",\"b\"]");
- }
-
- @Test
- public void updatePropertyOfNonDerivedResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty(PropertyTypeEnum.STRING_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
- // second resource derived from basicVFC
- Resource vfc1FromBasicVFC = AtomicOperationUtils
- .createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, basicVFC,
- ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true)
- .left().value();
- // add property Type list to second resource
- PropertyReqDetails defaultListProperty = ElementFactory.getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(defaultListProperty, vfc1FromBasicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // Update property (list) of derived resource
- defaultListProperty.setPropertyDefaultValue("[1,2,3,4]");
- String expectedDefaultValue = "[1,2,3,4]";
- ComponentInstanceProperty resourcePropertyAfterUpdate = AtomicOperationUtils
- .updatePropertyOfResource(defaultListProperty, vfc1FromBasicVFC, propertyUniqueId,
- UserRoleEnum.DESIGNER, true)
- .left().value();
- assertEquals(resourcePropertyAfterUpdate.getType(), "list");
- assertEquals(resourcePropertyAfterUpdate.getDefaultValue(), expectedDefaultValue);
- assertEquals(resourcePropertyAfterUpdate.getSchema().getProperty().getType(),
- defaultListProperty.getSchema().getProperty().getType()); // string/integer/boolean/float
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(vfc1FromBasicVFC.getUniqueId());
- String expectedDefaultValueFromDerivedResource = "[\"a\",\"b\"]";
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- resource.getProperties().get(0).getDefaultValue().equals(expectedDefaultValue);
- resource.getProperties().get(1).getDefaultValue().equals(expectedDefaultValueFromDerivedResource);
- }
-
- @Test
- public void updateListPropertyToNonCheckedOutResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- String PropertyDefaultValue = "[2,3]";
- propertyDetails.setPropertyDefaultValue(PropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType("integer");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
- // Update resource property type = "list"
- propertyDetails.setPropertyDefaultValue("[3,4]");
- propertyDetails.getSchema().getProperty().setType("integer");
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, false)
- .right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updatePropertyResponse.getResponse());
- // Verify resource's priority list did not changed
- verifyResourcePropertyList(basicVFC, propertyDetails, "[2,3]");
- }
-
- @Test
- public void updateListPropertyResourceByNonResouceOwner() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- String PropertyDefaultValue = "[2,3]";
- propertyDetails.setPropertyDefaultValue(PropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType("integer");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // AtomicOperationUtils.changeComponentState(basicVFC,
- // UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
- // Update resource property type = "list"
- propertyDetails.setPropertyDefaultValue("[3,4]");
- propertyDetails.getSchema().getProperty().setType("integer");
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER2, false)
- .right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updatePropertyResponse.getResponse());
- // Verify resource's priority list did not changed
- verifyResourcePropertyList(basicVFC, propertyDetails, "[2,3]");
- }
-
- @Test
- public void updateListPropertyResourceByTester() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- String PropertyDefaultValue = "[2,3]";
- propertyDetails.setPropertyDefaultValue(PropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType("integer");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // AtomicOperationUtils.changeComponentState(basicVFC,
- // UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
- // Update resource property type = "list"
- propertyDetails.setPropertyDefaultValue("[3,4]");
- propertyDetails.getSchema().getProperty().setType("integer");
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.TESTER, false)
- .right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- updatePropertyResponse.getResponse());
- // Verify resource's priority list did not changed
- verifyResourcePropertyList(basicVFC, propertyDetails, "[2,3]");
- }
-
- // DE199964
- @Test(enabled = false)
- public void updateListPropertyToNonExistingResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- String PropertyDefaultValue = "[2,3]";
- propertyDetails.setPropertyDefaultValue(PropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType("integer");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- String resourceUniqueId = basicVFC.getUniqueId();
- basicVFC.setUniqueId("1111111");
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, false)
- .right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_NOT_FOUND));
- ArrayList<String> variables = new ArrayList<>();
- variables.add(basicVFC.getUniqueId());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), variables,
- updatePropertyResponse.getResponse());
- // Verify resource's priority list did not changed
- basicVFC.setUniqueId(resourceUniqueId);
- verifyResourcePropertyList(basicVFC, propertyDetails, "[2,3]");
- }
-
- // DE199725
- @Test
- public void updateResourcePropertyListNonSupportedPropertyType() throws Exception { // Not
- // "list"
- // type
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- String PropertyDefaultValue = "[2,3]";
- propertyDetails.setPropertyDefaultValue(PropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType("integer");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // update resource property
- String propertyType = "listttttttt";
- propertyDetails.setPropertyType(propertyType);
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, false)
- .right().value();
- ArrayList<String> variables = new ArrayList<>();
- variables.add(propertyDetails.getPropertyType()); // property data type
- // (koko instead
- // list)
- variables.add(propertyDetails.getName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROPERTY_TYPE.name(), variables,
- updatePropertyResponse.getResponse());
- // Verify resource's priority list did not changed
- propertyDetails.setPropertyType("list");
- verifyResourcePropertyList(basicVFC, propertyDetails, "[2,3]");
- }
-
- @Test(enabled = false) // DE199732
- public void updateResourcePropertyListNonSupportedEntrySchemaType() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- String PropertyDefaultValue = "[2,3]";
- propertyDetails.setPropertyDefaultValue(PropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType("integer");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // update resource property
- String EntrySchemaType = "integerrrrrr";
- propertyDetails.getSchema().getProperty().setType(EntrySchemaType);
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, false)
- .right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add(EntrySchemaType);
- variables.add(propertyDetails.getName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROPERTY_INNER_TYPE.name(), variables,
- updatePropertyResponse.getResponse());
- propertyDetails.getSchema().getProperty().setType("integer");
- verifyResourcePropertyList(basicVFC, propertyDetails, "[2,3]");
- }
-
- @Test(dataProvider = "updatePropertiesListDefaultValueSuccessFlow")
- public void updateResourcePropertyListSuccessFlow(String entrySchemaType, String propertyDefaltValues,
- String expecteddefaultValues, String newEntrySchemaType, String newPropertyDefaltValues,
- String newExpecteddefaultValues) throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.setPropertyDefaultValue(propertyDefaltValues);
- propertyDetails.getSchema().getProperty().setType(entrySchemaType);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // verify properties return from response
- assertEquals("list", resourcePropertiesFromResponse.getType());
- assertEquals(expecteddefaultValues, resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(propertyDetails.getSchema().getProperty().getType(),
- resourcePropertiesFromResponse.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- // Update resource property type = "list"
- propertyDetails.setPropertyDefaultValue(newPropertyDefaltValues);
- propertyDetails.getSchema().getProperty().setType(newEntrySchemaType);
- ComponentInstanceProperty resourcePropertyAfterUpdate = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, true)
- .left().value();
- assertEquals("list", resourcePropertyAfterUpdate.getType());
- assertEquals(newExpecteddefaultValues, resourcePropertyAfterUpdate.getDefaultValue());
- assertEquals(propertyDetails.getSchema().getProperty().getType(),
- resourcePropertyAfterUpdate.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, newExpecteddefaultValues);
- }
-
- // Add property type list to resource
- // DE199718
- @Test(dataProvider = "invalidListProperties") // invalid default values
- public void addListPropertyToResourceFailureFlow(String entrySchemaType, String propertyDefaltValues)
- throws Exception {
- // String propertyType = "list";
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType(entrySchemaType);
- propertyDetails.setPropertyDefaultValue(propertyDefaltValues);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- RestResponse addPropertyToResourceResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyToResourceResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add(propertyDetails.getName());
- variables.add(propertyDetails.getPropertyType());
- variables.add(propertyDetails.getSchema().getProperty().getType());
- variables.add(propertyDefaltValues);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE.name(), variables,
- addPropertyToResourceResponse.getResponse());
-
- }
-
- // DE199964
- @Test
- public void addListPropertyToNonExistingResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType("integer");
- propertyDetails.setPropertyDefaultValue("[1,2]");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to non existing resource
- basicVFC.setUniqueId("1111111");
- RestResponse addPropertyToResourceResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyToResourceResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_NOT_FOUND));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), variables,
- addPropertyToResourceResponse.getResponse());
- }
-
- @Test
- public void addListPropertyToNonCheckedOutResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType("integer");
- propertyDetails.setPropertyDefaultValue("[1,2]");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
- // Add property type list to non Checked-Out resource
- RestResponse addPropertyToResourceResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyToResourceResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- addPropertyToResourceResponse.getResponse());
- }
-
- @Test
- public void addListPropertyToResourceByNonResourceOwner() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType("integer");
- propertyDetails.setPropertyDefaultValue("[1,2]");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to non Checked-Out resource
- RestResponse addPropertyToResourceResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER2, false).right().value();
- assertTrue(addPropertyToResourceResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- addPropertyToResourceResponse.getResponse());
- }
-
- @Test
- public void addListPropertyToResourcePropertyAlreadyExists01() throws Exception {
- String propertyType = "list";
- String propertySchemaType = "integer";
- String defaultValues = "[1,2]";
- String expecteddefaultValues = "[1,2]";
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType(propertySchemaType);
- propertyDetails.setPropertyDefaultValue(defaultValues);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // check-in and check-out resource
- RestResponse changeComponentState = LifecycleRestUtils.changeComponentState(basicVFC,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN);
- assertTrue(changeComponentState.getErrorCode().equals(BaseRestUtils.STATUS_CODE_SUCCESS));
- changeComponentState = LifecycleRestUtils.changeComponentState(basicVFC,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKOUT);
- assertTrue(changeComponentState.getErrorCode().equals(BaseRestUtils.STATUS_CODE_SUCCESS));
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- // verify properties return from response
- assertEquals(resourcePropertiesFromResponse.getType(), propertyType);
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), expecteddefaultValues);
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(), propertySchemaType); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- // Add same property again to resource
- RestResponse addPropertyRestResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyRestResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_ALREADY_EXISTS));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PROPERTY_ALREADY_EXIST.name(), variables,
- addPropertyRestResponse.getResponse());
- // verify property not deleted
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- }
-
- @Test
- public void addListPropertyToResourcePropertyAlreadyExists02() throws Exception {
- String propertyType = "list";
- String propertySchemaType = "integer";
- String defaultValues = "[1,2]";
- String expecteddefaultValues = "[1,2]";
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType(propertySchemaType);
- propertyDetails.setPropertyDefaultValue(defaultValues);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- // verify properties return from response
- assertEquals(resourcePropertiesFromResponse.getType(), propertyType);
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), expecteddefaultValues);
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(), propertySchemaType); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- // check-in and check-out resource
- RestResponse changeComponentState = LifecycleRestUtils.changeComponentState(basicVFC,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN);
- assertTrue(changeComponentState.getErrorCode().equals(BaseRestUtils.STATUS_CODE_SUCCESS));
- changeComponentState = LifecycleRestUtils.changeComponentState(basicVFC,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKOUT);
- assertTrue(changeComponentState.getErrorCode().equals(BaseRestUtils.STATUS_CODE_SUCCESS));
- // Add same property again to resource
- RestResponse addPropertyRestResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyRestResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_ALREADY_EXISTS));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PROPERTY_ALREADY_EXIST.name(), variables,
- addPropertyRestResponse.getResponse());
- // verify property not deleted
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- }
-
- @Test // DE199725
- public void addListPropertyToResourceNonSupportedPropertyType() throws Exception { // Not
- // "list"
- // type
- String propertyType = "listttttttt";
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.setPropertyType(propertyType);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- RestResponse addPropertyRestResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyRestResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add(propertyDetails.getPropertyType()); // property data type
- // (koko instead
- // list)
- variables.add(propertyDetails.getName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROPERTY_TYPE.name(), variables,
- addPropertyRestResponse.getResponse());
- }
-
- @Test // DE199732
- public void addListPropertyToResourceNonSupportedEntrySchemaType() throws Exception {
- String EntrySchemaType = "stringggg"; // instead "string"
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType(EntrySchemaType);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- RestResponse addPropertyRestResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyRestResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add(EntrySchemaType);
- variables.add(propertyDetails.getName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_PROPERTY_INNER_TYPE.name(), variables,
- addPropertyRestResponse.getResponse());
- }
-
- @Test
- public void addHundredPropertyListToResourceSuccessFlow() throws Exception {
- String propertyType = "list";
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- String propertyName = propertyDetails.getName();
- int numberOfPropertiesToAddToResource = 100;
- ComponentInstanceProperty resourcePropertiesFromResponse;
- for (int x = 0; x < numberOfPropertiesToAddToResource; x++) {
- propertyDetails.setName(propertyName + x);
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- // verify properties return from response
- assertEquals(resourcePropertiesFromResponse.getName(), propertyName + x);
- assertEquals(resourcePropertiesFromResponse.getType(), propertyType);
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[\"a\",\"b\"]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetails.getSchema().getProperty().getType()); // string/integer/boolean/float
- }
- // get resource and verify that 100 properties exist
- Resource resourceObject = AtomicOperationUtils.getResourceObject(basicVFC, UserRoleEnum.DESIGNER);
- assertEquals(numberOfPropertiesToAddToResource, resourceObject.getProperties().size());
-
- }
-
- @Test(dataProvider = "propertiesListDefaultValueSuccessFlow")
- public void addListPropertyToResourceSuccessFlow(String entrySchemaType, String propertyDefaltValues,
- String expecteddefaultValues) throws Exception {
- String propertyType = "list";
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType(entrySchemaType);
- propertyDetails.setPropertyDefaultValue(propertyDefaltValues);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- // verify properties return from response
- assertEquals(propertyType, resourcePropertiesFromResponse.getType());
- assertEquals(expecteddefaultValues, resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(entrySchemaType, resourcePropertiesFromResponse.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
-
- assertEquals(resourcePropertiesFromResponse.getType(), propertyType);
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), expecteddefaultValues);
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(), entrySchemaType); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- }
-
- // Delete property type list
- @Test
- public void deleteOneOfTheListPropertiesFromResourceAndAddItAgain() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.STRING_LIST);
- PropertyReqDetails propertyDetailsInteger = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[\"a\",\"b\"]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1,2]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, "[\"a\",\"b\"]");
- // Add deleted property again to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1,2]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- }
-
- @Test
- public void deletePropertyListTypeInteger() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.STRING_LIST);
- PropertyReqDetails propertyDetailsInteger = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[\"a\",\"b\"]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1,2]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsInteger, "[1,2]");
- }
-
- @Test
- public void deletePropertyListTypeBoolean() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.BOOLEAN_LIST);
- PropertyReqDetails propertyDetailsInteger = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[true,false]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1,2]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one property
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsInteger, "[1,2]");
- }
-
- @Test
- public void deletePropertyListTypeFloat() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.FLOAT_LIST);
- PropertyReqDetails propertyDetailsInteger = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1.0,2.0]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1,2]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one property
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsInteger, "[1,2]");
- }
-
- @Test
- public void deletePropertyListAlreadyDeleted() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.FLOAT_LIST);
- PropertyReqDetails propertyDetailsInteger = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1.0,2.0]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), "[1,2]");
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one property
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsInteger, "[1,2]");
- // delete again the same property
- deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_NOT_FOUND == deletePropertyOfResource.getErrorCode());
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PROPERTY_NOT_FOUND.name(), variables,
- deletePropertyOfResource.getResponse());
- }
-
- @Test
- public void deletePropertyListResourceIsNotCheckedOutState() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.FLOAT_LIST);
- String expectedDefaultvalues = "[1.0,2.0]";
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), expectedDefaultvalues);
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- // Get resource and verify updated default value
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, expectedDefaultvalues);
- // Check-in resource
- AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
- // Delete property
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION == deletePropertyOfResource.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- deletePropertyOfResource.getResponse());
- // Get resource and verify property is not deleted
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, expectedDefaultvalues);
- }
-
- @Test
- public void deletePropertyListResourceByNotIsNonResouceOwner() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.FLOAT_LIST);
- String expectedDefaultvalues = "[1.0,2.0]";
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), expectedDefaultvalues);
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- // Get resource and verify updated default value
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, expectedDefaultvalues);
- // Delete property by non resource owner
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER2);
- assertTrue(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION == deletePropertyOfResource.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- deletePropertyOfResource.getResponse());
- // Get resource and verify property is not deleted
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, expectedDefaultvalues);
- }
-
- @Test
- public void deletePropertyListFromNonExistingResource() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.FLOAT_LIST);
- String expectedDefaultvalues = "[1.0,2.0]";
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- String actualResourceUniqueId = basicVFC.getUniqueId();
- // Add property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals(resourcePropertiesFromResponse.getDefaultValue(), expectedDefaultvalues);
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- // Get resource and verify updated default value
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, expectedDefaultvalues);
- // Delete property from non existing resource
- basicVFC.setUniqueId("1111111");
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(deletePropertyOfResource.getErrorCode().equals(BaseRestUtils.STATUS_CODE_NOT_FOUND));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), variables,
- deletePropertyOfResource.getResponse());
- // Get resource and verify property is not deleted
- basicVFC.setUniqueId(actualResourceUniqueId);
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, expectedDefaultvalues);
- }
-
- @Test
- public void deletePropertyOfDerivedResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty(PropertyTypeEnum.STRING_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String derivedResourcePropertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
- // second resource derived from basicVFC
- Resource vfc1FromBasicVFC = AtomicOperationUtils
- .createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, basicVFC,
- ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true)
- .left().value();
- // Delete property (list) of derived resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(
- vfc1FromBasicVFC.getUniqueId(), derivedResourcePropertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(deletePropertyOfResource.getErrorCode().equals(BaseRestUtils.STATUS_CODE_NOT_FOUND));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PROPERTY_NOT_FOUND.name(), variables,
- deletePropertyOfResource.getResponse());
- // Verify resource's priority list did not changed
- verifyResourcePropertyList(vfc1FromBasicVFC, propertyDetails, "[\"a\",\"b\"]");
- }
-
- @Test
- public void deletePropertyOfNonDerivedResource() throws Exception {
- PropertyReqDetails propertyListString = ElementFactory.getDefaultListProperty(PropertyTypeEnum.STRING_LIST);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyListString, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
- // second resource derived from basicVFC
- Resource vfc1FromBasicVFC = AtomicOperationUtils
- .createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, basicVFC,
- ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true)
- .left().value();
- // add property Type list to second resource
- PropertyReqDetails propertyListInteger = ElementFactory.getDefaultListProperty(PropertyTypeEnum.INTEGER_LIST);
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyListInteger, vfc1FromBasicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // Delete property (list) of derived resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils
- .deletePropertyOfResource(vfc1FromBasicVFC.getUniqueId(), propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyListString, "[\"a\",\"b\"]");
- }
-
- private void verifyResourcePropertyList(Resource resource, PropertyReqDetails expectedProperty,
- String expecteddefaultValues) throws Exception {
- // get resource and verify property from type list
- Resource getResource = AtomicOperationUtils.getResourceObject(resource, UserRoleEnum.DESIGNER);
- List<PropertyDefinition> actualResourceProperties = getResource.getProperties();
- boolean isPropertyAppear = false;
- for (PropertyDefinition pro : actualResourceProperties) {
- if (expectedProperty.getName().equals(pro.getName())) {
- assertTrue("Check Property Type ", pro.getType().equals(expectedProperty.getPropertyType()));
- assertEquals("Check Property default values ", expecteddefaultValues, pro.getDefaultValue());
- // assertTrue("Check Property default values ",
- // pro.getDefaultValue().equals(expecteddefaultValues));
- assertTrue("Check entrySchema Property Type ", pro.getSchema().getProperty().getType()
- .equals(expectedProperty.getSchema().getProperty().getType()));
- isPropertyAppear = true;
- }
- }
- assertTrue(isPropertyAppear);
- }
-
- // US656905
- // --------------------- Map Property
- // ----------------------------------------------------------------
- @Test(dataProvider = "updatePropertiesMapDefaultValueFailureFlow")
- public void updateDefaultValueOfResourcePropertyMapFailureFlow(String entrySchemaType, String propertyDefaultValues,
- String expectedDefaultValue, String newEntrySchemaType, String newPropertyDefaultValue) throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultMapProperty();
- propertyDetails.setPropertyDefaultValue(propertyDefaultValues);
- propertyDetails.getSchema().getProperty().setType(entrySchemaType);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // verify properties return from response
- assertEquals("map", resourcePropertiesFromResponse.getType());
- assertEquals(expectedDefaultValue, resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(propertyDetails.getSchema().getProperty().getType(),
- resourcePropertiesFromResponse.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expectedDefaultValue);
- // Update resource property type = "map"
- propertyDetails.setPropertyDefaultValue(newPropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType(newEntrySchemaType);
- RestResponse updatePropertyResponse = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, false)
- .right().value();
- assertTrue(updatePropertyResponse.getErrorCode().equals(STATUS_CODE_INVALID_CONTENT));
- ArrayList<String> variables = new ArrayList<>();
- variables.add(propertyDetails.getName());
- variables.add(propertyDetails.getPropertyType());
- variables.add(propertyDetails.getSchema().getProperty().getType());
- variables.add(newPropertyDefaultValue);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE.name(), variables,
- updatePropertyResponse.getResponse());
- }
-
- @Test(dataProvider = "updatePropertiesMapDefaultValueSuccessFlow")
- public void updateResourcePropertyMapSuccessFlow(String entrySchemaType, String propertyDefaultValues,
- String expectedDefaultValue, String newEntrySchemaType, String newPropertyDefaultValue,
- String newExpectedDefaultValue) throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultMapProperty();
- propertyDetails.setPropertyDefaultValue(propertyDefaultValues);
- propertyDetails.getSchema().getProperty().setType(entrySchemaType);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- // verify properties return from response
- assertEquals("map", resourcePropertiesFromResponse.getType());
- assertEquals(expectedDefaultValue, resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(propertyDetails.getSchema().getProperty().getType(),
- resourcePropertiesFromResponse.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expectedDefaultValue);
- // Update resource property type = "map"
- propertyDetails.setPropertyDefaultValue(newPropertyDefaultValue);
- propertyDetails.getSchema().getProperty().setType(newEntrySchemaType);
- ComponentInstanceProperty resourcePropertyAfterUpdate = AtomicOperationUtils
- .updatePropertyOfResource(propertyDetails, basicVFC, propertyUniqueId, UserRoleEnum.DESIGNER, true)
- .left().value();
- assertEquals("map", resourcePropertyAfterUpdate.getType());
- assertEquals(newExpectedDefaultValue, resourcePropertyAfterUpdate.getDefaultValue());
- assertEquals(propertyDetails.getSchema().getProperty().getType(),
- resourcePropertyAfterUpdate.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, newExpectedDefaultValue);
- }
-
- @Test
- public void deletePropertyMapTypeString() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultMapProperty(PropertyTypeEnum.STRING_MAP);
- PropertyReqDetails propertyDetailsInteger = ElementFactory.getDefaultMapProperty(PropertyTypeEnum.INTEGER_MAP);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals("{\"key1\":\"val1\",\"key2\":\"val2\"}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals("{\"key1\":123,\"key2\":-456}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsInteger, "{\"key1\":123,\"key2\":-456}");
- }
-
- @Test
- public void deletePropertyMapTypeFloat() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeFloat = ElementFactory.getDefaultMapProperty(PropertyTypeEnum.FLOAT_MAP);
- PropertyReqDetails propertyDetailsInteger = ElementFactory.getDefaultMapProperty(PropertyTypeEnum.INTEGER_MAP);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeFloat, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeFloat.getPropertyType());
- assertEquals("{\"key1\":0.2123,\"key2\":43.545}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeFloat.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals("{\"key1\":123,\"key2\":-456}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsInteger, "{\"key1\":123,\"key2\":-456}");
- }
-
- @Test
- public void deletePropertyMapTypeBoolean() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeBoolean = ElementFactory
- .getDefaultMapProperty(PropertyTypeEnum.BOOLEAN_MAP);
- PropertyReqDetails propertyDetailsInteger = ElementFactory.getDefaultMapProperty(PropertyTypeEnum.INTEGER_MAP);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeBoolean, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeBoolean.getPropertyType());
- assertEquals("{\"key1\":true,\"key2\":false}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeBoolean.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsInteger.getPropertyType());
- assertEquals("{\"key1\":123,\"key2\":-456}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsInteger.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsInteger, "{\"key1\":123,\"key2\":-456}");
- }
-
- @Test
- public void deletePropertyMapTypeInteger() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeInteger = ElementFactory
- .getDefaultMapProperty(PropertyTypeEnum.INTEGER_MAP);
- PropertyReqDetails propertyDetailsBoolean = ElementFactory.getDefaultMapProperty(PropertyTypeEnum.BOOLEAN_MAP);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeInteger, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- String propertyUniqueId = resourcePropertiesFromResponse.getUniqueId();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeInteger.getPropertyType());
- assertEquals("{\"key1\":123,\"key2\":-456}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeInteger.getSchema().getProperty().getType()); // string/integer/boolean/float
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsBoolean, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsBoolean.getPropertyType());
- assertEquals("{\"key1\":true,\"key2\":false}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsBoolean.getSchema().getProperty().getType());
- // Get resource and verify updated default value
- RestResponse restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(2, resource.getProperties().size());
- // Delete one resource
- RestResponse deletePropertyOfResource = AtomicOperationUtils.deletePropertyOfResource(basicVFC.getUniqueId(),
- propertyUniqueId, UserRoleEnum.DESIGNER);
- assertTrue(BaseRestUtils.STATUS_CODE_DELETE == deletePropertyOfResource.getErrorCode());
- // Get resource and verify updated default value
- restResponse = ResourceRestUtils.getResource(basicVFC.getUniqueId());
- resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- assertEquals(1, resource.getProperties().size());
- verifyResourcePropertyList(basicVFC, propertyDetailsBoolean, "{\"key1\":true,\"key2\":false}");
- }
-
- @Test(dataProvider = "propertiesMapDefaultValueSuccessFlow")
- public void addMapPropertyToResourceSuccessFlow(String entrySchemaType, String propertyDefaltValues,
- String expecteddefaultValues) throws Exception {
- String propertyType = "map";
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultMapProperty();
- propertyDetails.getSchema().getProperty().setType(entrySchemaType);
- propertyDetails.setPropertyDefaultValue(propertyDefaltValues);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to resource
- ComponentInstanceProperty resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, true).left().value();
- // verify properties return from response
- assertEquals(propertyType, resourcePropertiesFromResponse.getType());
- assertEquals(expecteddefaultValues, resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(entrySchemaType, resourcePropertiesFromResponse.getSchema().getProperty().getType()); // string/integer/boolean/float
- verifyResourcePropertyList(basicVFC, propertyDetails, expecteddefaultValues);
- }
-
- @Test
- public void addMapPropertyToNonExistingResource() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType("integer");
- propertyDetails.setPropertyDefaultValue("{\"key1\":1 , \"key2\":2}");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to non existing resource
- basicVFC.setUniqueId("1111111");
- RestResponse addPropertyToResourceResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER, false).right().value();
- assertTrue(addPropertyToResourceResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_NOT_FOUND));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), variables,
- addPropertyToResourceResponse.getResponse());
- }
-
- @Test
- public void addMaptPropertyToResourceByNonResourceOwner() throws Exception {
- PropertyReqDetails propertyDetails = ElementFactory.getDefaultListProperty();
- propertyDetails.getSchema().getProperty().setType("integer");
- propertyDetails.setPropertyDefaultValue("{\"key1\":1 , \"key2\":2}");
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add property type list to non Checked-Out resource
- RestResponse addPropertyToResourceResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetails, basicVFC, UserRoleEnum.DESIGNER2, false).right().value();
- assertTrue(addPropertyToResourceResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION));
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- addPropertyToResourceResponse.getResponse());
- }
-
- @Test
- public void addMapPropertyToResourcePropertyAlreadyExists() throws Exception {
- ComponentInstanceProperty resourcePropertiesFromResponse;
- PropertyReqDetails propertyDetailsTypeString = ElementFactory
- .getDefaultListProperty(PropertyTypeEnum.STRING_MAP);
- // create resource
- Resource basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
- NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
- .value();
- // Add 2 property type list to resource
- resourcePropertiesFromResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, true).left()
- .value();
- assertEquals(resourcePropertiesFromResponse.getType(), propertyDetailsTypeString.getPropertyType());
- assertEquals("{\"key1\":\"val1\",\"key2\":\"val2\"}", resourcePropertiesFromResponse.getDefaultValue());
- assertEquals(resourcePropertiesFromResponse.getSchema().getProperty().getType(),
- propertyDetailsTypeString.getSchema().getProperty().getType()); // string/integer/boolean/float
- // check-in and check-out resource
- RestResponse changeComponentState = LifecycleRestUtils.changeComponentState(basicVFC,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN);
- assertTrue(changeComponentState.getErrorCode().equals(BaseRestUtils.STATUS_CODE_SUCCESS));
- changeComponentState = LifecycleRestUtils.changeComponentState(basicVFC,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKOUT);
- assertTrue(changeComponentState.getErrorCode().equals(BaseRestUtils.STATUS_CODE_SUCCESS));
- // Add same property again to resource
- RestResponse addPropertyRestResponse = AtomicOperationUtils
- .addCustomPropertyToResource(propertyDetailsTypeString, basicVFC, UserRoleEnum.DESIGNER, false).right()
- .value();
- assertTrue(addPropertyRestResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_ALREADY_EXISTS));
- ArrayList<String> variables = new ArrayList<>();
- variables.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PROPERTY_ALREADY_EXIST.name(), variables,
- addPropertyRestResponse.getResponse());
- // verify property not deleted
- verifyResourcePropertyList(basicVFC, propertyDetailsTypeString, "{\"key1\":\"val1\",\"key2\":\"val2\"}");
- }
-
-}
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
deleted file mode 100644
index 4e2a521b3c..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java
+++ /dev/null
@@ -1,1397 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.resource;
-
-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.*;
-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;
-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.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-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() {
- super(new TestName(), ComponentRelationshipInVfTest.class.getName());
- }
-
- private ResourceReqDetails resourceDetailsVF;
- private User designerUser;
- private User adminUser;
- private User testerUser;
- private ResourceReqDetails resourceDetailsReq;
- private ResourceReqDetails resourceDetailsCap;
-
- @BeforeMethod
- public void before() throws Exception {
- designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- testerUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
-
- resourceDetailsVF = ElementFactory.getDefaultResourceByType("VF100", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, designerUser.getUserId(), ResourceTypeEnum.VF.toString());
- createResource(resourceDetailsVF, designerUser);
-
- resourceDetailsReq = ElementFactory.getDefaultResourceByType("SoftCompRouter",
- NormativeTypesEnum.SOFTWARE_COMPONENT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
- designerUser.getUserId(), ResourceTypeEnum.CP.toString()); // resourceType
- // =
- // VFC
- resourceDetailsCap = ElementFactory.getDefaultResourceByType("MyCompute", NormativeTypesEnum.COMPUTE,
- ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, designerUser.getUserId(), ResourceTypeEnum.CP.toString()); // resourceType
- // =
- // VFC
-
- }
-
- private void createResource(ResourceReqDetails resourceDetails, User user) throws Exception, IOException {
- RestResponse createResourceResponse = ResourceRestUtils.createResource(resourceDetails, user);
- ResourceRestUtils.checkCreateResponse(createResourceResponse);
- if (!resourceDetails.getResourceType().equals("VF"))
- LifecycleRestUtils.changeResourceState(resourceDetails, user, "0.1", LifeCycleStatesEnum.CHECKIN);
- }
-
- private void createAtomicResource(ResourceReqDetails resourceDetails, User user) throws Exception {
- createResource(resourceDetails, user);
- }
-
- private RequirementCapabilityRelDef setRelationshipBetweenInstances(ComponentInstance riReq,
- ComponentInstance riCap, CapReqDef capReqDef) throws Exception {
-
- String capbilityUid = capReqDef.getCapabilities().get("tosca.capabilities.Container").get(0).getUniqueId();
- String requirementUid = capReqDef.getRequirements().get("tosca.capabilities.Container").get(0).getUniqueId();
-
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- requirementDef.setFromNode(riReq.getUniqueId());
- requirementDef.setToNode(riCap.getUniqueId());
-
- RelationshipInfo pair = new RelationshipInfo();
- pair.setRequirementOwnerId(riReq.getUniqueId());
- pair.setCapabilityOwnerId(riCap.getUniqueId());
- pair.setRequirement("host");
- RelationshipImpl relationship = new RelationshipImpl();
- relationship.setType("tosca.capabilities.Container");
- pair.setRelationships(relationship);
- pair.setCapabilityUid(capbilityUid);
- pair.setRequirementUid(requirementUid);
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
- relationships.add(capReqRel);
- capReqRel.setRelation(pair);
- requirementDef.setRelationships(relationships);
- return requirementDef;
- }
-
- private ComponentInstance createComponentInstance(ResourceReqDetails res) throws Exception {
- return createComponentInstance(res, designerUser);
- }
-
- private ComponentInstance createComponentInstance(ResourceReqDetails res, User user, ResourceReqDetails vf)
- throws Exception {
- RestResponse response = ResourceRestUtils.createResourceInstance(res, user, vf.getUniqueId());
- ResourceRestUtils.checkCreateResponse(response);
- ComponentInstance compInstance = ResponseParser.parseToObject(response.getResponse(), ComponentInstance.class);
- return compInstance;
- }
-
- private ComponentInstance createComponentInstance(ResourceReqDetails res, User user) throws Exception {
- return createComponentInstance(res, user, resourceDetailsVF);
- }
-
- private void createTwoAtomicResourcesByType(String reqType, String capType, User user1, User user2)
- throws Exception {
- resourceDetailsReq.setResourceType(reqType);
- createAtomicResource(resourceDetailsReq, user1);
- resourceDetailsCap.setResourceType(capType);
- createAtomicResource(resourceDetailsCap, user2);
- }
-
- private void createTwoAtomicResourcesByType(String reqType, String capType) throws Exception {
- createTwoAtomicResourcesByType(reqType, capType, designerUser, designerUser);
- }
-
- @Test
- public void associateInVF() throws Exception {
-
- createTwoAtomicResourcesByType(ResourceTypeEnum.VFC.toString(), ResourceTypeEnum.VFC.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDef = getResourceReqCap();
-
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get("tosca.capabilities.Container");
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get("tosca.capabilities.Container");
-
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- requirementDef.setFromNode(riReq.getUniqueId());
- requirementDef.setToNode(riCap.getUniqueId());
-
- RelationshipInfo pair = new RelationshipInfo();
- pair.setRequirementOwnerId(riReq.getUniqueId());
- pair.setCapabilityOwnerId(riCap.getUniqueId());
- pair.setRequirement("host");
- RelationshipImpl relationship = new RelationshipImpl();
- relationship.setType("tosca.capabilities.Container");
- pair.setRelationships(relationship);
- pair.setCapabilityUid(capList.get(0).getUniqueId());
- pair.setRequirementUid(reqList.get(0).getUniqueId());
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
- relationships.add(capReqRel);
- capReqRel.setRelation(pair);
- requirementDef.setRelationships(relationships);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
-
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(designerUser,
- resourceDetailsVF);
- capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
-
- List<RequirementDefinition> list = capReqDef.getRequirements().get("tosca.capabilities.Container");
- assertEquals("Check requirement", null, list);
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, dissociateInstances.getErrorCode().intValue());
-
- getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(designerUser, resourceDetailsVF);
- capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
-
- list = capReqDef.getRequirements().get("tosca.capabilities.Container");
- assertEquals("Check requirement", 1, list.size());
- }
-
- //////////////////////////////// Q A //////////////////////////////
- private boolean checkRealtionship(String fromNode, String toNode, String resourceUniqueId) throws Exception {
- List<RequirementCapabilityRelDef> componentInstancesRelations = getComponentInstancesRelations(
- resourceUniqueId);
- RequirementCapabilityRelDef requirementCapabilityRelDef = componentInstancesRelations.get(0);
- boolean fromNodeCheck = requirementCapabilityRelDef.getFromNode().equals(fromNode);
- boolean toNodeCheck = requirementCapabilityRelDef.getToNode().equals(toNode);
-
- return fromNodeCheck && toNodeCheck;
- }
-
- private List<RequirementCapabilityRelDef> getComponentInstancesRelations(String resourceUniqueId)
- throws ClientProtocolException, IOException {
- Resource resource = getVfAsResourceObject(resourceUniqueId);
- List<RequirementCapabilityRelDef> componenRelationInstances = resource.getComponentInstancesRelations();
-
- return componenRelationInstances;
- }
-
- private Resource getVfAsResourceObject(String resourceUniqueId) throws ClientProtocolException, IOException {
- RestResponse getResource = ResourceRestUtils.getResource(resourceUniqueId);
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- return resource;
- }
-
- private List<ComponentInstance> getComponentInstancesList(String resourceUniqueId) throws Exception {
- Resource resource = getVfAsResourceObject(resourceUniqueId);
- List<ComponentInstance> componentInstances = resource.getComponentInstances();
- return componentInstances;
- }
-
- @Test
- public void associateCpToCpTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.CP.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- CapReqDef capReqDef = getResourceReqCap();
-
- requirementsBeforeAssociate.remove("tosca.capabilities.Container");
- assertTrue(capReqDef.getRequirements().equals(requirementsBeforeAssociate));
-
- List<CapabilityDefinition> list = capabilitiesBeforeAssociate.get("tosca.capabilities.Container");
- for (CapabilityDefinition cap : list) {
- cap.setMinOccurrences("0");
- }
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
- }
-
- private CapReqDef getResourceReqCap(ResourceReqDetails res) throws IOException {
- RestResponse getResourceBeforeAssociate = ComponentRestUtils.getComponentRequirmentsCapabilities(designerUser,
- resourceDetailsVF);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceBeforeAssociate.getResponse(), CapReqDef.class);
- return capReqDef;
- }
-
- private CapReqDef getResourceReqCap() throws IOException {
- return getResourceReqCap(resourceDetailsVF);
- }
-
- @Test
- public void associateCpToVLTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- CapReqDef capReqDef = getResourceReqCap();
-
- requirementsBeforeAssociate.remove("tosca.capabilities.Container");
- assertTrue(capReqDef.getRequirements().equals(requirementsBeforeAssociate));
-
- List<CapabilityDefinition> list = capabilitiesBeforeAssociate.get("tosca.capabilities.Container");
- for (CapabilityDefinition cap : list) {
- cap.setMinOccurrences("0");
- }
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
-
- }
-
- // Error handling
- // ELLA - more informative error
- @Test
- public void associateCpToVlInVFCTest() throws Exception {
- ResourceReqDetails vfcDetails = ElementFactory.getDefaultResourceByType("VFC100", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, designerUser.getUserId(), ResourceTypeEnum.VFC.toString());
- RestResponse createVfcResponse = ResourceRestUtils.createResource(vfcDetails, designerUser);
- ResourceRestUtils.checkCreateResponse(createVfcResponse);
-
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- vfcDetails.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 400, associateInstances.getErrorCode().intValue());
-
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "SoftCompRouter 1",
- // "MyCompute 2",
- // "host"
- // ]
- }
-
- // Error handling
- @Test
- public void associateCpToVfTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riCapInVfInstance = createComponentInstance(resourceDetailsCap, designerUser,
- resourceDetailsVF);
- ComponentInstance riReqInVfInstance = createComponentInstance(resourceDetailsReq, designerUser,
- resourceDetailsVF);
-
- ResourceReqDetails vfHigh = new ResourceReqDetails(resourceDetailsVF, "0.1");
- vfHigh.setName("vfHigh");
- vfHigh.setTags(new ArrayList<String>(Arrays.asList(vfHigh.getName())));
- vfHigh.setResourceType(ResourceTypeEnum.VF.toString());
- createResource(vfHigh, designerUser);
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq, designerUser, vfHigh);
- LifecycleRestUtils.changeResourceState(resourceDetailsVF, designerUser, "0.1", LifeCycleStatesEnum.CHECKIN);
- ComponentInstance riCap = createComponentInstance(resourceDetailsVF, designerUser, vfHigh);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 409, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- associateInstances.getResponse());
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "SoftCompRouter 1",
- // "VF100 2",
- // "host"
- // ]
- }
-
- // Error handling
- @Test
- public void associateVfcToVfcNotFoundTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.VFC.toString(), ResourceTypeEnum.VFC.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
- riCap.setUniqueId("123");
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 400, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_BAD_REQUEST.name(),
- new ArrayList<String>(), associateInstances.getResponse());
-
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "SoftCompRouter 1",
- // "012f6dcd-bcdf-4d9b-87be-ff1442b95831.5d265453-0b6a-4453-8f3d-57a253b88432.softcomprouter1",
- // "host"
- }
-
- @Test
- public void associateCpToDeletedVfcTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VFC.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse deleteResourceResponse = ResourceRestUtils.deleteResource(resourceDetailsCap.getUniqueId(),
- designerUser.getUserId());
- ResourceRestUtils.checkDeleteResponse(deleteResourceResponse);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- }
-
- @Test
- public void associateCpToDeletedVlTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse deleteResourceResponse = ResourceRestUtils.deleteResource(resourceDetailsCap.getUniqueId(),
- designerUser.getUserId());
- ResourceRestUtils.checkDeleteResponse(deleteResourceResponse);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- }
-
- @Test
- public void associateCpToDeletedCpTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.CP.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse deleteResourceResponse = ResourceRestUtils.deleteResource(resourceDetailsCap.getUniqueId(),
- designerUser.getUserId());
- ResourceRestUtils.checkDeleteResponse(deleteResourceResponse);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- }
-
- // Error handling
- @Test
- public void associateCpToDeletedCpInstanceTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.CP.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse deleteComponentInstance = ComponentInstanceRestUtils.deleteComponentInstance(designerUser,
- resourceDetailsVF.getUniqueId(), riReq.getUniqueId(), ComponentTypeEnum.RESOURCE);
- ComponentInstanceRestUtils.checkDeleteResponse(deleteComponentInstance);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 400, associateInstances.getErrorCode().intValue());
-
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "7d6aca08-9321-4ea1-a781-c52c8214a30e.c0e63466-5283-44d8-adff-365c0885a6ba.softcomprouter1",
- // "MyCompute 2",
- // "host"
- // ]
- }
-
- // Error handling
- @Test
- public void associateVfcToDeletedVFCInstanceTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.VFC.toString(), ResourceTypeEnum.VFC.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse deleteComponentInstance = ComponentInstanceRestUtils.deleteComponentInstance(designerUser,
- resourceDetailsVF.getUniqueId(), riReq.getUniqueId(), ComponentTypeEnum.RESOURCE);
- ComponentInstanceRestUtils.checkDeleteResponse(deleteComponentInstance);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 400, associateInstances.getErrorCode().intValue());
-
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "7d6aca08-9321-4ea1-a781-c52c8214a30e.c0e63466-5283-44d8-adff-365c0885a6ba.softcomprouter1",
- // "MyCompute 2",
- // "host"
- // ]
- }
-
- @Test
- public void associateWithDifferentOwnerOfVf() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2), resourceDetailsVF.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 409, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- associateInstances.getResponse());
-
- CapReqDef capReqDef = getResourceReqCap();
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsAfterAssociate = capReqDef.getRequirements();
-
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
- assertTrue(requirementsAfterAssociate.equals(requirementsBeforeAssociate));
- }
-
- @Test
- public void associateWithTester() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), resourceDetailsVF.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 409, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- associateInstances.getResponse());
-
- CapReqDef capReqDef = getResourceReqCap();
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsAfterAssociate = capReqDef.getRequirements();
-
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
- assertTrue(requirementsAfterAssociate.equals(requirementsBeforeAssociate));
- }
-
- // Error handling
- @Test
- public void associateCpToVLIntoVFNotFound() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- String uidNotFound = "123";
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- uidNotFound, ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 404, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(),
- new ArrayList<String>(Arrays.asList("")), associateInstances.getResponse());
-
- // {"serviceException":{"messageId":"SVC4063","text":"Error: Requested
- // '%1' resource was not found.","variables":[""]}}}
- }
-
- // Error Handling
- @Test
- public void associateCpToVlWithMissingUid() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- requirementDef.setToNode("");
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 400, associateInstances.getErrorCode().intValue());
- // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
- // new ArrayList<String>(), associateInstances.getResponse());
-
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "SoftCompRouter 1",
- // "fd3a689b-fa1c-4105-933d-d1310e642f05.95bce626-ce73-413b-8c14-2388d1589d5c.softcomprouter1",
- // "host"
- // ]
- }
-
- @Test
- public void associateInServiceWithUidOfVf() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals("Check response code ", 404, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(),
- new ArrayList<String>(Arrays.asList("")), associateInstances.getResponse());
- }
-
- @Test
- public void associateCpToVl_DifferentOwners() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString(), designerUser,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2));
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- CapReqDef capReqDef = getResourceReqCap();
-
- requirementsBeforeAssociate.remove("tosca.capabilities.Container");
- assertTrue(capReqDef.getRequirements().equals(requirementsBeforeAssociate));
-
- List<CapabilityDefinition> list = capabilitiesBeforeAssociate.get("tosca.capabilities.Container");
- for (CapabilityDefinition cap : list) {
- cap.setMinOccurrences("0");
- }
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
- }
-
- @Test(enabled = false)
- public void associateToNotCheckedoutVf() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse changeResourceStateToCheckin = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckin);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 409, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- associateInstances.getResponse());
-
- CapReqDef capReqDef = getResourceReqCap();
- assertTrue(capReqDef.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDef.getCapabilities().equals(capabilitiesBeforeAssociate));
-
- String firstUniqueId = resourceDetailsVF.getUniqueId();
-
- // checkout
-
- RestResponse changeResourceStateToCheckout = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckout);
- String secondUniqueId = resourceDetailsVF.getUniqueId();
-
- CapReqDef capReqDefAfterFirstCheckout = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesAfterFirstCheckout = capReqDefAfterFirstCheckout
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsAfterFirstCheckout = capReqDefAfterFirstCheckout
- .getRequirements();
-
- requirementDef = setUidsOfInstancesAfterLifecycleStateChange(riReq, riCap, capReqDefBeforeAssociate);
-
- RestResponse firstAssociateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- designerUser, resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, firstAssociateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- CapReqDef capReqDefAfterFirstAssociate = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesAfterFirstAssociate = capReqDefAfterFirstAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsAfterFirstAssociate = capReqDefAfterFirstAssociate
- .getRequirements();
-
- requirementsAfterFirstCheckout.remove("tosca.capabilities.Container");
- assertTrue(requirementsAfterFirstAssociate.equals(requirementsAfterFirstCheckout));
- assertTrue(capabilitiesAfterFirstAssociate.equals(capabilitiesAfterFirstCheckout));
-
- resourceDetailsVF.setUniqueId(firstUniqueId);
- CapReqDef capReqDefOfFirstVersion = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesOfFirstVersion = capReqDefOfFirstVersion.getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsOfFirstVersion = capReqDefOfFirstVersion.getRequirements();
-
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
- assertTrue(requirementsBeforeAssociate.equals(requirementsOfFirstVersion));
- assertTrue(capabilitiesBeforeAssociate.equals(capabilitiesOfFirstVersion));
-
- // checkin-checkout
- resourceDetailsVF.setUniqueId(secondUniqueId);
- RestResponse changeResourceStateToCheckin2 = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckin2);
- RestResponse changeResourceStateToCheckout2 = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckout2);
-
- List<RequirementCapabilityRelDef> componentInstancesRelations = getComponentInstancesRelations(
- resourceDetailsVF.getUniqueId());
- assertFalse(componentInstancesRelations.isEmpty());
- assertEquals(1, componentInstancesRelations.size());
- List<ComponentInstance> componentInstancesList = getComponentInstancesList(resourceDetailsVF.getUniqueId());
- for (ComponentInstance comp : componentInstancesList) {
- String instanceUid = comp.getUniqueId();
- assertTrue(checkNodesInRelations(instanceUid, componentInstancesRelations.get(0)));
- }
- assertEquals(2, componentInstancesList.size());
-
- }
-
- private RequirementCapabilityRelDef setUidsOfInstancesAfterLifecycleStateChange(ComponentInstance riReq,
- ComponentInstance riCap, CapReqDef capReqDefBeforeAssociate)
- throws ClientProtocolException, IOException, Exception {
- RequirementCapabilityRelDef requirementDef;
- // RestResponse getResourceResponse =
- // ResourceRestUtils.getResource(resourceDetailsVF.getUniqueId());
- // Resource resource_0_2 =
- // ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(),
- // Resource.class);
- // List<ComponentInstance> componentInstances =
- // resource_0_2.getComponentInstances();
- List<ComponentInstance> componentInstances = getComponentInstancesList(resourceDetailsVF.getUniqueId());
-
- for (ComponentInstance comp : componentInstances) {
- if (comp.getName().equals(riReq.getName())) {
- riReq.setUniqueId(comp.getUniqueId());
- } else if (comp.getName().equals(riCap.getName())) {
- riCap.setUniqueId(comp.getUniqueId());
- }
- }
- requirementDef = setRelationshipBetweenInstances(riReq, riCap, capReqDefBeforeAssociate);
- return requirementDef;
- }
-
- private boolean checkNodesInRelations(String instanceUid, RequirementCapabilityRelDef relation) {
- if (relation.getToNode().equals(instanceUid)) {
- return true;
- } else if (relation.getFromNode().equals(instanceUid)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Test
- public void associateOneOfTwoCPsToVl_ThenDiscocciate() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
- ResourceReqDetails secondResourceDetailsReq = new ResourceReqDetails(resourceDetailsReq, "0.1");
- secondResourceDetailsReq.setName("secondCP");
- secondResourceDetailsReq.setTags(Arrays.asList(secondResourceDetailsReq.getName()));
- createAtomicResource(secondResourceDetailsReq, designerUser);
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riReq2 = createComponentInstance(secondResourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- CapReqDef capReqDef = getResourceReqCap();
-
- List<RequirementDefinition> expectedList = requirementsBeforeAssociate.get("tosca.capabilities.Container");
- for (RequirementDefinition req : expectedList) {
- if (req.getOwnerName().equals(riReq2.getName())) {
- expectedList = new ArrayList<RequirementDefinition>(Arrays.asList(req));
- break;
- }
- }
- requirementsBeforeAssociate.put("tosca.capabilities.Container", expectedList);
- assertTrue(capReqDef.getRequirements().equals(requirementsBeforeAssociate));
-
- List<CapabilityDefinition> list = capabilitiesBeforeAssociate.get("tosca.capabilities.Container");
- for (CapabilityDefinition cap : list) {
- cap.setMinOccurrences("0");
- }
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
-
- // second relationship
-
- RequirementCapabilityRelDef secondRequirementDef = setRelationshipBetweenInstances(riReq2, riCap,
- capReqDefBeforeAssociate);
- RestResponse secondAssociateInstances = ComponentInstanceRestUtils.associateInstances(secondRequirementDef,
- designerUser, resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, secondAssociateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(secondRequirementDef.getFromNode(), secondRequirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- CapReqDef capReqDefAfterSecondAssociation = getResourceReqCap();
-
- requirementsBeforeAssociate.remove("tosca.capabilities.Container");
- assertTrue(capReqDefAfterSecondAssociation.getRequirements().equals(requirementsBeforeAssociate));
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterSecondAssociate = capReqDefAfterSecondAssociation
- .getCapabilities();
- assertTrue(capabilitiesAfterSecondAssociate.equals(capabilitiesBeforeAssociate));
-
- // dissociate
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(secondRequirementDef,
- designerUser, resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, dissociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
-
- CapReqDef capReqDefAfterDissociation = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesAfterDissociate = capReqDefAfterDissociation
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsAfterDissociate = capReqDefAfterDissociation
- .getRequirements();
-
- assertTrue(capabilitiesAfterDissociate.equals(capReqDef.getCapabilities()));
- requirementsBeforeAssociate.put("tosca.capabilities.Container", expectedList);
- assertTrue(requirementsAfterDissociate.equals(requirementsBeforeAssociate));
- }
-
- @Test
- public void associateNotCompitableCapAndReq() throws Exception {
- resourceDetailsReq = ElementFactory.getDefaultResourceByType("Database", NormativeTypesEnum.DATABASE,
- ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, designerUser.getUserId(), ResourceTypeEnum.CP.toString()); // resourceType
- // =
- // VFC
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- assertTrue(requirementDef.getRelationships().size() == 1);
- String requirement = requirementDef.getRelationships().get(0).getRelation().getRequirement();
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 404, associateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND.name(),
- new ArrayList<String>(Arrays.asList(riReq.getName(), riCap.getName(), requirement)),
- associateInstances.getResponse());
-
- CapReqDef capReqDef = getResourceReqCap();
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsAfterAssociate = capReqDef.getRequirements();
-
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
- assertTrue(requirementsAfterAssociate.equals(requirementsBeforeAssociate));
-
- }
-
- @Test
- public void disassociateCpAndCpTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.CP.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, dissociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertEquals("Check requirement", 1, listOfRequierments.size());
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
- }
-
- @Test
- public void disassociateCpAndVfcTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VFC.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, dissociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertEquals("Check requirement", 1, listOfRequierments.size());
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
- }
-
- @Test
- public void disassociateCpAndVLTest() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, dissociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertEquals("Check requirement", 1, listOfRequierments.size());
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
- }
-
- // Error handliing
- // in the error should we get the unique id of instances instead of names
- @Test
- public void disassociateNotFoundAssociation() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
- String requirementName = requirementDef.getRelationships().get(0).getRelation().getRequirement();
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 404, dissociateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND.name(),
- new ArrayList<String>(Arrays.asList(riReq.getName(), riCap.getName(), requirementName)),
- dissociateInstances.getResponse());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertEquals("Check requirement", 1, listOfRequierments.size());
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
- }
-
- // Error handliing
- @Test
- public void disassociateRelationInVfNotFound() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- String uidNotFound = "123";
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- uidNotFound, ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 404, dissociateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(),
- new ArrayList<String>(Arrays.asList(uidNotFound)), dissociateInstances.getResponse());
-
- // "serviceException": {
- // "messageId": "SVC4063",
- // "text": "Error: Requested \u0027%1\u0027 resource was not found.",
- // "variables": [
- // ""
- // ]
- }
-
- @Test
- public void disassociateWithDifferentDesigner() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2), resourceDetailsVF.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 409, dissociateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- dissociateInstances.getResponse());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertEquals("Check requirement", 1, listOfRequierments.size());
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
-
- }
-
- @Test
- public void disassociateWithTester() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), resourceDetailsVF.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 409, dissociateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- dissociateInstances.getResponse());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertNotNull("Requierment is null after disassociate with tester", listOfRequierments);
- assertEquals("Check requirement", 1, listOfRequierments.size());
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
- }
-
- @Test
- public void disassociateServiceWithUidOfVF() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VFC.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals("Check response code ", 404, dissociateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(),
- new ArrayList<String>(Arrays.asList("")), dissociateInstances.getResponse());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertTrue(listOfRequierments == null);
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).size() != 0);
- }
-
- @Test
- public void disassociateWithEmptyVfUid() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- "", ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 404, dissociateInstances.getErrorCode().intValue());
-
- CapReqDef capReqDef = getResourceReqCap();
-
- requirementsBeforeAssociate.remove("tosca.capabilities.Container");
- assertTrue(capReqDef.getRequirements().equals(requirementsBeforeAssociate));
-
- List<CapabilityDefinition> list = capabilitiesBeforeAssociate.get("tosca.capabilities.Container");
- for (CapabilityDefinition cap : list) {
- cap.setMinOccurrences("0");
- }
-
- Map<String, List<CapabilityDefinition>> capabilitiesAfterAssociate = capReqDef.getCapabilities();
- assertTrue(capabilitiesAfterAssociate.equals(capabilitiesBeforeAssociate));
- }
-
- @Test
- public void disassociateOneComponentDeleted() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
-
- RestResponse deleteResourceResponse = ResourceRestUtils.deleteResource(resourceDetailsCap.getUniqueId(),
- designerUser.getUserId());
- ResourceRestUtils.checkDeleteResponse(deleteResourceResponse);
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, dissociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
-
- List<RequirementDefinition> listOfRequierments = capReqDefAfterDissociate.getRequirements()
- .get("tosca.capabilities.Container");
- assertEquals("Check requirement", 1, listOfRequierments.size());
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
- }
-
- @Test
- public void disassociateNotCheckedoutVf() throws Exception {
- createTwoAtomicResourcesByType(ResourceTypeEnum.CP.toString(), ResourceTypeEnum.VL.toString());
-
- ComponentInstance riReq = createComponentInstance(resourceDetailsReq);
- ComponentInstance riCap = createComponentInstance(resourceDetailsCap);
-
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap();
- Map<String, List<CapabilityDefinition>> capabilitiesBeforeAssociate = capReqDefBeforeAssociate
- .getCapabilities();
- Map<String, List<RequirementDefinition>> requirementsBeforeAssociate = capReqDefBeforeAssociate
- .getRequirements();
-
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(riReq, riCap,
- capReqDefBeforeAssociate);
-
- RestResponse changeResourceStateToCheckin = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckin);
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", 409, dissociateInstances.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- dissociateInstances.getResponse());
-
- CapReqDef capReqDefAfterDissociate = getResourceReqCap();
- assertTrue(capReqDefAfterDissociate.getRequirements().equals(requirementsBeforeAssociate));
- assertTrue(capReqDefAfterDissociate.getCapabilities().equals(capabilitiesBeforeAssociate));
-
- RestResponse changeResourceStateToCheckout = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckout);
-
- requirementDef = setUidsOfInstancesAfterLifecycleStateChange(riReq, riCap, capReqDefBeforeAssociate);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, designerUser,
- resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF.getUniqueId()));
-
- RestResponse secondDisociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef,
- designerUser, resourceDetailsVF.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, secondDisociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
-
- RestResponse changeResourceStateToCheckout2 = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKIN);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckout2);
- RestResponse changeResourceStateToCheckout3 = LifecycleRestUtils.changeResourceState(resourceDetailsVF,
- designerUser, LifeCycleStatesEnum.CHECKOUT);
- LifecycleRestUtils.checkSuccess(changeResourceStateToCheckout3);
-
- assertTrue(getComponentInstancesRelations(resourceDetailsVF.getUniqueId()).isEmpty());
-
- }
-
-}
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
deleted file mode 100644
index 126aabdd03..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.resource;
-
-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;
-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.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.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.imports.ImportGenericResourceCITest;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import java.util.*;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-public class GetResourceNotAbstractApiTest extends ComponentBaseTest {
-
- private static Logger logger = LoggerFactory.getLogger(ComponentBaseTest.class.getName());
- protected static final int STATUS_CODE_GET_SUCCESS = 200;
-
- protected Config config = Config.instance();
- protected String contentTypeHeaderData = "application/json";
- protected String acceptHeaderDate = "application/json";
-
- @Rule
- public static TestName name = new TestName();
-
- public GetResourceNotAbstractApiTest() {
- super(name, GetResourceNotAbstractApiTest.class.getName());
- }
-
- @Test
- public void getNotAbstractResourceList() throws Exception {
-
- // remove all the not abstract resources
- // Map<NormativeTypes, Boolean> originalState =
- // ImportResourceCITest.removeAllNormativeTypeResources();
-
- // import all the default not abstract resources
- // ImportGenericResourceCITest.importAllNormativeTypesResources(UserRoleEnum.ADMIN);
-
- // Get not abstract resources
- RestResponse getResourceNotAbstarctResponse = getNotAbstractResources();
- // Check that received 200.
- assertEquals("Check response code after get abstract resources", STATUS_CODE_GET_SUCCESS,
- getResourceNotAbstarctResponse.getErrorCode().intValue());
- // Verify that all the resources not abstract
- assertTrue("One or more resources are abstract", isAllResourcesNotAbstract(getResourceNotAbstarctResponse));
- // Verify that all the resources are certified
- assertTrue("Not all the resources are certified", isAllResourcesCertified(getResourceNotAbstarctResponse));
-
- String objectStorageUid = "ObjectStorage";
- String computeUid = "Compute";
- String blockStorageUid = "BlockStorage";
- String loadBalancerUid = "LoadBalancer";
- // String portUid = "tosca.nodes.Network.Port";
- String portUid = "Port";
- String networkUid = "Network";
- String databaseUid = "Database";
-
- // Compare expected list of abstract resources to actual list of
- // abstract resources.
- List<String> expectedNotAbstractResourcesUniqueIdArray = new ArrayList<String>(Arrays.asList(computeUid,
- databaseUid, objectStorageUid, blockStorageUid, loadBalancerUid, portUid, networkUid));
-
- List<String> actualNotAbstarctResourcesUniqueIdArray = restResponseToListByHeader(
- getResourceNotAbstarctResponse, "name");
-
- // Collections.sort(actualNotAbstarctResourcesUniqueIdArray);
- // Collections.sort(expectedNotAbstractResourcesUniqueIdArray);
-
- List<String> toFind = new ArrayList<>();
- toFind.add(objectStorageUid);
- toFind.add(computeUid);
- toFind.add(blockStorageUid);
- toFind.add(loadBalancerUid);
- toFind.add(portUid);
-
- boolean removeAll = toFind.removeAll(actualNotAbstarctResourcesUniqueIdArray);
- logger.debug("Cannot find resources {}", toFind.toString());
-
- for (String expectedResource : expectedNotAbstractResourcesUniqueIdArray) {
- if (false == actualNotAbstarctResourcesUniqueIdArray.contains(expectedResource)) {
- // System.out.println("Not found abstract resource " +
- // expectedResource);
- }
- }
-
- assertTrue(
- "Expected abstract resources list: " + expectedNotAbstractResourcesUniqueIdArray.toString()
- + " Actual: " + actualNotAbstarctResourcesUniqueIdArray.toString(),
- actualNotAbstarctResourcesUniqueIdArray.containsAll(expectedNotAbstractResourcesUniqueIdArray));
-
- /*
- * java.lang.AssertionError: Expected abstract resources list:
- * [tosca.nodes.Compute, tosca.nodes.ObjectStorage,
- * tosca.nodes.BlockStorage, tosca.nodes.LoadBalancer,
- * tosca.nodes.Network.Port] Actual: [resourceforproperty216,
- * tosca.nodes.Compute, tosca.nodes.Database, resourceforproperty217,
- * resourceforproperty217, tosca.nodes.ObjectStorage,
- * tosca.nodes.BlockStorage, tosca.nodes.LoadBalancer,
- * tosca.nodes.network.Port, tosca.nodes.network.Network,
- * resourceforproperty217, resourceforproperty217,
- * resourceforproperty217, resourceforproperty217,
- * resourceforproperty217, resourceforproperty217,
- * resourceforproperty217, resourceforproperty217,
- * resourceforproperty217, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317,
- * resourceforproperty317, resourceforproperty317]
- */
-
- // Create resource (not certified)
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- String resourceName = "TestResource";
- String description = "description";
- ArrayList<String> resourceTags = new ArrayList<String>();
- resourceTags.add(resourceName);
- String category = ServiceCategoriesEnum.MOBILITY.getValue();
- ArrayList<String> derivedFrom = new ArrayList<String>();
- derivedFrom.add("tosca.nodes.root");
- String vendorName = "Oracle";
- String vendorRelease = "1.0";
- String contactId = "Peter";
- String icon = "myICON";
-
- ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
- derivedFrom, vendorName, vendorRelease, contactId, icon);
-
- ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- // assertEquals("Check response code after create user", 201,
- // restResponse.getErrorCode().intValue());
-
- // Get not abstract resources
- getResourceNotAbstarctResponse = getNotAbstractResources();
- // Check that received 200.
- assertEquals("Check response code after get abstract resources", STATUS_CODE_GET_SUCCESS,
- getResourceNotAbstarctResponse.getErrorCode().intValue());
- // Verify that all the resources not abstract
- assertTrue("One or more resources are abstract", isAllResourcesNotAbstract(getResourceNotAbstarctResponse));
- // Verify that all the resources are certified
- assertTrue("Not all the resources are certified", isAllResourcesCertified(getResourceNotAbstarctResponse));
-
- // Compare expected list of abstract resources to actual list of
- // abstract resources.
- // expectedNotAbstractResourcesUniqueIdArray = new
- // ArrayList<String>(Arrays.asList("tosca.nodes.compute.1.0",
- // "tosca.nodes.objectstorage.1.0", "tosca.nodes.blockstorage.1.0",
- // "tosca.nodes.loadbalancer.1.0", "tosca.nodes.network.port.1.0"));
-
- // actualNotAbstarctResourcesUniqueIdArray =
- // restResponseToListByHeader(getResourceNotAbstarctResponse,
- // "uniqueId");
-
- actualNotAbstarctResourcesUniqueIdArray = restResponseToListByHeader(getResourceNotAbstarctResponse, "name");
-
- Collections.sort(actualNotAbstarctResourcesUniqueIdArray);
- Collections.sort(expectedNotAbstractResourcesUniqueIdArray);
-
- for (String expectedResource : expectedNotAbstractResourcesUniqueIdArray) {
- if (false == actualNotAbstarctResourcesUniqueIdArray.contains(expectedResource)) {
- // System.out.println("Not found abstract resource " +
- // expectedResource);
- }
- }
- assertTrue(
- "Expected abstract resources list: " + expectedNotAbstractResourcesUniqueIdArray.toString()
- + " Actual: " + actualNotAbstarctResourcesUniqueIdArray.toString(),
- actualNotAbstarctResourcesUniqueIdArray.containsAll(expectedNotAbstractResourcesUniqueIdArray));
- // assertTrue("Expected abstract resources list: "+
- // expectedNotAbstractResourcesUniqueIdArray.toString()+ " Actual:
- // "+actualNotAbstarctResourcesUniqueIdArray.toString(),expectedNotAbstractResourcesUniqueIdArray.equals(actualNotAbstarctResourcesUniqueIdArray));
-
- // restore the resources
- // ImportResourceCITest.restoreToOriginalState(originalState);
-
- }
-
- protected RestResponse getNotAbstractResources() throws Exception {
- HttpRequest httpRequest = new HttpRequest();
-
- String url = String.format(Urls.GET_ALL_NOT_ABSTRACT_RESOURCES, config.getCatalogBeHost(),
- config.getCatalogBePort());
-
- 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(), "cs0008");
-
- RestResponse getResourceNotAbstarctResponse = httpRequest.httpSendGet(url, headersMap);
-
- return getResourceNotAbstarctResponse;
- }
-
- protected List<String> restResponseToListByHeader(RestResponse restResponse, String restResponseHeader) {
- JsonElement jelement = new JsonParser().parse(restResponse.getResponse());
- JsonArray jsonArray = jelement.getAsJsonArray();
-
- List<String> restResponseArray = new ArrayList<>();
-
- for (int i = 0; i < jsonArray.size(); i++) {
- JsonObject jobject = (JsonObject) jsonArray.get(i);
- String header = jobject.get(restResponseHeader).toString();
- header = header.replace("\"", "");
- restResponseArray.add(header);
- }
-
- return restResponseArray;
-
- }
-
- protected boolean isAllResourcesNotAbstract(RestResponse restResponse) {
- JsonElement jelement = new JsonParser().parse(restResponse.getResponse());
- JsonArray jsonArray = jelement.getAsJsonArray();
-
- for (int i = 0; i < jsonArray.size(); i++) {
- JsonObject jobject = (JsonObject) jsonArray.get(i);
-
- if (jobject.get("abstract").getAsBoolean()) {
- return false;
- }
-
- }
- return true;
-
- }
-
- protected boolean isEmptyList(RestResponse restResponse) {
- JsonElement jelement = new JsonParser().parse(restResponse.getResponse());
- JsonArray jsonArray = jelement.getAsJsonArray();
-
- if (jsonArray.size() == 0) {
- return true;
- }
- return false;
- }
-
- protected boolean isAllResourcesCertified(RestResponse restResponse) {
- JsonElement jelement = new JsonParser().parse(restResponse.getResponse());
- JsonArray jsonArray = jelement.getAsJsonArray();
-
- String certified = "CERTIFIED";
- String lifecycleState;
-
- for (int i = 0; i < jsonArray.size(); i++) {
- JsonObject jobject = (JsonObject) jsonArray.get(i);
- lifecycleState = jobject.get("lifecycleState").getAsString();
- if (!lifecycleState.equals(certified)) {
- return false;
- }
-
- }
- return true;
- }
-
- @Test(enabled = false)
- public void getEmptyNonAbstractResourcesList() throws Exception {
- // remove all the not abstract resources
- Map<NormativeTypesEnum, Boolean> originalState = ImportGenericResourceCITest.removeAllNormativeTypeResources();
-
- // Get not abstract resources
- RestResponse getResourceNotAbstarctResponse = getNotAbstractResources();
- // Check that received 200.
- assertEquals("Check response code after get abstract resources", STATUS_CODE_GET_SUCCESS,
- getResourceNotAbstarctResponse.getErrorCode().intValue());
- // Verify empty list
- assertTrue("Received list is not empty", isEmptyList(getResourceNotAbstarctResponse));
-
- // restore the resources
- // ImportResourceCITest.restoreToOriginalState(originalState);
- // import the resources
- ImportGenericResourceCITest.importAllNormativeTypesResources(UserRoleEnum.ADMIN);
- }
-
-}
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
deleted file mode 100644
index e966b4aae9..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java
+++ /dev/null
@@ -1,1770 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.resource;
-
-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.*;
-import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-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.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-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
- public static TestName name = new TestName();
-
- public VfComponentInstanceCRUDTest() {
- super(name, VfComponentInstanceCRUDTest.class.getName());
- }
-
- @BeforeMethod
- public void before() throws Exception {
- init();
- createComponents();
- }
-
- // CREATE Resource
- private void createComponents() throws Exception {
- createAtomicResource(resourceDetailsVFC_01);
- LifecycleRestUtils.changeResourceState(resourceDetailsVFC_01, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createAtomicResource(resourceDetailsVFC_02);
- LifecycleRestUtils.changeResourceState(resourceDetailsVFC_02, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createAtomicResource(resourceDetailsCP_01);
- LifecycleRestUtils.changeResourceState(resourceDetailsCP_01, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createAtomicResource(resourceDetailsCP_02);
- LifecycleRestUtils.changeResourceState(resourceDetailsCP_02, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createAtomicResource(resourceDetailsVL_01);
- LifecycleRestUtils.changeResourceState(resourceDetailsVL_01, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createAtomicResource(resourceDetailsVL_02);
- LifecycleRestUtils.changeResourceState(resourceDetailsVL_02, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createVF(resourceDetailsVF_02);
- }
-
- @Test
- public void createVfcInstanceByDesigner() throws Exception {
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVFC_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test(enabled = false) // DE189419
- public void createInstanceOfVfToItself() throws Exception {
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVF_02);
- createAtomicResourceInstance = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails,
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertTrue(createAtomicResourceInstance.getErrorCode() == STATUS_CODE_NOT_FOUND);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void createVfcInstanceByAdmin() throws Exception {
- User user = sdncAdminDetails;
- createVF(resourceDetailsVF_01, user);
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_01,
- resourceDetailsVFC_01, user);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_01, 1, 0);
- }
-
- @Test
- public void createCpInstance() throws Exception {
- // Create CP instance
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void createVlInstance() throws Exception {
- // Create VL instance
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void updateResourceInstanceNameLessMaxLegth() throws Exception {
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName("xxxxXthisXstringxisx49XcharcatersXlengthXxxxxxxxx");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
-
- }
-
- @Test
- public void updateInstanceNameExceedMaxLegth() throws Exception {
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName("xxxxXthisXstringxisx51XcharcatersXlengthXxxxxxxxxxx");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT,
- updateResourceInstanceResponse.getErrorCode().intValue());
- }
-
- @Test
- public void updateResourceInstanceNameHasMaxLegth() throws Exception {
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName("xxxxXthisXstringxisx50XcharcatersXlengthXxxxxxxxxx");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- }
-
- @Test
- public void resourceInstanceNameIsEmpty() throws Exception {
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- resourceInstanceReqDetails.setName("");
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- String instanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "name");
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "1").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance Name ", (resourceDetailsVFC_01.getName() + " 1"),
- instanceName);
- }
-
- @Test
- public void resourceInstanceNameIsNull() throws Exception {
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- resourceInstanceReqDetails.setName(null);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- String instanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "name");
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "1").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance Name ", (resourceDetailsVFC_01.getName() + " 1"),
- instanceName);
- }
-
- @Test
- public void resourceInstanceNameValidation01() throws Exception {
- // 2 Instances
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String instanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "name");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "1").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance Name ", (resourceDetailsVFC_01.getName() + " 1"),
- instanceName);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails,
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "normalizedName");
- instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "name");
- componentInstance = ResponseParser.parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(),
- ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "2").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ", (resourceDetailsVFC_01.getName() + " 2"),
- instanceName);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void resourceInstanceNameValidation02() throws Exception {
-
- // 2 Instances
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String instanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "name");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "1").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance Name ", (resourceDetailsVFC_01.getName() + " 1"),
- instanceName);
- resourceInstanceReqDetails = ElementFactory.getComponentResourceInstance(resourceDetailsCP_01);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails,
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "normalizedName");
- instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "name");
- componentInstance = ResponseParser.parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(),
- ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsCP_01.getName() + "2").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ", (resourceDetailsCP_01.getName() + " 2"),
- instanceName);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void createVfcInstanceByTester() throws Exception { // Response 409
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncTesterDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- @Test
- public void createVfcInstance_UserIdIsEmpty() throws Exception {
-
- User sdncUserDetails = new User();
- sdncUserDetails.setUserId("");
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncUserDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- @Test
- public void createVfcInstance_UserIdIsNonAsdcUser() throws Exception {
-
- User sdncUserDetails = new User();
- sdncUserDetails.setUserId("bt4567");
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncUserDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- @Test
- public void createAllAtomicInstances() throws Exception {
-
- // Add to VF resource VFC, CP and VL instances
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVFC_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 3, 0);
- }
-
- @Test
- public void createDefferentVfcInstances() throws Exception {
-
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVFC_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVFC_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void createDefferentCpInstances() throws Exception {
-
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsCP_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void createDefferentVLInstances() throws Exception {
-
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVL_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void createSeveralInstanceOfSameVFC() throws Exception {
-
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVFC_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVFC_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void createSeveralInstanceOfSameVL() throws Exception {
-
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVL_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void createSeveralInstanceOfSameCP() throws Exception {
-
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void createInstanceOfCpToVfc() throws Exception { // Add to CP to VFC
- // (not allowed)
-
- ComponentInstanceReqDetails resourceInstanceReqDetailsCP = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- ComponentInstanceReqDetails resourceInstanceReqDetailsVFC = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetailsCP, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetailsCP, sdncDesignerDetails, resourceInstanceReqDetailsVFC.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void createInstanceVfcToCp() throws Exception { // (not allowed)
-
- ComponentInstanceReqDetails resourceInstanceReqDetailsCP = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- ComponentInstanceReqDetails resourceInstanceReqDetailsVFC = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetailsCP, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetailsVFC, sdncDesignerDetails, resourceInstanceReqDetailsCP.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void createInstanceVlToVfc() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetailsVL = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- ComponentInstanceReqDetails resourceInstanceReqDetailsVFC = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetailsVFC, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetailsVL, sdncDesignerDetails, resourceInstanceReqDetailsVFC.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void createInstanceToNonSupportedComponentType() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetailsCP = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetailsCP, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE_INSTANCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_INVALID_CONTENT,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- // ("Create instance without position is allowed")
- @Test
- public void createInstanceOfVlWithoutPosXAndPosY() throws Exception { // instance
- // does
- // not
- // have
- // position
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- resourceInstanceReqDetails.setPosX("");
- resourceInstanceReqDetails.setPosY("");
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- // Create instance without position is allowed")
- @Test
- public void createInstanceOfVlWithPositionNull() throws Exception { // instance
- // does
- // not
- // have
- // position
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- resourceInstanceReqDetails.setPosX(null);
- resourceInstanceReqDetails.setPosY(null);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void createResourceInstanceForNonCheckedOutVF() throws Exception {
-
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncAdminDetails,
- "0.1", LifeCycleStatesEnum.CHECKIN);
- resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- AssertJUnit.assertEquals("Check response code after create user", STATUS_CODE_SUCCESS,
- checkInResponse.getErrorCode().intValue());
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- createResourceInstanceResponse.getErrorCode().intValue());
- }
-
- @Test
- public void createResourceInstanceVfCheckedOutByOtherUser() throws Exception {
-
- // Admin try to add RI to VF which is checked-Out By Designer
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncAdminDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- @Test
- public void createResourceInstanceForNonExistingVF() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, "blablabla", ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- createResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- // Delete
- @Test
- public void deleteVfcInstanceByDesigner() throws Exception {
-
- // Create RI
- RestResponse createResourceInstanceResponse = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVFC_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = deleteAtomicInstanceForVF(compInstId, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkDeleteResponse(deleteResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- @Test
- public void deleteVfcInstanceByAdmin() throws Exception {
- createVF(resourceDetailsVF_01, sdncAdminDetails);
- RestResponse createResourceInstanceResponse = createAtomicInstanceForVF(resourceDetailsVF_01,
- resourceDetailsVL_01, sdncAdminDetails);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_01, 1, 0);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = deleteAtomicInstanceForVF(compInstId, resourceDetailsVF_01,
- sdncAdminDetails);
- ResourceRestUtils.checkDeleteResponse(deleteResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_01, 0, 0);
- }
-
- @Test
- public void deleteCpInstance() throws Exception {
-
- RestResponse createResourceInstanceResponse = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = deleteAtomicInstanceForVF(compInstId, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkDeleteResponse(deleteResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- @Test
- public void deleteVlInstance() throws Exception {
-
- RestResponse createResourceInstanceResponse = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = deleteAtomicInstanceForVF(compInstId, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkDeleteResponse(deleteResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- }
-
- @Test
- public void deleteOneVlInstance() throws Exception {
-
- // RI-1
- RestResponse createResourceInstanceResponse = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- // RI-2
- createResourceInstanceResponse = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVL_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- // Delete Resource instance RI-1
- RestResponse deleteResourceInstanceResponse = deleteAtomicInstanceForVF(compInstId, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkDeleteResponse(deleteResourceInstanceResponse);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteVfcInstanceCheckedByOtherUser() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncTesterDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteInstanceNonSupportedComponentType() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE_INSTANCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_INVALID_CONTENT,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteInstanceFromNonVF() throws Exception {
- // RI-1
-
- ComponentInstanceReqDetails resourceInstanceVlReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceVlReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance1 = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance1, ComponentTypeEnum.RESOURCE);
- // RI-2
- ComponentInstanceReqDetails resourceInstanceCplReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceCplReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance2 = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance2, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- // Delete VL instance from CP instance
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceInstanceCplReqDetails.getUniqueId(),
- resourceInstanceVlReqDetails.getUniqueId(), ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- }
-
- @Test
- public void deleteNonExistingInstanceFromVF() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceVlReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceVlReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance1 = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance1, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- resourceInstanceVlReqDetails.setUniqueId("1234567890");
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceVlReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteCpInstanceFromNonCheckOutVF() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceCpReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceCpReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance1 = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance1, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails,
- "0.1", LifeCycleStatesEnum.CHECKIN);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_SUCCESS,
- checkInResponse.getErrorCode().intValue());
- resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceCpReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteVlInstanceFromNonCheckOutVF() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceVlReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceVlReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance1 = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance1, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails,
- "0.1", LifeCycleStatesEnum.CHECKIN);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_SUCCESS,
- checkInResponse.getErrorCode().intValue());
- resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceVlReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteVfcInstanceFromNonCheckOutVF() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceVfcReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceVfcReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance1 = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance1, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails,
- "0.1", LifeCycleStatesEnum.CHECKIN);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_SUCCESS,
- checkInResponse.getErrorCode().intValue());
- resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- // Delete Resource instance
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceVfcReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteVlInstance_UserIdIsNonAsdcUser() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- // Delete Resource instance by non-ASDC User
- User sdncUserDetails = new User();
- sdncUserDetails.setUserId("bt4567");
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncUserDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void deleteAlreadyDeletedInstance() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_DELETE,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- deleteCompInstReqCapFromExpected(componentInstance.getUniqueId());
- getComponentAndValidateRIs(resourceDetailsVF_02, 0, 0);
- deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncDesignerDetails,
- resourceDetailsVF_02.getUniqueId(), resourceInstanceReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- }
-
- @Test
- public void reCreateDeletedInstance() throws Exception {
-
- // 2 Instances
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String instanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "name");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "1").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance Name ", (resourceDetailsVFC_01.getName() + " 1"),
- instanceName);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails,
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "normalizedName");
- instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "name");
- componentInstance = ResponseParser.parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(),
- ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "2").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ", (resourceDetailsVFC_01.getName() + " 2"),
- instanceName);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- // Delete one instance
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), resourceInstanceReqDetails.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_DELETE,
- deleteResourceInstanceResponse.getErrorCode().intValue());
- deleteCompInstReqCapFromExpected(componentInstance.getUniqueId());
- // Create same instance again
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails,
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(),
- "normalizedName");
- instanceName = ResponseParser.getValueFromJsonResponse(createResourceInstanceResponse.getResponse(), "name");
- componentInstance = ResponseParser.parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(),
- ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "3").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance Name ", (resourceDetailsVFC_01.getName() + " 3"),
- instanceName);
-
- }
-
- // Update
- @Test
- public void updateVfcInstanceNameByDesigner() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName("abcd");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String resourceNameFromJsonResponse = ResponseParser.getNameFromResponse(updateResourceInstanceResponse);
- AssertJUnit.assertEquals(resourceNameFromJsonResponse, vfcResourceInstanceReqDetails.getName());
- String riNormalizedName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "normalizedName");
- String riName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "name");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riNormalizedName, "abcd");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riName, "abcd");
- }
-
- @Test
- public void updateVfcInstanceNameByAdmin() throws Exception {
- User user = sdncAdminDetails;
- createVF(resourceDetailsVF_01, user);
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncAdminDetails, resourceDetailsVF_01.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_01, 1, 0);
- vfcResourceInstanceReqDetails.setName("ABCD E");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncAdminDetails, resourceDetailsVF_01.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String resourceNameFromJsonResponse = ResponseParser.getNameFromResponse(updateResourceInstanceResponse);
- AssertJUnit.assertEquals(resourceNameFromJsonResponse, vfcResourceInstanceReqDetails.getName());
- String riNormalizedName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "normalizedName");
- String riName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "name");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riNormalizedName, "abcde");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riName, "ABCD E");
- }
-
- @Test
- public void updateInstanceNameAllowedCharacters() throws Exception {
- // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
- // ('_'), dash ('-'), dot ('.'))
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName("Abcd_1234567890-qwert-yuiop.zxcvb");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String resourceNameFromJsonResponse = ResponseParser.getNameFromResponse(updateResourceInstanceResponse);
- AssertJUnit.assertEquals(resourceNameFromJsonResponse, vfcResourceInstanceReqDetails.getName());
- String riNormalizedName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "normalizedName");
- String riName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "name");
- // assertEquals("Check if RI normalizedName is correct ",
- // riNormalizedName, "abcd_1234567890-qwert-yuiop.zxcv" );
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riName, "Abcd_1234567890-qwert-yuiop.zxcvb");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riNormalizedName,
- "abcd1234567890qwertyuiopzxcvb");
-
- }
-
- @Test
- public void updateVfcInstanceNameEmpty() throws Exception {
- // see US534663 In case a designer removes the current resource instance
- // name then BE has to generate again the "default" resource instance
- // name
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String newName = "";
- vfcResourceInstanceReqDetails.setName(newName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String instanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "name");
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "2").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ", (resourceDetailsVFC_01.getName() + " 2"),
- instanceName);
- }
-
- @Test
- public void updateVfcInstanceNameNull() throws Exception {
- // see US534663 In case a designer removes the current resource instance
- // name then BE has to generate again the "default" resource instance
- // name
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String newName = null;
- vfcResourceInstanceReqDetails.setName(newName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- final String updateResponse = updateResourceInstanceResponse.getResponse();
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateResponse, "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateResponse, "name");
- AssertJUnit.assertEquals("check Resource Instance normalizedName ",
- (resourceDetailsVFC_01.getName() + "2").toLowerCase(), instanceNormalizedName);
- AssertJUnit.assertEquals("check Resource Instance normalizedName ", (resourceDetailsVFC_01.getName() + " 2"),
- instanceName);
- }
-
- @Test
- public void updateCpInstanceName() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName("AbcD");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String resourceNameFromJsonResponse = ResponseParser.getNameFromResponse(updateResourceInstanceResponse);
- AssertJUnit.assertEquals(resourceNameFromJsonResponse, vfcResourceInstanceReqDetails.getName());
- String riNormalizedName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "normalizedName");
- String riName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "name");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riNormalizedName, "abcd");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riName, "AbcD");
- }
-
- @Test
- public void updateVlInstanceName() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName("ABCD");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String resourceNameFromJsonResponse = ResponseParser.getNameFromResponse(updateResourceInstanceResponse);
- AssertJUnit.assertEquals(resourceNameFromJsonResponse, vfcResourceInstanceReqDetails.getName());
- String riNormalizedName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "normalizedName");
- String riName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "name");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riNormalizedName, "abcd");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riName, "ABCD");
- }
-
- @Test
- public void updateInstanceNameToArleadyExistInstanceName02() throws Exception {
-
- // Create VFC instance
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance vfcComponentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(vfcComponentInstance, ComponentTypeEnum.RESOURCE);
- // Create CP instance
- ComponentInstanceReqDetails cpResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- cpResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance cpComponentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(cpComponentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 2, 0);
- cpResourceInstanceReqDetails.setName(vfcComponentInstance.getName());
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- cpResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_ALREADY_EXISTS,
- updateResourceInstanceResponse.getErrorCode().intValue());
- }
-
- @Test
- public void updateInstanceNameMaxLength() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl12345";
- vfcResourceInstanceReqDetails.setName(newName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String resourceNameFromJsonResponse = ResponseParser.getNameFromResponse(updateResourceInstanceResponse);
- AssertJUnit.assertEquals(resourceNameFromJsonResponse, vfcResourceInstanceReqDetails.getName());
- String riNormalizedName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "normalizedName");
- String riName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "name");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riNormalizedName, newName.toLowerCase());
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riName, newName);
- }
-
- @Test
- public void updateInstanceNameExceedMaxLength() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456";
- vfcResourceInstanceReqDetails.setName(newName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT,
- updateResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void updateCpInstanceCheckedByOtherUser() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String newName = "Qwertyuiop1234567890";
- resourceInstanceReqDetails.setName(newName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- resourceInstanceReqDetails, sdncAdminDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- updateResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void UpdateVfcInstance_UserIdIsNonAsdcUser() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String newName = "Qwertyuiop1234567890";
- resourceInstanceReqDetails.setName(newName);
- User nonSdncUserDetails = new User();
- nonSdncUserDetails.setUserId("bt4567");
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- resourceInstanceReqDetails, nonSdncUserDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- updateResourceInstanceResponse.getErrorCode().intValue());
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- }
-
- @Test
- public void UpdateResourceInstanceFormNonExistingVF() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- // LifecycleRestUtils.changeResourceState(resourceDetailsVL_01,
- // sdncAdminDetails, "0.1", LifeCycleStatesEnum.CHECKIN);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String newName = "Qwertyuiop1234567890";
- resourceInstanceReqDetails.setName(newName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, "blablabla", ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- updateResourceInstanceResponse.getErrorCode().intValue());
- }
-
- @Test
- public void updateNonExistingInstanceFromVF() throws Exception {
-
- ComponentInstanceReqDetails resourceInstanceVlReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceVlReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance1 = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance1, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- resourceInstanceVlReqDetails.setUniqueId("1234567890");
- // String newName= "Qwertyuiop1234567890";
- // resourceInstanceVlReqDetails.setName(newName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- resourceInstanceVlReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- updateResourceInstanceResponse.getErrorCode().intValue());
- }
-
- // Update
- @Test
- public void updateVfcInstanceNameAsVfName() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- vfcResourceInstanceReqDetails.setName(resourceDetailsVF_02.getName());
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String resourceNameFromJsonResponse = ResponseParser.getNameFromResponse(updateResourceInstanceResponse);
- AssertJUnit.assertEquals(resourceNameFromJsonResponse, vfcResourceInstanceReqDetails.getName());
- String riNormalizedName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "normalizedName");
- String riName = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "name");
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riNormalizedName,
- resourceDetailsVF_02.getName().toLowerCase());
- AssertJUnit.assertEquals("Check if RI normalizedName is correct ", riName, resourceDetailsVF_02.getName());
- }
-
- @Test
- public void updateInstanceNameInvalidCharacters() throws Exception {
- char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/',
- '|', '\\', ',' };
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String newName = "Abcd1";
- String updateName;
- for (int i = 0; i < invalidChars.length; i++) {
- updateName = newName + invalidChars[i];
- vfcResourceInstanceReqDetails.setName(updateName);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_INVALID_CONTENT,
- updateResourceInstanceResponse.getErrorCode().intValue());
- }
- }
-
- // Update Position
- @Test
- public void updateVfcInstancePosition() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String updatePosX = "130";
- String updatePosY = "180";
- vfcResourceInstanceReqDetails.setPosX(updatePosX);
- vfcResourceInstanceReqDetails.setPosY(updatePosY);
- vfcResourceInstanceReqDetails.setName(null);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String posXFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posX");
- String posYFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posY");
- AssertJUnit.assertEquals(posXFromJsonResponse, updatePosX);
- AssertJUnit.assertEquals(posYFromJsonResponse, updatePosY);
- }
-
- @Test
- public void updateVlInstancePosition() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVL_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String updatePosX = "130";
- String updatePosY = "180";
- vfcResourceInstanceReqDetails.setPosX(updatePosX);
- vfcResourceInstanceReqDetails.setPosY(updatePosY);
- vfcResourceInstanceReqDetails.setName(null);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String posXFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posX");
- String posYFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posY");
- AssertJUnit.assertEquals(posXFromJsonResponse, updatePosX);
- AssertJUnit.assertEquals(posYFromJsonResponse, updatePosY);
- }
-
- @Test
- public void updateCpInstancePosition() throws Exception {
-
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String updatePosX = "130";
- String updatePosY = "180";
- vfcResourceInstanceReqDetails.setPosX(updatePosX);
- vfcResourceInstanceReqDetails.setPosY(updatePosY);
- vfcResourceInstanceReqDetails.setName(null);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String posXFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posX");
- String posYFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posY");
- AssertJUnit.assertEquals(posXFromJsonResponse, updatePosX);
- AssertJUnit.assertEquals(posYFromJsonResponse, updatePosY);
- }
-
- @Test
- public void updateInstancePositionNegativePosition() throws Exception {
-
- ComponentInstanceReqDetails cpResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- cpResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.RESOURCE);
- getComponentAndValidateRIs(resourceDetailsVF_02, 1, 0);
- String updatePosX = "-100";
- String updatePosY = "-100";
- cpResourceInstanceReqDetails.setPosX(updatePosX);
- cpResourceInstanceReqDetails.setPosY(updatePosY);
- cpResourceInstanceReqDetails.setName(null);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- cpResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String posXFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posX");
- String posYFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posY");
- AssertJUnit.assertEquals(posXFromJsonResponse, updatePosX);
- AssertJUnit.assertEquals(posYFromJsonResponse, updatePosY);
- }
-
- @Test
- public void updateInstancesPositionSameLocationForBothInstances() throws Exception {
-
- ComponentInstanceReqDetails cpResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- cpResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- ComponentInstanceReqDetails vfcResourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsVFC_01);
- createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkCreateResponse(createResourceInstanceResponse);
- String updatePosX = "100";
- String updatePosY = "500";
- vfcResourceInstanceReqDetails.setPosX(updatePosX);
- vfcResourceInstanceReqDetails.setPosY(updatePosY);
- vfcResourceInstanceReqDetails.setName(null);
- cpResourceInstanceReqDetails.setPosX(updatePosX);
- cpResourceInstanceReqDetails.setPosY(updatePosY);
- cpResourceInstanceReqDetails.setName(null);
- RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- vfcResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- String posXFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posX");
- String posYFromJsonResponse = ResponseParser
- .getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(), "posY");
- AssertJUnit.assertEquals(posXFromJsonResponse, updatePosX);
- AssertJUnit.assertEquals(posYFromJsonResponse, updatePosY);
- updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
- cpResourceInstanceReqDetails, sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(),
- ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(updateResourceInstanceResponse);
- posXFromJsonResponse = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "posX");
- posYFromJsonResponse = ResponseParser.getValueFromJsonResponse(updateResourceInstanceResponse.getResponse(),
- "posY");
- AssertJUnit.assertEquals(posXFromJsonResponse, updatePosX);
- AssertJUnit.assertEquals(posYFromJsonResponse, updatePosY);
- }
-
- @Test
- public void createAllAtomicInstancesTestGetReqCapAPI_suc() throws Exception {
-
- // Add to VF resource VFC, CP and VL instances
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVFC_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
-
- getVfResourceReqCapUsingAPI(3, 0, sdncDesignerDetails);
-
- }
-
- // END of Update
-
- @Test
- public void createAllAtomicInstancesTestGetReqCapAPIfailed() throws Exception {
-
- // Add to VF resource VFC, CP and VL instances
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVFC_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- resourceDetailsVF_02.setUniqueId("dummy");
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncAdminDetails,
- resourceDetailsVF_02);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- getResourceResponse.getErrorCode().intValue());
-
- }
-
- @Test
- public void associateInVF() throws Exception {
-
- ResourceReqDetails resourceDetailsReq = ElementFactory.getDefaultResourceByType("SoftCompRouter",
- NormativeTypesEnum.SOFTWARE_COMPONENT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
- sdncDesignerDetails.getUserId(), ResourceTypeEnum.VFC); // resourceType
- // = VFC
- ResourceReqDetails resourceDetailsCap = ElementFactory.getDefaultResourceByType("MyComput",
- NormativeTypesEnum.COMPUTE, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, sdncDesignerDetails.getUserId(),
- ResourceTypeEnum.VFC); // resourceType = VFC
- createAtomicResource(resourceDetailsReq);
- LifecycleRestUtils.changeResourceState(resourceDetailsReq, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createAtomicResource(resourceDetailsCap);
- LifecycleRestUtils.changeResourceState(resourceDetailsCap, sdncAdminDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
-
- RestResponse riReqR = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsReq, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(riReqR);
- RestResponse riCapR = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsCap, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(riCapR);
-
- ComponentInstance riReq = ResponseParser.parseToObject(riReqR.getResponse(), ComponentInstance.class);
- ComponentInstance riCap = ResponseParser.parseToObject(riCapR.getResponse(), ComponentInstance.class);
-
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- resourceDetailsVF_02);
-
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
-
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get("tosca.capabilities.Container");
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get("tosca.capabilities.Container");
-
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- requirementDef.setFromNode(riReq.getUniqueId());
- requirementDef.setToNode(riCap.getUniqueId());
-
- RelationshipInfo pair = new RelationshipInfo();
- pair.setRequirementOwnerId(riReq.getUniqueId());
- pair.setCapabilityOwnerId(riCap.getUniqueId());
- pair.setRequirement("host");
- RelationshipImpl relationship = new RelationshipImpl();
- relationship.setType("tosca.capabilities.Container");
- pair.setRelationships(relationship);
- pair.setCapabilityUid(capList.get(0).getUniqueId());
- pair.setRequirementUid(reqList.get(0).getUniqueId());
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
- relationships.add(capReqRel);
- capReqRel.setRelation(pair);
- requirementDef.setRelationships(relationships);
-
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_SUCCESS,
- associateInstances.getErrorCode().intValue());
-
- getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- resourceDetailsVF_02);
- capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
-
- List<RequirementDefinition> list = capReqDef.getRequirements().get("tosca.capabilities.Container");
- AssertJUnit.assertEquals("Check requirement", null, list);
-
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF_02.getUniqueId(), ComponentTypeEnum.RESOURCE);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_SUCCESS,
- dissociateInstances.getErrorCode().intValue());
-
- getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- resourceDetailsVF_02);
- capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
-
- list = capReqDef.getRequirements().get("tosca.capabilities.Container");
- AssertJUnit.assertEquals("Check requirement", 1, list.size());
-
- }
-
- /*@Test
- public void testUnsatisfiedCpReqInVF() throws Exception {
-
- // Certify all the needed atomic resources
- RestResponse response = LifecycleRestUtils.certifyResource(resourceDetailsVFC_02);
- ResourceRestUtils.checkSuccess(response);
- response = LifecycleRestUtils.certifyResource(resourceDetailsCP_01);
- ResourceRestUtils.checkSuccess(response);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails,
- resourceDetailsVF_02.getUniqueId());
- ResourceRestUtils.checkSuccess(response);
-
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02,
- resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String compInstName = ResponseParser.getNameFromResponse(createAtomicResourceInstance);
- String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- RestResponse submitForTesting = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02,
- sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- String[] variables = new String[] { resourceDetailsVF_02.getName(), "VF", "CP (Connection Point)", compInstName,
- "requirement", "tosca.capabilities.network.Bindable", "fulfilled" };
- BaseValidationUtils.checkErrorResponse(submitForTesting,
- ActionStatus.REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION, variables);
-
- createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsVF_02, resourceDetailsVFC_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String computeCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
- fulfillCpRequirement(resourceDetailsVF_02, cpCompInstId, computeCompInstId, computeCompInstId,
- sdncDesignerDetails, ComponentTypeEnum.RESOURCE);
-
- submitForTesting = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- BaseValidationUtils.checkSuccess(submitForTesting);
- }*/
-
- private void getVfResourceReqCapUsingAPI(int numberOfRIs, int numberOfRelations, User user)
- throws IOException, Exception {
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncAdminDetails,
- resourceDetailsVF_02);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_SUCCESS,
- getResourceResponse.getErrorCode().intValue());
- // ResourceValidationUtils.validateResp(getResourceResponse,
- // resourceRespJavaObject);
- // int numberOfActualRIs = resource.getComponentInstances()!=null ?
- // resource.getComponentInstances().size() : 0;
- // int numberOfActualRelations =
- // resource.getComponentInstancesRelations()!=null ?
- // resource.getComponentInstancesRelations().size() : 0;
- // assertEquals("Check number of RIs meet the expected number",
- // numberOfRIs ,numberOfActualRIs);
- // assertEquals("Check number of RI relations meet the expected number",
- // numberOfRelations ,numberOfActualRelations);
-
- //// get VF actual Capabilities and Requirements and validate according
- //// to expected
- Resource vfResource = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(),
- Resource.class);
- verifyReqCap(vfResource);
- }
-}
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
deleted file mode 100644
index eabf057715..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java
+++ /dev/null
@@ -1,1294 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.service;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import org.json.JSONObject;
-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.Component;
-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.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.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-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.UserRoleEnum;
-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;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.DbUtils;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-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());
-
- String serviceBaseVersion = "0.1";
-
- @Rule
- public static TestName name = new TestName();
-
- public CreateServiceMetadataApiTest() {
- super(name, CreateServiceMetadataApiTest.class.getName());
- }
-
- @Test
- public void createDefaultService() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // String creator =
- // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN).getUserId();
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", 201, restResponse.getErrorCode().intValue());
-
- // validate create service response vs actual
-
- Service service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails, service, sdncUserDetails,
- (LifecycleStateEnum) null);
-
- // validate get service response vs actual
- restResponse = ServiceRestUtils.getService(serviceDetails, sdncUserDetails);
- service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails, service, sdncUserDetails,
- (LifecycleStateEnum) null);
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus("201");
- expectedResourceAuditJavaObject.setDesc("OK");
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createDefaultServiceUserDesigner() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", 201, restResponse.getErrorCode().intValue());
-
- // validate create service response vs actual
-
- Service service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails, service, sdncUserDetails,
- (LifecycleStateEnum) null);
-
- // validate get service response vs actual
- restResponse = ServiceRestUtils.getService(serviceDetails, sdncUserDetails);
- service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus("201");
- expectedResourceAuditJavaObject.setDesc("OK");
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceUserNotFound() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncUserDetails.setUserId("no1234");
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- sdncUserDetails.setFirstName("");
- sdncUserDetails.setLastName("");
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrVersion("");
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setModifierName("");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceUserNotAllowed() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceEmptyName() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- String serviceName = "";
- serviceDetails.setName(serviceName);
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_COMPONENT_NAME.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList("Service");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_COMPONENT_NAME.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceEmptyCategory() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- String category = "";
-
- serviceDetails.setCategories(null);
- // serviceDetails.addCategory(category);
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_CATEGORY.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList("Service");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceEmptyTag() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ArrayList<String> tags = new ArrayList<String>();
- tags.add("");
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- serviceDetails.setTags(tags);
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_FIELD_FORMAT.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList("Service", "tag");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceEmptyDescription() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- String description = "";
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- serviceDetails.setDescription(description);
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList("Service");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceEmptyTags() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ArrayList<String> tags = new ArrayList<String>();
- tags.add("");
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- serviceDetails.setTags(tags);
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_FIELD_FORMAT.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList("Service", "tag");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceByPutHttpMethod() throws Exception {
-
- String method = "PUT";
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
-
- RestResponse restResponse = ServiceRestUtils.createServiceByHttpMethod(serviceDetails, sdncUserDetails, method,
- Urls.CREATE_SERVICE);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.NOT_ALLOWED.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), variables,
- restResponse.getResponse());
-
- // //validate audit
- //
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // resourceUtils.constructFieldsForAuditValidation(serviceDetails,
- // serviceBaseVersion, sdncUserDetails);
- //
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setAction(auditAction);
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- //
- // String auditDesc =
- // AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- // expectedResourceAuditJavaObject.setDesc(auditDesc);
- //
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction);
-
- }
-
- @Test
- public void createServiceByDeleteHttpMethod() throws Exception {
-
- String method = "DELETE";
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
-
- RestResponse restResponse = ServiceRestUtils.createServiceByHttpMethod(serviceDetails, sdncUserDetails, method,
- Urls.CREATE_SERVICE);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.NOT_ALLOWED.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), variables,
- restResponse.getResponse());
-
- // //validate audit
- //
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // resourceUtils.constructFieldsForAuditValidation(serviceDetails,
- // serviceBaseVersion, sdncUserDetails);
- //
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setAction(auditAction);
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- //
- // String auditDesc =
- // AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- // expectedResourceAuditJavaObject.setDesc(auditDesc);
- //
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction);
-
- }
-
- @Test
- public void createServiceTagLengthExceedLimit() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- StringBuilder tagBuffer = new StringBuilder();
- for (int i = 0; i < 1025; i++) {
- tagBuffer.append("a");
- }
- ArrayList<String> tags = new ArrayList<String>();
- tags.add(tagBuffer.toString());
- serviceDetails.setTags(tags);
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
-
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList("50");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), variables,
- restResponse.getResponse());
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setDesc(errorInfo.getAuditDesc("50"));
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- /*
- * ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- * ServiceValidationUtils.constructFieldsForAuditValidation(
- * serviceDetails, serviceBaseVersion, sdncUserDetails);
- *
- * String auditAction="Create";
- * expectedResourceAuditJavaObject.setAction(auditAction);
- * expectedResourceAuditJavaObject.setPrevState("");
- * expectedResourceAuditJavaObject.setPrevVersion("");
- * expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.
- * NOT_CERTIFIED_CHECKOUT).toString());
- * expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().
- * toString()); expectedResourceAuditJavaObject.setDesc(auditDesc);
- *
- * AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- * auditAction, null);
- */
-
- }
-
- @Test
- public void createServiceAlreadyExistException() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // create service with the same name
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
-
- // validate create service response vs actual
-
- List<String> variables = Arrays.asList("Service", serviceDetails.getName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name(), variables,
- restResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
-
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void createServiceWrongContactId() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- serviceDetails.setContactId("123as");
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_INVALID_CONTACT.name());
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), restResponse.getErrorCode());
- }
-
- @Test
- public void createServiceProjectName() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- serviceDetails.setProjectCode("12345");
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- Integer expectedCode = 201;
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", expectedCode, restResponse.getErrorCode());
- Service service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse());
-
- assertEquals("12345", service.getProjectCode());
- }
-
- @Test
- public void createAndGetByNameAndVersion() throws Exception {
-
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // create
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- assertEquals("Check response code after create service", 201, restResponse.getErrorCode().intValue());
-
- // get
- restResponse = ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails, serviceDetails.getName(),
- serviceBaseVersion);
- assertEquals("Check response code after get service", 200, restResponse.getErrorCode().intValue());
-
- Service service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse());
- String uniqueId = service.getUniqueId();
- serviceDetails.setUniqueId(uniqueId);
- ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails, service, sdncUserDetails,
- (LifecycleStateEnum) null);
- }
-
- //// US553874
-
- @JsonIgnore
- @Test
- public void createServiceIsVNF_isFalse() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after updating Interface Artifact", 201,
- restResponse.getErrorCode().intValue());
-
- // get service and verify that service created with isVNF defined in
- // serviceDetails
- RestResponse serviceByNameAndVersion = ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- serviceDetails.getName(), serviceBaseVersion);
- Service serviceObject = ResponseParser
- .convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails, serviceObject, sdncUserDetails,
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus("201");
- expectedResourceAuditJavaObject.setDesc("OK");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- @JsonIgnore
- @Test
- public void createServiceIsVNF_isTrue() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after updating Interface Artifact", 201,
- restResponse.getErrorCode().intValue());
-
- // get service and verify that service created with isVNF defined in
- // serviceDetails
- RestResponse serviceByNameAndVersion = ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- serviceDetails.getName(), serviceBaseVersion);
- Service serviceObject = ResponseParser
- .convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails, serviceObject, sdncUserDetails,
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus("201");
- expectedResourceAuditJavaObject.setDesc("OK");
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- @JsonIgnore
- @Test(enabled = false)
- public void createServiceIsVNF_isNull() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- // clean audit DB before service creation
- DbUtils.cleanAllAudits();
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- assertNotNull("check response object is not null after create service", restResponse);
- assertEquals("Check response code after updating Interface Artifact", 400,
- restResponse.getErrorCode().intValue());
- List<String> variables = Arrays.asList("VNF Service Indicator");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_DATA.name(), variables,
- restResponse.getResponse());
-
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setDesc(errorInfo.getAuditDesc("VNF Service Indicator"));
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- @JsonIgnore
- @Test(enabled = false)
- public void createServiceEmptyIsVNF() throws Exception {
-
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
-
- DbUtils.cleanAllAudits();
-
- // send create service toward BE
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
-
- assertNotNull("check response object is not null after create service", restResponse);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after create service", restResponse.getErrorCode(),
- restResponse.getErrorCode());
-
- // validate create service response vs actual
- List<String> variables = Arrays.asList("VNF Service Indicator");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_DATA.name(), variables,
- restResponse.getResponse());
-
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, serviceBaseVersion, sdncUserDetails);
-
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- private RestResponse createServiceWithMissingAttribute(String serviceDetails, User sdncModifierDetails)
- throws Exception {
-
- Config config = Utils.getConfig();
-
- Map<String, String> headersMap = ServiceRestUtils.prepareHeadersMap(sdncModifierDetails, false);
- headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), "no-cache");
-
- HttpRequest http = new HttpRequest();
- String url = String.format(Urls.CREATE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort());
- // TODO: ADD AUTHENTICATION IN REQUEST
- logger.debug(url);
- logger.debug("Send POST request to create service: {}", url);
- logger.debug("Service body: {}", serviceDetails);
- logger.debug("Service headers: {}", headersMap);
- RestResponse sendCreateUserRequest = http.httpSendPost(url, serviceDetails, headersMap);
-
- return sendCreateUserRequest;
-
- }
-
- @JsonIgnore
- @Test(enabled = false)
- public void createServiceVersion_isVNFDoesNotExistInJson() throws Exception {
-
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // clean audit DB before updating service
- DbUtils.cleanAllAudits();
-
- // remove isVNF from json sent to create service
- JSONObject jObject = new JSONObject(serviceDetails);
- jObject.remove("VNF");
-
- // send create service toward BE
- RestResponse restResponse = createServiceWithMissingAttribute(jObject.toString(), sdncUserDetails);
- assertNotNull("check error code exists in response after create service", restResponse.getErrorCode());
- assertEquals("Check response code after updating Interface Artifact", 400,
- restResponse.getErrorCode().intValue());
- List<String> variables = new ArrayList<String>();
- variables.add("VNF Service Indicator");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_DATA.name(), variables,
- restResponse.getResponse());
-
- // validate audit
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ServiceValidationUtils
- .constructFieldsForAuditValidation(serviceDetails, "0.1", sdncUserDetails);
- String auditAction = "Create";
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setDesc(errorInfo.getAuditDesc("VNF Service Indicator"));
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void checkInvariantUuidIsImmutable() throws Exception {
- // choose the user to create service
- User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- Component resourceDetailsVFCcomp = AtomicOperationUtils
- .createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.ADMIN, true).left().value();
- AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT, resourceDetailsVFCcomp, UserRoleEnum.ADMIN,
- true, true);
- AtomicOperationUtils.changeComponentState(resourceDetailsVFCcomp, UserRoleEnum.ADMIN,
- LifeCycleStatesEnum.CERTIFY, true);
-
- // fill new service details
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- String invariantUuidDefinedByUser = "!!!!!!!!!!!!!!!!!!!!!!!!";
- serviceDetails.setInvariantUUID(invariantUuidDefinedByUser);
-
- // create service
- RestResponse restResponseCreation = ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- BaseRestUtils.checkStatusCode(restResponseCreation, "create request failed", false, 201);
- Service service = ResponseParser.convertServiceResponseToJavaObject(restResponseCreation.getResponse());
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceDetailsVFCcomp, service,
- UserRoleEnum.ADMIN, true);
-
- String invariantUUIDcreation = service.getInvariantUUID();
-
- // validate get service response vs actual
- RestResponse restResponseGetting = ServiceRestUtils.getService(serviceDetails, sdncUserDetails);
- BaseRestUtils.checkSuccess(restResponseGetting);
- service = ResponseParser.convertServiceResponseToJavaObject(restResponseGetting.getResponse());
- String invariantUUIDgetting = service.getInvariantUUID();
-
- assertEquals(invariantUUIDcreation, invariantUUIDgetting);
-
- // Update service with new invariant UUID
- RestResponse restResponseUpdate = ServiceRestUtils.updateService(serviceDetails, sdncUserDetails);
- BaseRestUtils.checkSuccess(restResponseUpdate);
- Service updatedService = ResponseParser.convertServiceResponseToJavaObject(restResponseUpdate.getResponse());
- String invariantUUIDupdating = updatedService.getInvariantUUID();
- assertEquals(invariantUUIDcreation, invariantUUIDupdating);
-
- // Do checkin
- RestResponse restResponseCheckin = LifecycleRestUtils.changeServiceState(serviceDetails, sdncUserDetails,
- serviceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN);
- BaseRestUtils.checkSuccess(restResponseCheckin);
- Service checkinService = ResponseParser.convertServiceResponseToJavaObject(restResponseCheckin.getResponse());
- String invariantUUIDcheckin = checkinService.getInvariantUUID();
- String version = checkinService.getVersion();
- assertEquals(invariantUUIDcreation, invariantUUIDcheckin);
- assertEquals(version, "0.1");
-
- // Do checkout
- RestResponse restResponseCheckout = LifecycleRestUtils.changeServiceState(serviceDetails, sdncUserDetails,
- serviceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
- BaseRestUtils.checkSuccess(restResponseCheckout);
- Service checkoutService = ResponseParser.convertServiceResponseToJavaObject(restResponseCheckout.getResponse());
- String invariantUUIDcheckout = checkoutService.getInvariantUUID();
- version = checkoutService.getVersion();
- assertEquals(invariantUUIDcreation, invariantUUIDcheckout);
- assertEquals(version, "0.2");
-
- // do certification request
- RestResponse restResponseCertificationRequest = LifecycleRestUtils.changeServiceState(serviceDetails,
- sdncUserDetails, serviceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- BaseRestUtils.checkSuccess(restResponseCertificationRequest);
- Service certificationRequestService = ResponseParser
- .convertServiceResponseToJavaObject(restResponseCertificationRequest.getResponse());
- String invariantUUIDcertificationRequest = certificationRequestService.getInvariantUUID();
- version = certificationRequestService.getVersion();
- assertEquals(invariantUUIDcreation, invariantUUIDcertificationRequest);
- assertEquals(version, "0.2");
-
- // start certification
- RestResponse restResponseStartCertification = LifecycleRestUtils.changeServiceState(serviceDetails,
- sdncUserDetails, serviceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
- BaseRestUtils.checkSuccess(restResponseStartCertification);
- Service startCertificationRequestService = ResponseParser
- .convertServiceResponseToJavaObject(restResponseStartCertification.getResponse());
- String invariantUUIDStartCertification = startCertificationRequestService.getInvariantUUID();
- version = startCertificationRequestService.getVersion();
- assertEquals(invariantUUIDcreation, invariantUUIDStartCertification);
- assertEquals(version, "0.2");
-
- // certify
- RestResponse restResponseCertify = LifecycleRestUtils.changeServiceState(serviceDetails, sdncUserDetails,
- serviceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY);
- BaseRestUtils.checkSuccess(restResponseCertify);
- Service certifyService = ResponseParser.convertServiceResponseToJavaObject(restResponseCertify.getResponse());
- String invariantUUIDcertify = certifyService.getInvariantUUID();
- version = certifyService.getVersion();
- assertEquals(invariantUUIDcreation, invariantUUIDcertify);
- assertEquals(version, "1.0");
-
- }
-
- // US672129 Benny
- private void getServiceValidateInvariantUuid(String serviceUniqueId, String invariantUUIDcreation)
- throws Exception {
- RestResponse getService = ServiceRestUtils.getService(serviceUniqueId,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, getService.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(getService));
- }
-
- @Test // invariantUUID generated when the component is created and never
- // changed
- public void serviceInvariantUuid() throws Exception {
- User designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- User testerUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- User pmUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
- Component resourceDetailsVFCcomp = AtomicOperationUtils
- .createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT, resourceDetailsVFCcomp, UserRoleEnum.DESIGNER,
- true, true);
- AtomicOperationUtils.changeComponentState(resourceDetailsVFCcomp, UserRoleEnum.DESIGNER,
- LifeCycleStatesEnum.CERTIFY, true);
- // create service
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- serviceDetails.setInvariantUUID("123456");
- RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
- assertEquals("Check response code after create resource", BaseRestUtils.STATUS_CODE_CREATED,
- restResponse.getErrorCode().intValue());
- Service service = ResponseParser.parseToObjectUsingMapper(restResponse.getResponse(), Service.class);
- // invariantUUID generated when the component is created and never
- // changed
- String invariantUUIDcreation = ResponseParser.getInvariantUuid(restResponse);
- // Add VF instance to service
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceDetailsVFCcomp, service,
- UserRoleEnum.DESIGNER, true);
- // get resource and verify InvariantUuid is not changed
- getServiceValidateInvariantUuid(service.getUniqueId(), invariantUUIDcreation);
-
- // Update service with new invariant UUID
- restResponse = ServiceRestUtils.updateService(serviceDetails, designerUser);
- assertEquals("Check response code after create resource", BaseRestUtils.STATUS_CODE_SUCCESS,
- restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // Checkin
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser, LifeCycleStatesEnum.CHECKIN);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // Checkout
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser,
- LifeCycleStatesEnum.CHECKOUT);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // certification request
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // start certification
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, testerUser,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // certify
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, testerUser, LifeCycleStatesEnum.CERTIFY);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // update resource
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser,
- LifeCycleStatesEnum.CHECKOUT);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- serviceDetails.setDescription("updatedDescription");
- restResponse = ServiceRestUtils.updateService(serviceDetails, designerUser);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // certification request
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // Checkout
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser,
- LifeCycleStatesEnum.CHECKOUT);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // certification request
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // start certification
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, testerUser,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // cancel certification
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, testerUser,
- LifeCycleStatesEnum.CANCELCERTIFICATION);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // start certification
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, testerUser,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // failure
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, testerUser,
- LifeCycleStatesEnum.FAILCERTIFICATION);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // Checkout
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser,
- LifeCycleStatesEnum.CHECKOUT);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // Checkin
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, designerUser, LifeCycleStatesEnum.CHECKIN);
- assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- // create instance
- ProductReqDetails productDetails = ElementFactory.getDefaultProduct();
- RestResponse createProductResponse = ProductRestUtils.createProduct(productDetails, pmUser);
- assertEquals(BaseRestUtils.STATUS_CODE_CREATED, createProductResponse.getErrorCode().intValue());
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(serviceDetails);
- RestResponse createServiceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- serviceInstanceReqDetails, pmUser, productDetails.getUniqueId(), ComponentTypeEnum.PRODUCT);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_CREATED,
- createServiceInstanceResponse.getErrorCode().intValue());
- getServiceValidateInvariantUuid(serviceDetails.getUniqueId(), invariantUUIDcreation);
-
- }
-
-}
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
deleted file mode 100644
index fc99946b91..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java
+++ /dev/null
@@ -1,672 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.service;
-
-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;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-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.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.*;
-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.*;
-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.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 =
- * 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(), 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);
- }
-
-}
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
deleted file mode 100644
index 6db27b9e4f..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java
+++ /dev/null
@@ -1,1171 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.service;
-
-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.*;
-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.*;
-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.*;
-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
- private ImportReqDetails importReqDetails2;
- private ImportReqDetails importReqDetails3;
- private ImportReqDetails importReqDetails4;
- private Resource resourceVFC1;
- private Resource resourceVFC2;
- private Resource resourceVFC3;
- private Resource resourceVFC4;
- private ResourceReqDetails resourceDetailsVF100;
- private ResourceReqDetails resourceDetailsVF200;
- private Resource resourceVF100;
- private Resource resourceVF200;
- protected String testResourcesPath;
-
- protected final String importYmlWithReq11 = "softwareComponentReq11.yml";
- protected final String importYmlWithReq12 = "softwareComponentReq12.yml";
- protected final String importYmlWithCap11 = "computeCap11.yml";
- protected final String importYmlWithCap1Unbounded = "computeCap1UNBOUNDED.yml";
- protected final String capabilitiesAndRequirementsType = "tosca.capabilities.Container";
-
- public ReqCapOccurrencesTest() {
- super(new TestName(), ReqCapOccurrencesTest.class.getSimpleName());
- }
-
- @BeforeMethod
- public void before() throws Exception {
- // Do not use call init() from ComponentInstanceBaseTest
- expectedContainerCapabilities = new LinkedHashMap<String, List<CapabilityDefinition>>();
- expectedContainerRequirements = new LinkedHashMap<String, List<RequirementDefinition>>();
- removedRequirements = new HashMap<>();
- expectedContInstReqCap = new HashMap<>();
-
- RestResponse importResourceResponse;
- sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // import yml file location
- String sourceDir = config.getResourceConfigDir();
- final String workDir = "importToscaResourceByCreateUrl";
- testResourcesPath = sourceDir + File.separator + workDir;
- ///// Create atomic resources /////////////////////////
- // import VFC1 with Requirements : MIN=1 MAX=2
- ///// (tosca.capabilities.Container)
- importReqDetails1 = ElementFactory.getDefaultImportResource("VFC1");
- importResourceResponse = importedResource(importReqDetails1, importYmlWithReq12);
- // resourceVFC1 =
- // ResponseParser.convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(importReqDetails1, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- resourceVFC1 = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- // import VFC2 with Capabilities : MIN 1 MAX UNBOUNDED
- // (tosca.capabilities.Container)
- importReqDetails2 = ElementFactory.getDefaultImportResource("VFC2");
- importResourceResponse = importedResource(importReqDetails2, importYmlWithCap1Unbounded);
- // resourceVFC2 =
- // ResponseParser.convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- restResponse = LifecycleRestUtils.changeResourceState(importReqDetails2, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- resourceVFC2 = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- // import VFC3 with Capabilities : MIN 1 MAX 1
- // (tosca.capabilities.Container)
- importReqDetails3 = ElementFactory.getDefaultImportResource("VFC3");
- importResourceResponse = importedResource(importReqDetails3, importYmlWithCap11);
- // resourceVFC3 =
- // ResponseParser.convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- restResponse = LifecycleRestUtils.changeResourceState(importReqDetails3, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- resourceVFC3 = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- // import VFC4 with Requirements : MIN 1 MAX 1
- // (tosca.capabilities.Container)
- importReqDetails4 = ElementFactory.getDefaultImportResource("VFC4");
- importResourceResponse = importedResource(importReqDetails4, importYmlWithReq11);
- // resourceVFC4 =
- // ResponseParser.convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- restResponse = LifecycleRestUtils.changeResourceState(importReqDetails4, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- resourceVFC4 = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
-
- // create VF100
- resourceDetailsVF100 = ElementFactory.getDefaultResourceByType("VF1000", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(),
- ResourceTypeEnum.VF.toString());
- RestResponse createResourceVF100 = ResourceRestUtils.createResource(resourceDetailsVF100, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createResourceVF100);
- // create VF200
- resourceDetailsVF200 = ElementFactory.getDefaultResourceByType("VF2000", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(),
- ResourceTypeEnum.VF.toString());
- RestResponse createResourceVF200 = ResourceRestUtils.createResource(resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createResourceVF200);
- // Create Service
- serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY,
- sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
- RestResponse createServiceRestResponse = ServiceRestUtils.createService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createServiceRestResponse);
-
- }
-
- // US628514 Capability/Requirement "Occurrences" attribute in CREATE/DELETE
- // Relation APIs
- // Container = SERVICE , Container instance = VF
- @Test
- public void capAndReqOccurrencesInServiceAndHisInstancesNoAssociation() throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC1 (Req MIN=1 MAX=2) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC21 (Cap MIN=1 MAX=UNBOUNDED) to VF2000
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- RestResponse createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "1";
- String containerMaxReq = "2";
- String containerMinCap = "1";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- }
-
- @Test
- public void serviceInstanceAssociationReqMaxOccurrencesNotReached() throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC1 (Req MIN=1 MAX=2) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC2 (Cap MIN=1 MAX=UNBOUNDED) to VF2000
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- RestResponse createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // associate 2 VFs
- String capType = capabilitiesAndRequirementsType;
- String reqName = "host";
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList, componentInstanceReq.getUniqueId(), componentInstanceCap.getUniqueId());
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- ResourceRestUtils.checkSuccess(associateInstances);
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "1";
- String containerMinCap = "0";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- }
-
- @Test
- public void serviceInstanceAssociationReqMaxOccurrencesIsReached() throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC4 (Req MIN=1 MAX=1) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails4, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC2 (Cap MIN=1 MAX=UNBOUNDED) to VF2000
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- RestResponse createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // associate 2 VFs
- String capType = capabilitiesAndRequirementsType;
- String reqName = "host";
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList, componentInstanceReq.getUniqueId(), componentInstanceCap.getUniqueId());
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- ResourceRestUtils.checkSuccess(associateInstances);
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "0";
- String containerMinCap = "0";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- }
-
- @Test
- public void associateServiceInstanceWhenReqMaxOccurrencesAlreadyReached() throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC4 (Req MIN=1 MAX=1) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails4, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC2 (Cap MIN=1 MAX=UNBOUNDED) to VF2.00
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- RestResponse createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String vf1Name = ResponseParser.getValueFromJsonResponse(createVFInstResp.getResponse(), "name");
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String vf2Name = ResponseParser.getValueFromJsonResponse(createVFInstResp.getResponse(), "name");
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // associate 2 VFs
- String capType = capabilitiesAndRequirementsType;
- String reqName = "host";
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList, componentInstanceReq.getUniqueId(), componentInstanceCap.getUniqueId());
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- ResourceRestUtils.checkSuccess(associateInstances);
- // associate same instances again - when requirement Max Occurrences
- // reached
- associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, sdncDesignerDetails,
- serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_NOT_FOUND,
- associateInstances.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(vf1Name);
- varibales.add(vf2Name);
- varibales.add("host");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND.name(), varibales,
- associateInstances.getResponse());
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "0";
- String containerMinCap = "0";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- }
-
- @Test
- public void serviceInstanceAssociationCapMaxOccurrencesIsReached() throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC1 (Req MIN=1 MAX=2) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC3 (Cap MIN=1 MAX=1) to VF2000
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails3, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- RestResponse createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // associate 2 VFs
- String capType = capabilitiesAndRequirementsType;
- String reqName = "host";
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList, componentInstanceReq.getUniqueId(), componentInstanceCap.getUniqueId());
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- ResourceRestUtils.checkSuccess(associateInstances);
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "1";
- String containerMinCap = "0";
- String containerMaxCap = "0";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- }
-
- @Test
- public void associationServiceInstanceWhenCapMaxOccurrencesAlreadyReached() throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC1 (Req MIN=1 MAX=2) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC3 (Cap MIN=1 MAX=1) to VF2000
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails3, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- RestResponse createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- sdncDesignerDetails);
- // RestResponse createVFInstResp = createVFInstance(serviceDetails_01,
- // resourceDetailsVF100, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String vf1Name = ResponseParser.getValueFromJsonResponse(createVFInstResp.getResponse(), "name");
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- // createVFInstResp = createVFInstance(serviceDetails_01,
- // resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String vf2Name = ResponseParser.getValueFromJsonResponse(createVFInstResp.getResponse(), "name");
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // associate 2 VFs
- String capType = capabilitiesAndRequirementsType;
- String reqName = "host";
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList, componentInstanceReq.getUniqueId(), componentInstanceCap.getUniqueId());
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- ResourceRestUtils.checkSuccess(associateInstances);
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "1";
- String containerMinCap = "0";
- String containerMaxCap = "0";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- // associate same instances again - when requirement Max Occurrences
- // reached
- associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, sdncDesignerDetails,
- serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_NOT_FOUND,
- associateInstances.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(vf1Name);
- varibales.add(vf2Name);
- varibales.add("host");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND.name(),
- varibales, associateInstances.getResponse());
- }
-
- @Test
- public void associationAndDisassociateServiceInstancesWhenReqMaxOccurrencesAlreadyReached()
- throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC4 (Req MIN=1 MAX=1) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails4, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC3 (Cap MIN=1 MAX=1) to VF2000
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails3, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- RestResponse createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- sdncDesignerDetails);
- // RestResponse createVFInstResp = createVFInstance(serviceDetails_01,
- // resourceDetailsVF100, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- // createVFInstResp = createVFInstance(serviceDetails_01,
- // resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // associate 2 VF Instances
- String capType = capabilitiesAndRequirementsType;
- String reqName = "host";
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList, componentInstanceReq.getUniqueId(), componentInstanceCap.getUniqueId());
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- ResourceRestUtils.checkSuccess(associateInstances);
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "0";
- String containerMinCap = "0";
- String containerMaxCap = "0";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- // Disassociate 2 VF Instances
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS,
- dissociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF100.getUniqueId()).isEmpty());
- // get service and verify Occurrences in container and container
- // instance requirements and Capabilities
- getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- containerMinReq = "1";
- containerMaxReq = "1";
- containerMinCap = "1";
- containerMaxCap = "1";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- }
-
- @Test(enabled = false)
- public void aaaa() throws Exception, Exception {
- RestResponse getResourseRestResponse;
- // Add instance of VFC1 (Req MIN=1 MAX=2) to VF1000
- ComponentInstance componentInstanceReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceReq);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Add instance of VFC3 (Cap MIN=1 MAX=1) to VF2000
- ComponentInstance componentInstanceCap = createComponentInstance(importReqDetails3, sdncDesignerDetails,
- resourceDetailsVF200);
- assertNotNull(componentInstanceCap);
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF200.getUniqueId());
- resourceVF200 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Check-In both VFs
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF100, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF200, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create VF instances
- // RestResponse createVFInstResp =
- // createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF100,
- // sdncDesignerDetails);
- RestResponse createVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF100, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String vf1Name = ResponseParser.getValueFromJsonResponse(createVFInstResp.getResponse(), "name");
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // createVFInstResp = createVFInstanceDuringSetup(serviceDetails_01,
- // resourceDetailsVF200, sdncDesignerDetails);
- createVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF200, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String vf2Name = ResponseParser.getValueFromJsonResponse(createVFInstResp.getResponse(), "name");
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // associate 2 VFs
- String capType = capabilitiesAndRequirementsType;
- String reqName = "host";
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList, componentInstanceReq.getUniqueId(), componentInstanceCap.getUniqueId());
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- ResourceRestUtils.checkSuccess(associateInstances);
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
- // get service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkSuccess(getServiceResponse);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "1";
- String containerMinCap = "0";
- String containerMaxCap = "0";
- verifyContainerCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType, containerMinReq,
- containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(service, capabilitiesAndRequirementsType,
- resourceVF200, resourceVF100);
- // associate same instances again - when requirement Max Occurrences
- // reached
- associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, sdncDesignerDetails,
- serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_NOT_FOUND,
- associateInstances.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(vf1Name);
- varibales.add(vf2Name);
- varibales.add("host");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND.name(),
- varibales, associateInstances.getResponse());
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////
- // US628514 Capability/Requirement "Occurrences" attribute in CREATE/DELETE
- ////////////////////////////////////////////////////////////////////////////////////////////////// Relation
- ////////////////////////////////////////////////////////////////////////////////////////////////// APIs
- // Container = VF , Container instance = VFC
- @Test
- public void capAndReqOccurrencesInVfAndHisInstancesNoAssociation() throws Exception, Exception {
- // Add VFC1 and VFC2 instances in VF
- ComponentInstance createComponentInstance1 = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(createComponentInstance1);
- ComponentInstance createComponentInstance2 = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(createComponentInstance2);
- // GET resource
- RestResponse getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "1";
- String containerMaxReq = "2";
- String containerMinCap = "1";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC2, resourceVFC1);
- }
-
- @Test
- public void vfInstanceAssociationReqMaxOccurrencesNotReached() throws Exception, Exception {
- // Add VFC1 (with Requirements: tosca.capabilities.Container, MIN=1
- // MAX=2) instance to VF
- ComponentInstance componentInstanceWithReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithReq);
- // Add VFC2 (with Capabilities: tosca.capabilities.Container, MIN=1,
- // MAX=UNBOUNDED ) instance to VF
- ComponentInstance componentInstanceWithCap = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithCap);
- // associate Instances
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap(resourceDetailsVF100);
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(componentInstanceWithReq,
- componentInstanceWithCap, capReqDefBeforeAssociate);
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF100.getUniqueId()));
- // GET resource
- RestResponse getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "1";
- String containerMinCap = "0";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC2, resourceVFC1);
-
- }
-
- @Test
- public void vfInstanceAssociationReqMaxOccurrencesIsReached() throws Exception, Exception {
- // Add VFC4 (with Requirements: tosca.capabilities.Container, MIN=1
- // MAX=1) instance to VF
- ComponentInstance componentInstanceWithReq = createComponentInstance(importReqDetails4, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithReq);
- // Add VFC2 (with Capabilities: tosca.capabilities.Container, MIN=1,
- // MAX=UNBOUNDED ) instance to VF
- ComponentInstance componentInstanceWithCap = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithCap);
- // associate Instances
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap(resourceDetailsVF100);
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(componentInstanceWithReq,
- componentInstanceWithCap, capReqDefBeforeAssociate);
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF100.getUniqueId()));
- // GET resource
- RestResponse getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "0";
- String containerMinCap = "0";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC2, resourceVFC4);
- }
-
- @Test
- public void associateVfInstanceWhenReqMaxOccurrencesAlreadyReached() throws Exception, Exception {
- // Add VFC4 (with Requirements: tosca.capabilities.Container, MIN=1
- // MAX=1) instance to VF
- ComponentInstance componentInstanceWithReq = createComponentInstance(importReqDetails4, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithReq);
- // Add VFC2 (with Capabilities: tosca.capabilities.Container, MIN=1,
- // MAX=UNBOUNDED ) instance to VF
- ComponentInstance componentInstanceWithCap = createComponentInstance(importReqDetails2, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithCap);
- // associate Instances
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap(resourceDetailsVF100);
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(componentInstanceWithReq,
- componentInstanceWithCap, capReqDefBeforeAssociate);
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF100.getUniqueId()));
- // GET resource
- RestResponse getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "0";
- String containerMinCap = "0";
- String containerMaxCap = "UNBOUNDED";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC2, resourceVFC4);
- // associate same instances again - when requirement Max Occurrences
- // reached
- associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_NOT_FOUND,
- associateInstances.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(componentInstanceWithReq.getName());
- varibales.add(componentInstanceWithCap.getName());
- varibales.add("host");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND.name(), varibales,
- associateInstances.getResponse());
-
- }
-
- @Test
- public void vfInstanceAssociationCapMaxOccurrencesIsReached() throws Exception, Exception {
- // Add VFC1 (with Requirements: tosca.capabilities.Container, MIN=1
- // MAX=2) instance to VF
- ComponentInstance componentInstanceWithReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithReq);
- // Add VFC3 (with Capabilities: tosca.capabilities.Container, MIN=1
- // MAX=1 ) instance to VF
- ComponentInstance componentInstanceWithCap = createComponentInstance(importReqDetails3, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithCap);
- // associate Instances
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap(resourceDetailsVF100);
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(componentInstanceWithReq,
- componentInstanceWithCap, capReqDefBeforeAssociate);
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF100.getUniqueId()));
- // GET resource
- RestResponse getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "1";
- String containerMinCap = "0";
- String containerMaxCap = "0";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC3, resourceVFC1);
- }
-
- @Test
- public void associationVfInstanceWhenCapMaxOccurrencesAlreadyReached() throws Exception, Exception {
- // Add VFC1 (with Requirements: tosca.capabilities.Container, MIN=1
- // MAX=2) instance to VF
- ComponentInstance componentInstanceWithReq = createComponentInstance(importReqDetails1, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithReq);
- // Add VFC3 (with Capabilities: tosca.capabilities.Container, MIN=1
- // MAX=1 ) instance to VF
- ComponentInstance componentInstanceWithCap = createComponentInstance(importReqDetails3, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithCap);
- // associate Instances
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap(resourceDetailsVF100);
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(componentInstanceWithReq,
- componentInstanceWithCap, capReqDefBeforeAssociate);
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", STATUS_CODE_SUCCESS, associateInstances.getErrorCode().intValue());
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF100.getUniqueId()));
- // GET resource
- RestResponse getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "1";
- String containerMinCap = "0";
- String containerMaxCap = "0";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC3, resourceVFC1);
- // associate same instances again - when requirement Max Occurrences
- // reached
- associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_NOT_FOUND,
- associateInstances.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(componentInstanceWithReq.getName());
- varibales.add(componentInstanceWithCap.getName());
- varibales.add("host");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND.name(),
- varibales, associateInstances.getResponse());
- }
-
- @Test
- public void associationAndDisassociateVfInstancesWhenReqMaxOccurrencesAlreadyReached() throws Exception, Exception {
- // Add VFC4 (with Requirements: tosca.capabilities.Container, MIN=1
- // MAX=1) instance to VF
- ComponentInstance componentInstanceWithReq = createComponentInstance(importReqDetails4, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithReq);
- // Add VFC3 (with Capabilities: tosca.capabilities.Container, MIN=1
- // MAX=1 ) instance to VF
- ComponentInstance componentInstanceWithCap = createComponentInstance(importReqDetails3, sdncDesignerDetails,
- resourceDetailsVF100);
- assertNotNull(componentInstanceWithCap);
- // associate Instances
- CapReqDef capReqDefBeforeAssociate = getResourceReqCap(resourceDetailsVF100);
- RequirementCapabilityRelDef requirementDef = setRelationshipBetweenInstances(componentInstanceWithReq,
- componentInstanceWithCap, capReqDefBeforeAssociate);
- RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- ResourceRestUtils.checkSuccess(associateInstances);
- assertTrue(checkRealtionship(requirementDef.getFromNode(), requirementDef.getToNode(),
- resourceDetailsVF100.getUniqueId()));
- // GET resource
- RestResponse getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- String containerMinReq = "0";
- String containerMaxReq = "0";
- String containerMinCap = "0";
- String containerMaxCap = "0";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC3, resourceVFC4);
- // Disassociate 2 Instances
- RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef,
- sdncDesignerDetails, resourceDetailsVF100.getUniqueId(), ComponentTypeEnum.RESOURCE);
- assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS,
- dissociateInstances.getErrorCode().intValue());
- assertTrue(getComponentInstancesRelations(resourceDetailsVF100.getUniqueId()).isEmpty());
- // GET resource
- getResourseRestResponse = ResourceRestUtils.getResource(sdncDesignerDetails,
- resourceDetailsVF100.getUniqueId());
- resourceVF100 = ResponseParser.parseToObjectUsingMapper(getResourseRestResponse.getResponse(), Resource.class);
- // Verify Container requirements and Capabilities
- containerMinReq = "1";
- containerMaxReq = "1";
- containerMinCap = "1";
- containerMaxCap = "1";
- verifyContainerCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- containerMinReq, containerMaxReq, containerMinCap, containerMaxCap);
- verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(resourceVF100, capabilitiesAndRequirementsType,
- resourceVFC3, resourceVFC4);
- }
-
- ///////////////////////////////////////
-
- private boolean checkRealtionship(String fromNode, String toNode, String resourceUniqueId) throws Exception {
- List<RequirementCapabilityRelDef> componentInstancesRelations = getComponentInstancesRelations(
- resourceUniqueId);
- RequirementCapabilityRelDef requirementCapabilityRelDef = componentInstancesRelations.get(0);
- boolean fromNodeCheck = requirementCapabilityRelDef.getFromNode().equals(fromNode);
- boolean toNodeCheck = requirementCapabilityRelDef.getToNode().equals(toNode);
-
- return fromNodeCheck && toNodeCheck;
- }
-
- private List<RequirementCapabilityRelDef> getComponentInstancesRelations(String resourceUniqueId)
- throws ClientProtocolException, IOException {
- Resource resource = getVfAsResourceObject(resourceUniqueId);
- List<RequirementCapabilityRelDef> componenRelationInstances = resource.getComponentInstancesRelations();
-
- return componenRelationInstances;
- }
-
- private Resource getVfAsResourceObject(String resourceUniqueId) throws ClientProtocolException, IOException {
- RestResponse getResource = ResourceRestUtils.getResource(resourceUniqueId);
- Resource resource = ResponseParser.parseToObjectUsingMapper(getResource.getResponse(), Resource.class);
- return resource;
- }
-
- private RequirementCapabilityRelDef setRelationshipBetweenInstances(ComponentInstance riReq,
- ComponentInstance riCap, CapReqDef capReqDef) throws Exception {
-
- String capbilityUid = capReqDef.getCapabilities().get("tosca.capabilities.Container").get(0).getUniqueId();
- String requirementUid = capReqDef.getRequirements().get("tosca.capabilities.Container").get(0).getUniqueId();
-
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- requirementDef.setFromNode(riReq.getUniqueId());
- requirementDef.setToNode(riCap.getUniqueId());
-
- RelationshipInfo pair = new RelationshipInfo();
- pair.setRequirementOwnerId(riReq.getUniqueId());
- pair.setCapabilityOwnerId(riCap.getUniqueId());
- pair.setRequirement("host");
- RelationshipImpl relationship = new RelationshipImpl();
- relationship.setType("tosca.capabilities.Container");
- pair.setRelationships(relationship);
- pair.setCapabilityUid(capbilityUid);
- pair.setRequirementUid(requirementUid);
- List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
- CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
- relationships.add(capReqRel);
- capReqRel.setRelation(pair);
- requirementDef.setRelationships(relationships);
- return requirementDef;
- }
-
- private CapReqDef getResourceReqCap(ResourceReqDetails res) throws IOException {
- RestResponse getResourceBeforeAssociate = ComponentRestUtils
- .getComponentRequirmentsCapabilities(sdncDesignerDetails, resourceDetailsVF100);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceBeforeAssociate.getResponse(), CapReqDef.class);
- return capReqDef;
- }
-
- private RestResponse importedResource(ImportReqDetails importReqDetails, String ymlFile) throws Exception {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, testResourcesPath,
- ymlFile);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails,
- sdncDesignerDetails, null);
- assertEquals("Check response code after importing resource", BaseRestUtils.STATUS_CODE_CREATED,
- importResourceResponse.getErrorCode().intValue());
- return importResourceResponse;
- }
-
- private ComponentInstance createComponentInstance(ResourceReqDetails res, User user, ResourceReqDetails vf)
- throws Exception {
- RestResponse response = ResourceRestUtils.createResourceInstance(res, user, vf.getUniqueId());
- ResourceRestUtils.checkCreateResponse(response);
- ComponentInstance compInstance = ResponseParser.parseToObject(response.getResponse(), ComponentInstance.class);
- return compInstance;
- }
-
- private void verifyContainerCapabilitiesAndRequirementsOccurrences(Component component,
- String CapabilitiesAndRequirementsType, String minReqOccurrences, String maxReqOccurrences,
- String minCapabilities, String maxCapabilities) throws Exception {
- boolean isRequirementAppear = false;
- boolean isCapabilityAppear = false;
- List<RequirementDefinition> requirements;
- List<CapabilityDefinition> capabilities;
- requirements = component.getRequirements().get(CapabilitiesAndRequirementsType);
- if (maxReqOccurrences == "0") {
- assertTrue(requirements == null);
- } // if container MAX requirement = 0
- if (maxReqOccurrences != "0") {
- assertNotNull(requirements);
- for (RequirementDefinition req : requirements) {
- switch (req.getName()) {
- case "host":
- assertTrue("Check Min Requirement Occurrences ", req.getMinOccurrences().equals(minReqOccurrences));
- assertTrue("Check Max Requirement Occurrences ", req.getMaxOccurrences().equals(maxReqOccurrences));
- isRequirementAppear = true;
- break;
- }
- assertTrue(isRequirementAppear);
- isRequirementAppear = false;
- }
- }
- // Container Capabilities
- capabilities = component.getCapabilities().get(CapabilitiesAndRequirementsType);
- if (maxCapabilities == "0") {// if container MAX capabilities = 0
- assertTrue(capabilities == null);
- }
- if (maxCapabilities != "0") {
- assertNotNull(capabilities);
- for (CapabilityDefinition cap : capabilities) {
- switch (cap.getName()) {
- case "host":
- assertTrue("Check Min capability Occurrences ", cap.getMinOccurrences().equals(minCapabilities));
- assertTrue("Check Max capability Occurrences ", cap.getMaxOccurrences().equals(maxCapabilities));
- isCapabilityAppear = true;
- break;
- }
- assertTrue(isCapabilityAppear);
- isCapabilityAppear = false;
- }
- }
-
- }
-
- private void verifyContainerInstanceCapabilitiesAndRequirementsOccurrences(Component component,
- String CapabilitiesAndRequirementsType, Resource vfWithCapabilities, Resource vfWithRequirements)
- throws Exception {
- boolean isCapReqAppear = false;
- List<ComponentInstance> listOfComponentInstances = component.getComponentInstances();
-
- for (ComponentInstance instance : listOfComponentInstances) {
- if (instance.getComponentUid().equals(vfWithCapabilities.getUniqueId())) {
- List<CapabilityDefinition> capFromResource = vfWithCapabilities.getCapabilities()
- .get(CapabilitiesAndRequirementsType);
- List<CapabilityDefinition> capFromInstance = instance.getCapabilities()
- .get(CapabilitiesAndRequirementsType);
- for (CapabilityDefinition resourceCap : capFromResource)
- for (CapabilityDefinition instanceReq : capFromInstance) {
- if (resourceCap.getUniqueId().equals(instanceReq.getUniqueId())) {
- assertTrue("Check Min capability Occurrences ",
- resourceCap.getMinOccurrences().equals(instanceReq.getMinOccurrences()));
- assertTrue("Check Max capability Occurrences ",
- resourceCap.getMaxOccurrences().equals(instanceReq.getMaxOccurrences()));
- isCapReqAppear = true;
- break;
- }
-
- }
- }
-
- if (instance.getComponentUid().equals(vfWithRequirements.getUniqueId())) {
- List<RequirementDefinition> reqFromAtomicResource = vfWithRequirements.getRequirements()
- .get(CapabilitiesAndRequirementsType);
- List<RequirementDefinition> reqFromInstance = instance.getRequirements()
- .get(CapabilitiesAndRequirementsType);
- for (RequirementDefinition resourceReq : reqFromAtomicResource)
- for (RequirementDefinition instanceReq : reqFromInstance) {
- if (resourceReq.getUniqueId().equals(instanceReq.getUniqueId())) {
- assertTrue("Check Min Requirement Occurrences ",
- resourceReq.getMinOccurrences().equals(instanceReq.getMinOccurrences()));
- assertTrue("Check Max Requirement Occurrences ",
- resourceReq.getMaxOccurrences().equals(instanceReq.getMaxOccurrences()));
- isCapReqAppear = true;
- break;
- }
- }
- }
- assertTrue(isCapReqAppear);
- isCapReqAppear = false;
- }
-
- }
-
- private RequirementCapabilityRelDef getReqCapRelation(String reqCompInstId, String capCompInstId, String capType,
- String reqName, List<CapabilityDefinition> capList, List<RequirementDefinition> reqList,
- String vfc1UniqueId, String vfc2UniqueId) {
- return ElementFactory.getReqCapRelation(reqCompInstId, capCompInstId, vfc1UniqueId, vfc2UniqueId, capType,
- reqName, capList, reqList);
- }
-
-}
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
deleted file mode 100644
index 60ca71d676..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java
+++ /dev/null
@@ -1,1608 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.service;
-
-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.*;
-import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
-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.*;
-import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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 = " ";
- private static String REQUIREMENT_NAME = "host";
- private static String CAPABILITY_TYPE = "tosca.capabilities.Container";
-
- private String reqOwnerId;
- private String capOwnerId;
-
- public ServiceComponentInstanceCRUDTest() {
- super(new TestName(), ServiceComponentInstanceCRUDTest.class.getSimpleName());
- }
-
- @BeforeMethod(alwaysRun = true)
- public void before() throws Exception {
- init();
- createComponents();
- }
-
- private void createComponents() throws Exception {
- createAtomicResource(resourceDetailsVFC_01);
- createAtomicResource(resourceDetailsVFC_02);
- createAtomicResource(resourceDetailsCP_01);
- createAtomicResource(resourceDetailsVL_01);
- createAtomicResource(resourceDetailsVL_02);
- createVF(resourceDetailsVF_01);
- createVF(resourceDetailsVF_02);
- createService(serviceDetails_01);
- certifyResource(resourceDetailsVFC_01);
- certifyResource(resourceDetailsVFC_02);
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_01,
- resourceDetailsVFC_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- reqOwnerId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVFC_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- capOwnerId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);// should
- // be
- // updated
- // to
- // getUniqueIdOfFirstInstance
- // in
- // service
- // context
- }
-
- private void certifyResource(ResourceReqDetails resource) throws Exception {
- /*changeResourceLifecycleState(resource, sdncDesignerDetails.getUserId(),
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.STARTCERTIFICATION);*/
- changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.CERTIFY);
- }
-
- private void changeResourceLifecycleState(ResourceReqDetails resourceDetails, String userUserId,
- LifeCycleStatesEnum lifeCycleStates) throws Exception {
- RestResponse response = LifecycleRestUtils.changeResourceState(resourceDetails, userUserId, lifeCycleStates);
- LifecycleRestUtils.checkLCS_Response(response);
- }
-
- private void changeServiceLifecycleState(ServiceReqDetails serviceDetails, User user,
- LifeCycleStatesEnum lifeCycleStates) throws Exception {
- RestResponse response = LifecycleRestUtils.changeServiceState(serviceDetails, user, lifeCycleStates);
- LifecycleRestUtils.checkLCS_Response(response);
- }
-
- private void createVFInstanceFailWithoutChangeState(ActionStatus actionStatus, List<String> variables,
- ResourceReqDetails vfResource, User user, int errorCode) throws Exception {
- RestResponse createVFInstanceSuccessfullyWithoutChangeStateResp = createVFInstance(serviceDetails_01,
- vfResource, user);
- checkErrorMessage(actionStatus, variables, errorCode, createVFInstanceSuccessfullyWithoutChangeStateResp);
- }
-
- private void createVFInstanceFail(ActionStatus actionStatus, List<String> variables, ResourceReqDetails vfResource,
- User user, int errorCode) throws Exception, FileNotFoundException, JSONException {
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, vfResource, user);
- checkErrorMessage(actionStatus, variables, errorCode, createVFInstResp);
- }
-
- private void deleteVFInstanceFail(ActionStatus actionStatus, List<String> variables, ResourceReqDetails vfResource,
- User user, int errorCode) throws Exception, FileNotFoundException, JSONException {
- RestResponse deleteVFInstResp = deleteVFInstance(vfResource.getUniqueId(), serviceDetails_01, user);
- checkErrorMessage(actionStatus, variables, errorCode, deleteVFInstResp);
- }
-
- private void createAtomicResourceInstanceFailWithoutChangeState(ActionStatus actionStatus, List<String> variables,
- ResourceReqDetails atomicResource, User user, int errorCode)
- throws Exception, FileNotFoundException, JSONException {
- RestResponse createAtomicInstResp = createAtomicInstanceForService(serviceDetails_01, atomicResource, user);
- checkErrorMessage(actionStatus, variables, errorCode, createAtomicInstResp);
- }
-
- private void createAtomicResourceInstanceFail(ActionStatus actionStatus, List<String> variables,
- ResourceReqDetails atomicResource, User user, int errorCode)
- throws Exception, FileNotFoundException, JSONException {
- RestResponse createAtomicInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, atomicResource,
- user);
- checkErrorMessage(actionStatus, variables, errorCode, createAtomicInstResp);
- }
-
- private void deleteAtomicResourceInstanceFail(ActionStatus actionStatus, List<String> variables,
- ResourceReqDetails atomicResource, User user, int errorCode)
- throws Exception, FileNotFoundException, JSONException {
- RestResponse deleteAtomicInstResp = deleteAtomicInstanceForService(atomicResource.getUniqueId(),
- serviceDetails_01, user);
- checkErrorMessage(actionStatus, variables, errorCode, deleteAtomicInstResp);
- }
-
- private void checkErrorMessage(ActionStatus actionStatus, List<String> variables, int errorCode,
- RestResponse response) throws Exception {
-
- log.debug(response.getResponse());
- AssertJUnit.assertEquals(errorCode, response.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(actionStatus.name(), variables, response.getResponse());
- }
-
- private RestResponse createCheckedinVFInstance(ServiceReqDetails containerDetails,
- ResourceReqDetails compInstOriginDetails, User modifier) throws Exception {
- changeResourceLifecycleState(compInstOriginDetails, compInstOriginDetails.getCreatorUserId(),
- LifeCycleStatesEnum.CHECKIN);
- return createVFInstance(containerDetails, compInstOriginDetails, modifier);
- }
-
- private RestResponse createCheckedinAtomicInstanceForService(ServiceReqDetails containerDetails,
- ResourceReqDetails compInstOriginDetails, User modifier) throws Exception {
- changeResourceLifecycleState(compInstOriginDetails, compInstOriginDetails.getCreatorUserId(),
- LifeCycleStatesEnum.CHECKIN);
- return createAtomicInstanceForService(containerDetails, compInstOriginDetails, modifier);
- }
-
- private void createVFInstanceAndAtomicResourceInstanceWithoutCheckin(ResourceReqDetails vf,
- ResourceReqDetails atomicResource, User user) throws Exception {
- RestResponse createVFInstance = createVFInstance(serviceDetails_01, vf, user);
- ResourceRestUtils.checkCreateResponse(createVFInstance);
- RestResponse atomicInstanceForService = createAtomicInstanceForService(serviceDetails_01, atomicResource, user);
- ResourceRestUtils.checkCreateResponse(atomicInstanceForService);
- }
-
- private void createVFInstanceAndAtomicResourceInstanceSuccessully(ResourceReqDetails vf,
- ResourceReqDetails atomicResource) throws Exception, IOException {
- createVFInstanceAndAtomicResourceInstanceSuccessully(vf, atomicResource, sdncDesignerDetails);
- }
-
- private void createVFInstanceAndAtomicResourceInstanceSuccessully(ResourceReqDetails vf,
- ResourceReqDetails atomicResource, User user) throws Exception, IOException {
- changeResourceLifecycleState(vf, vf.getCreatorUserId(), LifeCycleStatesEnum.CHECKIN);
- changeResourceLifecycleState(atomicResource, atomicResource.getCreatorUserId(), LifeCycleStatesEnum.CHECKIN);
- createVFInstanceAndAtomicResourceInstanceWithoutCheckin(vf, atomicResource, user);
- }
-
- @Test
- public void createVFInstanceSuccessfullyTest() throws Exception {
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void createVFAndAtomicInstanceTest() throws Exception {
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsVL_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsVL_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- getComponentAndValidateRIs(serviceDetails_01, 4, 0);
- }
-
- @Test
- public void deleteAtomicInstanceTest() throws Exception {
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- // 1 rel
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- // 2 rel
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsVL_01,
- sdncDesignerDetails);
- // 3 rel
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsVL_02,
- sdncDesignerDetails);
- // 4 rel
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- // To delete
- String compInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // 3 rel
- createVFInstResp = deleteAtomicInstanceForService(compInstId, serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkDeleteResponse(createVFInstResp);
- getComponentAndValidateRIs(serviceDetails_01, 3, 0);
- }
-
- @Test
- public void deleteVFInstanceTest() throws Exception {
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- // 1 rel
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02, sdncDesignerDetails);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- // 2 rel
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- createVFInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- // 3 rel
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- // 2 rel
- createVFInstResp = deleteVFInstance(compInstId, serviceDetails_01, sdncDesignerDetails);
- ResourceRestUtils.checkDeleteResponse(createVFInstResp);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void associateDissociateTwoVFs() throws Exception {
-
- RestResponse createVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_02, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
-
- String capType = CAPABILITY_TYPE;
- String reqName = REQUIREMENT_NAME;
-
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName,
- capList, reqList);
-
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<RequirementDefinition> list = capReqDef.getRequirements().get(capType);
- AssertJUnit.assertEquals("Check requirement", null, list);
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
-
- dissociateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- list = capReqDef.getRequirements().get(capType);
- AssertJUnit.assertEquals("Check requirement", 1, list.size());
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- private RequirementCapabilityRelDef getReqCapRelation(String reqCompInstId, String capCompInstId, String capType,
- String reqName, List<CapabilityDefinition> capList, List<RequirementDefinition> reqList) {
- return ElementFactory.getReqCapRelation(reqCompInstId, capCompInstId, reqOwnerId, capOwnerId, capType, reqName,
- capList, reqList);
- }
-
- @Test
- public void createResourceInstanceByDifferentDesignerTest() throws Exception {
- createVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2), 409);
- createAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2), 409);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- @Test
- public void createResourceInstanceByDifferentDesignerTest_ServiceIsCheckedin() throws Exception {
- User designer2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2);
-
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- changeServiceLifecycleState(serviceDetails_01, designer2, LifeCycleStatesEnum.CHECKOUT);
-
- createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01, designer2);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
-
- }
-
- @Test
- public void createResourceInstanceByTester() throws Exception {
- createVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), 409);
- createAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), 409);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- @Test
- public void createResourceInstanceWithNotASDCUserTest() throws Exception {
- sdncDesignerDetails.setUserId("ab0001");
- createVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- sdncDesignerDetails, 409);
- createAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, sdncDesignerDetails, 409);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- @Test
- public void createResourceInstanceWithEmptyUserIdTest() throws Exception {
- sdncDesignerDetails.setUserId("");
- createVFInstanceFail(ActionStatus.MISSING_INFORMATION, new ArrayList<String>(), resourceDetailsVF_01,
- sdncDesignerDetails, 403);
- createAtomicResourceInstanceFail(ActionStatus.MISSING_INFORMATION, new ArrayList<String>(),
- resourceDetailsCP_01, sdncDesignerDetails, 403);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- @Test
- public void createResourceInstanceWithEmptyServiceUidTest() throws Exception {
- serviceDetails_01.setUniqueId("");
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- assertEquals(404, createVFInstResp.getErrorCode().intValue());
- RestResponse createAtomicInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01,
- resourceDetailsCP_01, sdncDesignerDetails);
- assertEquals(404, createAtomicInstResp.getErrorCode().intValue());
- }
-
- @Test
- public void createResourceInstanceWhileResourceNotExistTest() throws Exception {
- String vfResourceUniqueId = "1234";
- String atomicResourceUniqueId = "5678";
-
- resourceDetailsVF_01.setUniqueId(vfResourceUniqueId);
- resourceDetailsCP_01.setUniqueId(atomicResourceUniqueId);
-
- createVFInstanceFailWithoutChangeState(ActionStatus.RESOURCE_NOT_FOUND,
- new ArrayList<String>(Arrays.asList("")), resourceDetailsVF_01, sdncDesignerDetails, 404);
- createAtomicResourceInstanceFailWithoutChangeState(ActionStatus.RESOURCE_NOT_FOUND,
- new ArrayList<String>(Arrays.asList("")), resourceDetailsCP_01, sdncDesignerDetails, 404);
- }
-
- @Test
- public void createResourceInstanceInServiceNotExistsTest() throws Exception {
- serviceDetails_01.setUniqueId("1234");
- createVFInstanceFail(ActionStatus.SERVICE_NOT_FOUND, new ArrayList<String>(Arrays.asList("")),
- resourceDetailsVF_01, sdncDesignerDetails, 404);
- createAtomicResourceInstanceFail(ActionStatus.SERVICE_NOT_FOUND, new ArrayList<String>(Arrays.asList("")),
- resourceDetailsCP_01, sdncDesignerDetails, 404);
- }
-
- @Test
- public void createResourceInstanceInCheckedinServiceTest() throws Exception {
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
-
- createVFInstanceFailWithoutChangeState(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsVF_01, sdncDesignerDetails, 409);
- createAtomicResourceInstanceFailWithoutChangeState(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, sdncDesignerDetails, 409);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- @Test(enabled = false)
- public void createResourceInstance_ResourceInCheckoutStateTest() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- RestResponse createVFInstanceWithoutChangeStateResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ComponentInstanceRestUtils.checkCreateResponse(createVFInstanceWithoutChangeStateResp);
- RestResponse createAtomicInstWithoutCheangeStateResp = createAtomicInstanceForService(serviceDetails_01,
- resourceDetailsCP_01, sdncDesignerDetails);
- ComponentInstanceRestUtils.checkCreateResponse(createAtomicInstWithoutCheangeStateResp);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- /*@Test
- public void createResourceInstance_ResourceInCertificationRequestStateTest() throws Exception {
- changeResourceLifecycleState(resourceDetailsVF_01, sdncDesignerDetails.getUserId(),
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- changeResourceLifecycleState(resourceDetailsCP_01, sdncDesignerDetails.getUserId(),
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
-
- createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }*/
-
- /*@Test
- public void createResourceInstance_startCertificationStateTest() throws Exception {
- changeResourceLifecycleState(resourceDetailsVF_01, sdncDesignerDetails.getUserId(),
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- changeResourceLifecycleState(resourceDetailsCP_01, sdncDesignerDetails.getUserId(),
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
-
- changeResourceLifecycleState(resourceDetailsVF_01, sdncTesterDetails.getUserId(),
- LifeCycleStatesEnum.STARTCERTIFICATION);
- changeResourceLifecycleState(resourceDetailsCP_01, sdncTesterDetails.getUserId(),
- LifeCycleStatesEnum.STARTCERTIFICATION);
-
- createVFInstanceAndAtomicResourceInstanceWithoutCheckin(resourceDetailsVF_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
-
- }*/
-
- @Test
- public void createResourceInstance_certifiedStateTest() throws Exception {
- certifyResource(resourceDetailsVF_01);
- certifyResource(resourceDetailsCP_01);
-
- createVFInstanceAndAtomicResourceInstanceWithoutCheckin(resourceDetailsVF_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- }
-
- @Test
- public void createResourceInstance_OneHasDifferentOwner() throws Exception {
- User designer2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2);
-
- ResourceReqDetails vfResource = new ResourceReqDetails(resourceDetailsVF_01, "0.1");
- vfResource.setUniqueId(null);
- vfResource.setName("newVF");
- vfResource.setTags(new ArrayList<String>(Arrays.asList(vfResource.getName())));
- createVF(vfResource, designer2);
-
- RestResponse atomicInstanceForService = createCheckedinAtomicInstanceForService(serviceDetails_01,
- resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(atomicInstanceForService);
- createVFInstanceFailWithoutChangeState(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), vfResource,
- designer2, 409);
-
- getComponentAndValidateRIs(serviceDetails_01, 1, 0);
- }
-
- @Test
- public void indexesOfVFInstancesTest() throws Exception {
- String firstInstanceName = resourceDetailsVF_01.getName() + SPACE_STRING + "1";
- String secondInstanceName = resourceDetailsVF_01.getName() + SPACE_STRING + "2";
- String thirdInstanceName = resourceDetailsVF_01.getName() + SPACE_STRING + "3";
-
- LifecycleRestUtils.changeResourceState(resourceDetailsVF_01, sdncDesignerDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
-
- RestResponse createFirstVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createSecondVFInstResp);
- RestResponse createThirdVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createThirdVFInstResp);
-
- Component service = getComponentAndValidateRIs(serviceDetails_01, 3, 0);
- List<ComponentInstance> componentInstancesList = service.getComponentInstances();
- for (ComponentInstance instance : componentInstancesList) {
- String instanceName = instance.getName();
- boolean isEqualToFirstInstanceName = instanceName.equals(firstInstanceName);
- boolean isEqualToSecondInstanceName = instanceName.equals(secondInstanceName);
- boolean isEqualToThirdInstanceName = instanceName.equals(thirdInstanceName);
- assertTrue(isEqualToFirstInstanceName || isEqualToSecondInstanceName || isEqualToThirdInstanceName);
- }
- }
-
- @Test
- public void vfInstancesAmountInTwoServiceVersionsTest() throws Exception {
- String oldServiceUniqueId = serviceDetails_01.getUniqueId();
-
- createTwoCheckedinVFInstances();
-
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
-
- String newSerivceUniqueIdAfterChangeLifecycleState = serviceDetails_01.getUniqueId();
- getComponentAndValidateRIsAfterChangeLifecycleState(oldServiceUniqueId, serviceDetails_01, 2, 0);
-
- // Check old version
- checkServiceOldVersionRIs(oldServiceUniqueId, newSerivceUniqueIdAfterChangeLifecycleState, 2, 0);
-
- // Add one more resource instance to second version of service
- LifecycleRestUtils.changeResourceState(resourceDetailsVL_01, sdncDesignerDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- RestResponse createAtomicResourceInstResp = createAtomicResourceInstanceToSecondServiceVersion(
- newSerivceUniqueIdAfterChangeLifecycleState, resourceDetailsVL_01);
- String atomicResourceUniqueId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstResp);
- getComponentAndValidateRIsAfterAddingAtomicResourceInstance(oldServiceUniqueId, serviceDetails_01, 3, 0);
-
- // Check that RIs are same as in the beginning - like in old version of
- // service
- deleteCompInstReqCapFromExpected(atomicResourceUniqueId);
- checkServiceOldVersionRIs(oldServiceUniqueId, newSerivceUniqueIdAfterChangeLifecycleState, 2, 0);
-
- }
-
- private void createTwoCheckedinVFInstances() throws Exception {
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createSecondVFInstResp);
- }
-
- private void getComponentAndValidateRIsAfterAddingAtomicResourceInstance(String oldComponentUniqueId,
- ComponentReqDetails componentDetails, int numOfRIs, int numOfRelations) throws Exception {
- getComponentAndValidateRIsAfterChangeLifecycleState(oldComponentUniqueId, componentDetails, numOfRIs,
- numOfRelations);
-
- }
-
- private void checkServiceOldVersionRIs(String oldUniqueId, String newUniqueId, int numOfRIs, int numOfRelations)
- throws IOException, Exception {
- serviceDetails_01.setUniqueId(oldUniqueId);
- getComponentAndValidateRIsAfterChangeLifecycleState(newUniqueId, serviceDetails_01, numOfRIs, numOfRelations);
- }
-
- private RestResponse createAtomicResourceInstanceToSecondServiceVersion(String secondServiceUniqueId,
- ResourceReqDetails resourceToAdd) throws Exception {
- serviceDetails_01.setUniqueId(secondServiceUniqueId);
- RestResponse createAtomicResourceInstResp = createAtomicInstanceForService(serviceDetails_01, resourceToAdd,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstResp);
- return createAtomicResourceInstResp;
- }
-
- @Test
- public void createResourceInstanceToUnsupportedComponentTest() throws Exception {
- String unsupportedType = "unsupported";
- ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory
- .getComponentResourceInstance(resourceDetailsCP_01);
- RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(
- resourceInstanceReqDetails, sdncDesignerDetails, serviceDetails_01.getUniqueId(), unsupportedType);
- checkErrorMessage(ActionStatus.UNSUPPORTED_ERROR, new ArrayList<String>(Arrays.asList(unsupportedType)), 400,
- createResourceInstanceResponse);
- }
-
- @Test
- public void deleteResourceInstanceByDifferentDesignerTest() throws Exception {
-
- createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01);
-
- deleteVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2), 409);
- deleteAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2), 409);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void deleteResourceInstanceByDifferentDesignerTest_ServiceIsCheckedin() throws Exception {
-
- String oldServiceUniqueId = serviceDetails_01.getUniqueId();
-
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- RestResponse createAtomicResourceInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01,
- resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstResp);
-
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- changeServiceLifecycleState(serviceDetails_01, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2),
- LifeCycleStatesEnum.CHECKOUT);
- String newServiceUniqueId = serviceDetails_01.getUniqueId();
-
- String oldVFInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- String newVFInstanceUniqueId = oldVFInstanceUniqueId.replaceAll(oldServiceUniqueId,
- serviceDetails_01.getUniqueId());
- String oldAtomicResourceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstResp);
- String newAtomicResourceInstanceUniqueId = oldAtomicResourceInstanceUniqueId.replaceAll(oldServiceUniqueId,
- serviceDetails_01.getUniqueId());
-
- deleteVFInstanceAndAtomicResourceInstanceSuccessfully(newVFInstanceUniqueId, newAtomicResourceInstanceUniqueId,
- ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2));
-
- serviceDetails_01.setUniqueId(oldServiceUniqueId);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
-
- serviceDetails_01.setUniqueId(newServiceUniqueId);
- updateExpectedReqCapAfterChangeLifecycleState(oldServiceUniqueId, serviceDetails_01.getUniqueId());
- deleteCompInstReqCapFromExpected(newVFInstanceUniqueId);
- deleteCompInstReqCapFromExpected(newAtomicResourceInstanceUniqueId);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- private void deleteVFInstanceAndAtomicResourceInstanceSuccessfully(String vfInstanceUniqueId,
- String atomicResourceInstanceUniqueId) throws IOException, Exception {
- deleteVFInstanceAndAtomicResourceInstanceSuccessfully(vfInstanceUniqueId, atomicResourceInstanceUniqueId,
- sdncDesignerDetails);
- }
-
- private void deleteVFInstanceAndAtomicResourceInstanceSuccessfully(String vfInstanceUniqueId,
- String atomicResourceInstanceUniqueId, User user) throws IOException, Exception {
- RestResponse deleteVFInstResp = deleteVFInstance(vfInstanceUniqueId, serviceDetails_01, user);
- ResourceRestUtils.checkDeleteResponse(deleteVFInstResp);
- RestResponse deleteAtomicResourceInsResp = deleteAtomicInstanceForService(atomicResourceInstanceUniqueId,
- serviceDetails_01, user);
- ResourceRestUtils.checkDeleteResponse(deleteAtomicResourceInsResp);
- }
-
- @Test
- public void deleteResourceInstanceByTesterUserTest() throws Exception {
- createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01);
- deleteVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), 409);
- deleteAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), 409);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void deleteResourceInstanceByNotASDCUserTest() throws Exception {
- createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01);
- User notASDCUser = new User();
- notASDCUser.setUserId("ab0001");
- deleteVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- notASDCUser, 409);
- deleteAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, notASDCUser, 409);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void deleteResourceInstanceFromCheckedinServiceTest() throws Exception {
- createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01);
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- deleteVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- sdncDesignerDetails, 409);
- deleteAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, sdncDesignerDetails, 409);
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void deleteResourceInstanceWhileResourceCertifiedStateTest() throws Exception {
- certifyResource(resourceDetailsVF_01);
- certifyResource(resourceDetailsCP_01);
-
- RestResponse createVFInstance = createVFInstance(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstance);
- String vfInstUniqueId = ResponseParser.getUniqueIdFromResponse(createVFInstance);
- RestResponse atomicInstanceForService = createAtomicInstanceForService(serviceDetails_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(atomicInstanceForService);
- String atomicInstUniqueId = ResponseParser.getUniqueIdFromResponse(atomicInstanceForService);
-
- deleteVFInstanceAndAtomicResourceInstanceSuccessfully(vfInstUniqueId, atomicInstUniqueId);
-
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- // fail - bug DE191849
- @Test
- public void deleteNotFoundResourceInstanceTest() throws Exception, Throwable {
-
- resourceDetailsVF_01.setUniqueId("1234");
- resourceDetailsCP_01.setUniqueId("5678");
-
- deleteVFInstanceFail(ActionStatus.RESOURCE_NOT_FOUND, new ArrayList<String>(Arrays.asList("")),
- resourceDetailsVF_01, sdncDesignerDetails, 404);
- deleteAtomicResourceInstanceFail(ActionStatus.RESOURCE_NOT_FOUND, new ArrayList<String>(Arrays.asList("")),
- resourceDetailsCP_01, sdncDesignerDetails, 404);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
-
- // {"requestError":{"serviceException":{"messageId":"SVC4503","text":"Error:
- // Requested '%1' service was not found.","variables":["1234"]}}}>
- }
-
- @Test
- public void deleteResourceInstanceFromServiceNotFoundTest() throws Exception, Throwable {
- serviceDetails_01.setUniqueId("1234");
- deleteVFInstanceFail(ActionStatus.SERVICE_NOT_FOUND, new ArrayList<String>(Arrays.asList("")),
- resourceDetailsVF_01, sdncDesignerDetails, 404);
- deleteAtomicResourceInstanceFail(ActionStatus.SERVICE_NOT_FOUND, new ArrayList<String>(Arrays.asList("")),
- resourceDetailsCP_01, sdncDesignerDetails, 404);
- }
-
- @Test
- public void deleteResourceInstanceFromUnsupportedTypeTest() throws Exception {
- String unsupportedType = "unsupportedType";
- RestResponse deleteVFInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncDesignerDetails,
- serviceDetails_01.getUniqueId(), resourceDetailsVF_01.getUniqueId(), unsupportedType);
- checkErrorMessage(ActionStatus.UNSUPPORTED_ERROR, new ArrayList<String>(Arrays.asList(unsupportedType)), 400,
- deleteVFInstanceResponse);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- @Test
- public void deleteResourceInstanceWithEmptyServiceUidTest() throws Exception, Throwable {
- serviceDetails_01.setUniqueId("");
- RestResponse deleteVFInstResp = deleteVFInstance(resourceDetailsVF_01.getUniqueId(), serviceDetails_01,
- sdncDesignerDetails);
- assertEquals(404, deleteVFInstResp.getErrorCode().intValue());
- }
-
- @Test
- public void deleteResourceInstanceWithEmptyResourceInstanceUidTest() throws Exception, Throwable {
- RestResponse deleteVFInstResp = deleteVFInstance("", serviceDetails_01, sdncDesignerDetails);
- assertEquals(405, deleteVFInstResp.getErrorCode().intValue());
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- @Test
- public void deleteResourceInstanceWithEmptyUserIdTest() throws Exception {
- sdncDesignerDetails.setUserId("");
- deleteVFInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(), resourceDetailsVF_01,
- sdncDesignerDetails, 409);
- deleteAtomicResourceInstanceFail(ActionStatus.RESTRICTED_OPERATION, new ArrayList<String>(),
- resourceDetailsCP_01, sdncDesignerDetails, 409);
- getComponentAndValidateRIs(serviceDetails_01, 0, 0);
- }
-
- // fail - bug DE188994
- @Test
- public void associateResourceInstanceToResourceInstanceNotFoundTest() throws Exception, Throwable {
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- String capCompInstId = "1234";
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- List<CapabilityDefinition> capListBeforeAssociate = new ArrayList<CapabilityDefinition>();
- CapabilityDefinition cap = new CapabilityDefinition();
- cap.setUniqueId(capCompInstId);
- capListBeforeAssociate.add(cap);
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- assocaiteInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESOURCE_INSTANCE_NOT_FOUND, 404,
- new ArrayList<String>(Arrays.asList(capCompInstId)));
-
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capabilitiesAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> requirementsAfterAssoicate = capReqDefAfterAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- // AssertJUnit.assertEquals("Check requirement", reqListBeforeAssociate,
- // requirementsAfterAssoicate);
- // AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate,
- // capabilitiesAfterAssociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 1, 0);
-
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "VF100 1",
- // "9ae76786-2a9c-4409-95cb-db32885ed07f.eece8aaf-eb9f-4aff-b9a5-a11ca11de9e5.vf1001",
- // "host"
- // ]
- }
-
- // this case is not relevant any more, it is tested as part of occurrences
- // story
- @Test(enabled = false)
- public void associateOnceAgainExistingRelationTest() throws Exception {
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- //////////////////////////////////////////////
- // NO ERROR - RELATION ALREADY EXIST
- // assocaiteInstancesFail(requirementDef, sdncDesignerDetails,
- // ActionStatus.RESOURCE_INSTANCE_NOT_FOUND, 404, new
- // ArrayList<String>(Arrays.asList(capCompInstId)));
- //////////////////////////////////////////////
-
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListAfterAssociate = capReqDefAfterAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- // AssertJUnit.assertEquals("Check requirement", null,
- // reqListAfterAssociate);
- // AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate,
- // capListAfterAssociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
-
- // "messageId": "SVC4119",
- // "text": "Error: No relation found between resource instances
- // \u0027%1\u0027 and \u0027%2\u0027 for requirement \u0027%3\u0027.",
- // "variables": [
- // "VF100 1",
- // "VF_admin 2",
- // "host"
-
- }
-
- @Test
- public void associateInstancesInMissingServiceTest() throws Exception {
- serviceDetails_01.setUniqueId("1234");
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- assocaiteInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.SERVICE_NOT_FOUND, 404,
- new ArrayList<String>(Arrays.asList("")));
- }
-
- @Test
- public void associateAfterDeletingResourceTest() throws Exception {
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- ResourceRestUtils.deleteResource(resourceDetailsVF_01.getUniqueId(), sdncDesignerDetails.getUserId());
-
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
-
- // for (CapabilityDefinition capabilityDefinition :
- // capListBeforeAssociate) {
- // if (capabilityDefinition.getType().equals(CAPABILITY_TYPE)){
- // capabilityDefinition.setMinOccurrences("0");
- // }
- // }
- //
- // List<RequirementDefinition> reqListAfterAssociate =
- // capReqDefAfterAssociate.getRequirements().get(CAPABILITY_TYPE);
- //
- // AssertJUnit.assertEquals("Check requirement", null,
- // reqListAfterAssociate);
- //
- // AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate,
- // capListAfterAssociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
- }
-
- @Test
- public void associateInstancesInCheckedinServiceTest() throws Exception {
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
-
- assocaiteInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESTRICTED_OPERATION, 409,
- new ArrayList<String>());
-
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capabilitiesAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> requirementsAfterAssoicate = capReqDefAfterAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- AssertJUnit.assertEquals("Check requirement", reqListBeforeAssociate, requirementsAfterAssoicate);
- AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate, capabilitiesAfterAssociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- // fail - bug DE188994
- @Test
- public void associateAfterCheckoutAllInstancesTest() throws Exception {
- String firstVFUniqueId = resourceDetailsVF_01.getUniqueId();
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- String secondVFUniqueId = resourceDetailsVF_02.getUniqueId();
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- changeResourceLifecycleState(resourceDetailsVF_01, sdncDesignerDetails.getUserId(),
- LifeCycleStatesEnum.CHECKOUT);
- changeResourceLifecycleState(resourceDetailsVF_02, sdncDesignerDetails.getUserId(),
- LifeCycleStatesEnum.CHECKOUT);
-
- requirementDef.setFromNode(
- requirementDef.getFromNode().replaceAll(firstVFUniqueId, resourceDetailsVF_01.getUniqueId()));
- requirementDef
- .setToNode(requirementDef.getToNode().replaceAll(secondVFUniqueId, resourceDetailsVF_02.getUniqueId()));
-
- assocaiteInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESTRICTED_OPERATION, 409,
- new ArrayList<String>());
-
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capabilitiesAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> requirementsAfterAssoicate = capReqDefAfterAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- // AssertJUnit.assertEquals("Check requirement", reqListBeforeAssociate,
- // requirementsAfterAssoicate);
- // AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate,
- // capabilitiesAfterAssociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
-
- // "messageId": "SVC4116",
- // "text": "Error: Invalid Content.",
- // "variables": [
- // "e9dcea15-ce27-4381-a554-4278973cefb1.d0b3affd-cf92-4626-adfe-961b44103924.vf1001",
- // "e9dcea15-ce27-4381-a554-4278973cefb1.d0b3affd-cf92-4626-adfe-961b44103924.vf1001",
- // "host"
- // ]
-
- }
-
- @Test
- public void associateInstancesByDifferentUsersTest() throws Exception {
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- assocaiteInstancesFail(requirementDef, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2),
- ActionStatus.RESTRICTED_OPERATION, 409, new ArrayList<String>());
- assocaiteInstancesFail(requirementDef, ElementFactory.getDefaultUser(UserRoleEnum.TESTER),
- ActionStatus.RESTRICTED_OPERATION, 409, new ArrayList<String>());
- assocaiteInstancesFail(requirementDef, ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR),
- ActionStatus.RESTRICTED_OPERATION, 409, new ArrayList<String>());
- assocaiteInstancesFail(requirementDef, ElementFactory.getDefaultUser(UserRoleEnum.OPS),
- ActionStatus.RESTRICTED_OPERATION, 409, new ArrayList<String>());
- assocaiteInstancesFail(requirementDef, ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1),
- ActionStatus.RESTRICTED_OPERATION, 409, new ArrayList<String>());
-
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capabilitiesAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> requirementsAfterAssoicate = capReqDefAfterAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- AssertJUnit.assertEquals("Check requirement", reqListBeforeAssociate, requirementsAfterAssoicate);
- AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate, capabilitiesAfterAssociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- private void assocaiteInstancesFail(RequirementCapabilityRelDef requirementDef, User user,
- ActionStatus actionStatus, int errorCode, List<String> variables) throws IOException, Exception {
- RestResponse associateInstancesResp = ComponentInstanceRestUtils.associateInstances(requirementDef, user,
- serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- checkErrorMessage(actionStatus, variables, errorCode, associateInstancesResp);
- }
-
- private void dissoicateInstancesFail(RequirementCapabilityRelDef requirementDef, User user,
- ActionStatus actionStatus, int errorCode, List<String> variables) throws IOException, Exception {
- RestResponse dissoicateInstancesResp = ComponentInstanceRestUtils.dissociateInstances(requirementDef, user,
- serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- checkErrorMessage(actionStatus, variables, errorCode, dissoicateInstancesResp);
- }
-
- @Test
- public void associateWithMissingServiceUidTest() throws Exception {
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- serviceDetails_01.setUniqueId("");
- RestResponse associateInstancesResp = ComponentInstanceRestUtils.associateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals(404, associateInstancesResp.getErrorCode().intValue());
- }
-
- // fail - bug DE191824
- @Test
- public void associateNotCompitableReqCapTest() throws Exception {
- RestResponse createFirstAtomicResourceInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01,
- resourceDetailsCP_01, sdncDesignerDetails);
- String reqCompInstName = ResponseParser.getNameFromResponse(createFirstAtomicResourceInstResp);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstAtomicResourceInstResp);
- RestResponse createSecondAtomicResourceInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01,
- resourceDetailsVL_02, sdncDesignerDetails);
- String capCompInstName = ResponseParser.getNameFromResponse(createSecondAtomicResourceInstResp);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondAtomicResourceInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- List<String> variables = new ArrayList<String>();
- variables.add(reqCompInstName);
- variables.add(capCompInstName);
- variables.add(REQUIREMENT_NAME);
-
- assocaiteInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND, 404,
- variables);
-
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capabilitiesAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> requirementsAfterAssoicate = capReqDefAfterAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- // AssertJUnit.assertEquals("Check requirement", reqListBeforeAssociate,
- // requirementsAfterAssoicate);
- // AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate,
- // capabilitiesAfterAssociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
-
- // {"requestError":{"serviceException":{"messageId":"SVC4119","text":"Error:
- // No relation found between resource instances '%1' and '%2' for
- // requirement '%3'.","variables":["CP100 1","VL200 2","host"]}}}>
- }
-
- @Test
- public void associateInstancesInTwoServiceVersionsTest() throws Exception {
- String oldServiceUniqueId = serviceDetails_01.getUniqueId();
- RestResponse createFirstVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
-
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
- String secondServiceUniqueId = serviceDetails_01.getUniqueId();
-
- serviceDetails_01.setUniqueId(oldServiceUniqueId);
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
-
- updateCapabilitiesOwnerId(oldServiceUniqueId, capListBeforeAssociate, secondServiceUniqueId);
- updateExpectedReqCapAfterChangeLifecycleState(oldServiceUniqueId, secondServiceUniqueId);
- CapReqDef capReqDefAfterAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListAfterAssociate = capReqDefAfterAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListAfterAssociate = capReqDefAfterAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- // AssertJUnit.assertEquals("Check requirement", null,
- // reqListAfterAssociate);
- // AssertJUnit.assertEquals("Check capabilities",
- // capListBeforeAssociate, capListAfterAssociate);
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
-
- RestResponse createThirdVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqSecondCompInstId = ResponseParser.getUniqueIdFromResponse(createThirdVFInstResp);
-
- CapReqDef capReqDefBeforeSeconderyAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeSeconderyAssociate = capReqDefBeforeSeconderyAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeSeconderyAssociate = capReqDefBeforeSeconderyAssociate
- .getRequirements().get(CAPABILITY_TYPE);
-
- capCompInstId = capCompInstId.replaceAll(oldServiceUniqueId, secondServiceUniqueId);
- RequirementCapabilityRelDef secondRequirementDef = getReqCapRelation(reqSecondCompInstId, capCompInstId,
- CAPABILITY_TYPE, REQUIREMENT_NAME, capListBeforeSeconderyAssociate, reqListBeforeSeconderyAssociate);
- associateComponentInstancesForService(secondRequirementDef, serviceDetails_01, sdncDesignerDetails);
-
- CapReqDef capReqDefAfterSeconderyAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListAfterSeconderyAssociate = capReqDefAfterSeconderyAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListAfterSeconderyAssociate = capReqDefAfterSeconderyAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
- // AssertJUnit.assertEquals("Check requirement", null,
- // reqListAfterSeconderyAssociate);
- // AssertJUnit.assertEquals("Check capabilities",
- // capListBeforeAssociate, capListAfterSeconderyAssociate);
- getComponentAndValidateRIs(serviceDetails_01, 3, 2);
- }
-
- private void updateCapabilitiesOwnerId(String oldUniqueId, List<CapabilityDefinition> capList, String newUniqueId) {
- serviceDetails_01.setUniqueId(newUniqueId);
- for (CapabilityDefinition cap : capList) {
- String oldOwnerId = cap.getOwnerId();
- String newOwnerId = oldOwnerId.replaceAll(oldUniqueId, newUniqueId);
- cap.setOwnerId(newOwnerId);
- }
- }
-
- @Test
- public void dissociateRelationNotFoundTest() throws Exception {
- createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails);
- String reqCompInstId = "1234";
- createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02, sdncDesignerDetails);
- String capCompInstId = "4567";
-
- CapReqDef capReqDef = ComponentRestUtils.getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capList, reqList);
-
- List<String> variables = new ArrayList<String>();
- variables.add(reqCompInstId);
- variables.add(capCompInstId);
- variables.add(REQUIREMENT_NAME);
- dissoicateInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND,
- 404, variables);
-
- CapReqDef capReqDefAfterDissociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListAfterDissociate = capReqDefAfterDissociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListAfterDissociate = capReqDefAfterDissociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- AssertJUnit.assertEquals("Check requirement", 1, reqListAfterDissociate.size());
- AssertJUnit.assertEquals("Check requirement", reqList, reqListAfterDissociate);
- AssertJUnit.assertEquals("Check capabilities", capList, capListAfterDissociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
-
- }
-
- @Test
- public void dissociateRelationInServiceNotFoundTest() throws Exception {
- String uniqueId = "1234";
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- serviceDetails_01.setUniqueId(uniqueId);
- dissoicateInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.SERVICE_NOT_FOUND, 404,
- new ArrayList<String>(Arrays.asList("")));
-
- }
-
- @Test
- public void dissoicateRelationWhileInstanceNotFound() throws Exception {
- String capUniqueId = "1234";
-
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02, sdncDesignerDetails);
- String capCompInstId = capUniqueId;
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- List<String> variables = new ArrayList<String>();
- variables.add(reqCompInstId);
- variables.add(capCompInstId);
- variables.add(REQUIREMENT_NAME);
- dissoicateInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND,
- 404, variables);
-
- CapReqDef capReqDefAfterDissociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListAfterDissociate = capReqDefAfterDissociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListAfterDissociate = capReqDefAfterDissociate.getRequirements()
- .get(CAPABILITY_TYPE);
- AssertJUnit.assertEquals("Check requirement", reqListBeforeAssociate, reqListAfterDissociate);
- AssertJUnit.assertEquals("Check capabilities", capListBeforeAssociate, capListAfterDissociate);
-
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void dissociateWhileServiceCheckedinTest() throws Exception {
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- dissoicateInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESTRICTED_OPERATION, 409,
- new ArrayList<String>());
- }
-
- @Test
- public void dissoicateWithEmptyUserIdHeaderTest() throws Exception {
- sdncDesignerDetails.setUserId("");
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- dissoicateInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESTRICTED_OPERATION, 409,
- new ArrayList<String>());
- }
-
- @Test
- public void dissociateWithMissingUidOfServiceTest() throws Exception {
- serviceDetails_01.setUniqueId("");
- RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
- RestResponse dissociateResp = ComponentInstanceRestUtils.dissociateInstances(requirementDef,
- sdncDesignerDetails, serviceDetails_01.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertEquals(404, dissociateResp.getErrorCode().intValue());
- }
-
- @Test
- public void relationDeletedAfterDeletingResourceInstanceTest() throws Exception {
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
-
- RestResponse deleteVFInstance = deleteVFInstance(reqCompInstId, serviceDetails_01, sdncDesignerDetails);
- ComponentInstanceRestUtils.checkDeleteResponse(deleteVFInstance);
- getComponentAndValidateRIs(serviceDetails_01, 1, 0);
- }
-
- @Test
- public void relationNotFoundInSecondVersionAfterDissociateTest() throws Exception {
- String oldContainerUniqueIdToReplace = serviceDetails_01.getUniqueId();
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- dissociateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
-
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
-
- updateExpectedReqCapAfterChangeLifecycleState(oldContainerUniqueIdToReplace, serviceDetails_01.getUniqueId());
- getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
-
- @Test
- public void dissociateOnceAgainTest() throws Exception {
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- String reqCompInsName = ResponseParser
- .convertComponentInstanceResponseToJavaObject(createFirstVFInstResp.getResponse()).getName();
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
- String capCompInstName = ResponseParser
- .convertComponentInstanceResponseToJavaObject(createSecondVFInstResp.getResponse()).getName();
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, CAPABILITY_TYPE,
- REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- dissociateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
-
- List<String> variables = new ArrayList<String>();
- variables.add(reqCompInsName);
- variables.add(capCompInstName);
- variables.add(REQUIREMENT_NAME);
-
- dissoicateInstancesFail(requirementDef, sdncDesignerDetails, ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND,
- 404, variables);
- }
-
- // fail - bug : DE191707
- @Test
- public void associateTwoRelations_CheckinCheckout_DissoicateOneRelationInSecondVersion() throws Exception {
- String oldContainerUniqueIdToReplace = serviceDetails_01.getUniqueId();
- RestResponse createFirstVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createFirstVFInstResp);
- RestResponse createSecondVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createSecondVFInstResp);
- RestResponse createThirdVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- String secondReqCompInstId = ResponseParser.getUniqueIdFromResponse(createThirdVFInstResp);
-
- CapReqDef capReqDefBeforeAssociate = ComponentRestUtils
- .getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01);
- List<CapabilityDefinition> capListBeforeAssociate = capReqDefBeforeAssociate.getCapabilities()
- .get(CAPABILITY_TYPE);
- List<RequirementDefinition> reqListBeforeAssociate = capReqDefBeforeAssociate.getRequirements()
- .get(CAPABILITY_TYPE);
-
- RequirementCapabilityRelDef requirementDefFirstRelation = getReqCapRelation(reqCompInstId, capCompInstId,
- CAPABILITY_TYPE, REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
- RequirementCapabilityRelDef requirementDefSecondRelation = getReqCapRelation(secondReqCompInstId, capCompInstId,
- CAPABILITY_TYPE, REQUIREMENT_NAME, capListBeforeAssociate, reqListBeforeAssociate);
-
- associateComponentInstancesForService(requirementDefFirstRelation, serviceDetails_01, sdncDesignerDetails);
- associateComponentInstancesForService(requirementDefSecondRelation, serviceDetails_01, sdncDesignerDetails);
- getComponentAndValidateRIs(serviceDetails_01, 3, 2);
-
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
- String newContainerUniqueId = serviceDetails_01.getUniqueId();
-
- // check if dissoicate of old relation is possibile
- // dissoicateInstancesFail(requirementDefFirstRelation,
- // sdncDesignerDetails, actionStatus, errorCode, variables);
- getComponentAndValidateRIs(serviceDetails_01, 3, 2);
-
- requirementDefFirstRelation
- .setFromNode(reqCompInstId.replaceAll(oldContainerUniqueIdToReplace, newContainerUniqueId));
- requirementDefFirstRelation
- .setToNode(reqCompInstId.replaceAll(oldContainerUniqueIdToReplace, newContainerUniqueId));
-
- dissociateComponentInstancesForService(requirementDefFirstRelation, serviceDetails_01, sdncDesignerDetails);
-
- // updateCapabilitiesOwnerId(oldContainerUniqueIdToReplace,
- // capListBeforeAssociate, newContainerUniqueId);
- // CapReqDef capReqDefAfterAssociate =
- // ComponentRestUtils.getAndParseComponentRequirmentsCapabilities(sdncDesignerDetails,
- // serviceDetails_01);
- // List<CapabilityDefinition> capListAfterAssociate =
- // capReqDefAfterAssociate.getCapabilities().get(CAPABILITY_TYPE);
- // List<RequirementDefinition> reqListAfterAssociate =
- // capReqDefAfterAssociate.getRequirements().get(CAPABILITY_TYPE);
- // AssertJUnit.assertEquals("Check requirement", reqListBeforeAssociate,
- // reqListAfterAssociate);
- // AssertJUnit.assertEquals("Check requirement", capListBeforeAssociate,
- // capListAfterAssociate);
- updateExpectedReqCapAfterChangeLifecycleState(oldContainerUniqueIdToReplace, serviceDetails_01.getUniqueId());
- getComponentAndValidateRIs(serviceDetails_01, 3, 1);
- }
-
- @Test
- public void createResourceInstancesAndUpdatedServiceMetadataTest() throws Exception, Exception {
- serviceDetails_02.setUniqueId(serviceDetails_01.getUniqueId());
- createTwoCheckedinVFInstances();
- LifecycleRestUtils.changeResourceState(resourceDetailsCP_01, sdncDesignerDetails, "0.1",
- LifeCycleStatesEnum.CHECKIN);
- createVFInstanceAndAtomicResourceInstanceWithoutCheckin(resourceDetailsVF_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- RestResponse updateServiceResp = ServiceRestUtils.updateService(serviceDetails_02, sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(updateServiceResp);
- getComponentAndValidateRIs(serviceDetails_01, 4, 0);
- }
-
- @Test(enabled = false)
- public void forAcceptanceUserStory() throws Exception {
- RestResponse createVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String reqCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
- createVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_02, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- String capCompInstId = ResponseParser.getUniqueIdFromResponse(createVFInstResp);
-
- String capType = CAPABILITY_TYPE;
- String reqName = REQUIREMENT_NAME;
-
- RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- ResourceRestUtils.checkSuccess(getResourceResponse);
- CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType);
- List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType);
-
- RequirementCapabilityRelDef requirementDef = getReqCapRelation(reqCompInstId, capCompInstId, capType, reqName,
- capList, reqList);
-
- associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails);
- getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails,
- serviceDetails_01);
- capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class);
- List<RequirementDefinition> list = capReqDef.getRequirements().get(capType);
- AssertJUnit.assertEquals("Check requirement", null, list);
-
- serviceDetails_02.setUniqueId(serviceDetails_01.getUniqueId());
- RestResponse updateServiceResp = ServiceRestUtils.updateService(serviceDetails_02, sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(updateServiceResp);
- changeServiceLifecycleState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- getComponentAndValidateRIs(serviceDetails_01, 2, 1);
- }
-
- @Test
- public void testUnsatisfiedCpReqInService() throws Exception {
-
- // Certify all the needed atomic resources
- RestResponse response = LifecycleRestUtils.certifyResource(resourceDetailsCP_01);
- ResourceRestUtils.checkSuccess(response);
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails,
- resourceDetailsVF_02.getUniqueId());
- ResourceRestUtils.checkSuccess(response);
- response = LifecycleRestUtils.certifyResource(resourceDetailsVF_02);
- ResourceRestUtils.checkSuccess(response);
- capOwnerId = getUniqueIdOfFirstInstanceFromResponse(response);
-
- RestResponse createAtomicResourceInstance = createVFInstance(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String vfCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- createAtomicResourceInstance = createAtomicInstanceForService(serviceDetails_01, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String compInstName = ResponseParser.getNameFromResponse(createAtomicResourceInstance);
- String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- RestResponse submitForTesting = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- String[] variables = new String[] { serviceDetails_01.getName(), "service", "CP (Connection Point)",
- compInstName, "requirement", "tosca.capabilities.network.Bindable", "fulfilled" };
- BaseValidationUtils.checkErrorResponse(submitForTesting,
- ActionStatus.REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION, variables);
-
- fulfillCpRequirement(serviceDetails_01, cpCompInstId, vfCompInstId, capOwnerId, sdncDesignerDetails,
- ComponentTypeEnum.SERVICE);
-
- submitForTesting = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- BaseValidationUtils.checkSuccess(submitForTesting);
- }
-
- @Test
- public void getVFInstanceSuccessfullyTest() throws Exception {
- RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- System.out.println("instance successfuly created");
- RestResponse getInstancesResponce = ComponentInstanceRestUtils.getComponentInstances(ComponentTypeEnum.SERVICE,
- serviceDetails_01.getUniqueId(), sdncDesignerDetails);
-
- for (int i = 0; i < 1500; i++) {
- createVFInstResp = createVFInstance(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createVFInstResp);
- System.out.println("instance " + i + "successfuly created");
- }
-
- getInstancesResponce = ComponentInstanceRestUtils.getComponentInstances(ComponentTypeEnum.SERVICE,
- serviceDetails_01.getUniqueId(), sdncDesignerDetails);
-
- BaseValidationUtils.checkSuccess(getInstancesResponce);
-
- }
-
- private String getUniqueIdOfFirstInstanceFromResponse(RestResponse response) {
- try {
- JSONArray value = ResponseParser.getListFromJson(response, "componentInstances");
- return ResponseParser.getValueFromJsonResponse(value.get(0).toString(), "uniqueId");
- } catch (Exception e) {
- return null;
- }
- }
-}
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
deleted file mode 100644
index 18c2614040..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java
+++ /dev/null
@@ -1,2157 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.service;
-
-import org.apache.commons.lang3.StringUtils;
-import org.codehaus.jettison.json.JSONException;
-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.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
-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.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.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.utils.general.AtomicOperationUtils;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-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.validation.ErrorValidationUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ServiceValidationUtils;
-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>();
-
- protected ResourceReqDetails resourceDetails;
- protected ServiceReqDetails serviceDetails;
- protected User sdncDesignerDetails;
- protected User sdncDesignerDetails2;
- protected User sdncAdminDetails;
- protected User sdncGovernorDeatails;
- protected User sdncTesterDetails;
- protected User sdncOpsDetails;
- protected ComponentInstanceReqDetails resourceInstanceReqDetails;
- protected Component resourceDetailsVFCcomp;
- protected Component serviceDetailsCompp;
-
- @Rule
- public static TestName name = new TestName();
- protected ServiceReqDetails updatedServiceDetails;
-
- public UpdateServiceMetadataTest() {
- super(name, UpdateServiceMetadataTest.class.getName());
- }
-
- @BeforeMethod
- public void setUp() throws Exception {
-
- sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- sdncDesignerDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2);
- sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN2);
- sdncGovernorDeatails = ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR);
- sdncTesterDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- sdncOpsDetails = ElementFactory.getDefaultUser(UserRoleEnum.OPS);
- resourceDetailsVFCcomp = AtomicOperationUtils
- .createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT, resourceDetailsVFCcomp, UserRoleEnum.DESIGNER,
- true, true);
-
- AtomicOperationUtils.changeComponentState(resourceDetailsVFCcomp, UserRoleEnum.DESIGNER,
- LifeCycleStatesEnum.CERTIFY, true);
- Service serviceServ = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceDetailsVFCcomp, serviceServ,
- UserRoleEnum.DESIGNER, true);
-
- serviceDetails = new ServiceReqDetails(serviceServ);
- updatedServiceDetails = updatedServiceDetails(serviceDetails);
-
- }
-
- protected void certifyService(ServiceReqDetails serviceDetails, String version) throws Exception {
- LifecycleRestUtils.certifyService(serviceDetails);
- }
-
- protected ServiceReqDetails updatedServiceDetails(ServiceReqDetails service) {
- ServiceReqDetails updatedServiceDetails = new ServiceReqDetails(service);
-
- updatedServiceDetails.setDescription("updatedDescription");
- updatedServiceDetails.setName(service.getName());
- updatedServiceDetails.setProjectCode("987654654");
- updatedServiceDetails.setIcon("icon-service-red3");
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("updateTag", updatedServiceDetails.getName())));
- updatedServiceDetails.removeAllCategories();
- updatedServiceDetails.setCategories(null);
- updatedServiceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
- updatedServiceDetails.setContactId("xy0123");
-
- return updatedServiceDetails;
- }
-
- protected void addMandatoryArtifactsToService() throws Exception {
- // TODO Andrey US575052
- // ServiceRestUtils.addServiceMandatoryArtifacts(sdncDesignerDetails,
- // createServiceResponse);
- }
-
- protected void getServiceAndValidate(ServiceReqDetails excpectedService, User creator, User updater,
- LifecycleStateEnum lifeCycleState) throws Exception {
- RestResponse getServiceResponse = ServiceRestUtils.getService(excpectedService.getUniqueId(),
- sdncDesignerDetails);
- AssertJUnit.assertNotNull("check response object is not null after updating service", getServiceResponse);
- AssertJUnit.assertNotNull("check if error code exists in response after updating service",
- getServiceResponse.getErrorCode());
- AssertJUnit.assertEquals("Check response code after updating service", 200,
- getServiceResponse.getErrorCode().intValue());
- Service actualService = ResponseParser.convertServiceResponseToJavaObject(getServiceResponse.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(excpectedService, actualService, creator, updater,
- lifeCycleState);
- }
-
- public void getServiceAndValidate(ServiceReqDetails excpectedService, LifecycleStateEnum lifecycleState)
- throws Exception {
- getServiceAndValidate(excpectedService, sdncDesignerDetails, sdncDesignerDetails, lifecycleState);
- }
-
- protected void validateResponse(RestResponse response, int errorCode, ActionStatus actionResponse,
- List<String> listOfVariables) throws Exception {
- AssertJUnit.assertNotNull("check response object is not null after updating service", response);
- AssertJUnit.assertNotNull("check if error code exists in response after updating service",
- response.getErrorCode());
- AssertJUnit.assertEquals("Check response code after updating service", errorCode,
- response.getErrorCode().intValue());
-
- if (actionResponse != null) {
- ErrorValidationUtils.checkBodyResponseOnError(actionResponse.name(), listOfVariables,
- response.getResponse());
- return;
- }
-
- Service actualService = ResponseParser.convertServiceResponseToJavaObject(response.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(updatedServiceDetails, actualService,
- sdncDesignerDetails, sdncDesignerDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- protected void validateActualVsExpected(ServiceReqDetails expectedService, RestResponse actualServiceFromResponse) {
- Service actualService = ResponseParser
- .convertServiceResponseToJavaObject(actualServiceFromResponse.getResponse());
- ServiceValidationUtils.validateServiceResponseMetaData(updatedServiceDetails, actualService,
- sdncDesignerDetails, sdncDesignerDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- protected String multipleString(String ch, int repeat) {
- return StringUtils.repeat(ch, repeat);
- }
-
- protected void correctUpdate() throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 200, null, listForMessage);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- protected void updateWithInvalidValue(ActionStatus invalidValue, List<String> arr) throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, invalidValue, arr);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- protected void charactersInRangeChecking(int min, int max, String field) throws Exception {
- if (field != null) {
- if (field == "name") {
- for (char ch = (char) min; ch <= (char) max; ch++) {
- updatedServiceDetails.setName("testname" + String.valueOf(ch));
- updatedServiceDetails.setTags(
- addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- updateWithInvalidValue(ActionStatus.INVALID_COMPONENT_NAME,
- new ArrayList<>(Arrays.asList("Service")));
- }
- } else if (field == "icon") {
- for (char ch = (char) min; ch <= (char) max; ch++) {
- updatedServiceDetails.setIcon("testname" + String.valueOf(ch));
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_ICON,
- new ArrayList<>(Arrays.asList("Service")));
- }
- } else if (field == "tags") {
- List<String> variables = Arrays.asList("Service", "tag");
- for (char ch = (char) min; ch <= (char) max; ch++) {
- updatedServiceDetails.setTags(
- new ArrayList<>(Arrays.asList(String.valueOf(ch), updatedServiceDetails.getName())));
- updateWithInvalidValue(ActionStatus.INVALID_FIELD_FORMAT, variables);
- }
- } else if (field == "category") {
- for (char ch = (char) min; ch <= (char) max; ch++) {
- updatedServiceDetails.addCategoryChain(multipleString("1", 5) + String.valueOf(ch),
- multipleString("1", 5) + String.valueOf(ch));
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CATEGORY,
- new ArrayList<>(Arrays.asList("Service")));
- }
- }
-
- else if (field == "projectCode") {
- for (char ch = (char) min; ch <= (char) max; ch++) {
- updatedServiceDetails.setProjectCode(multipleString("1", 5) + String.valueOf(ch));
- updateWithInvalidValue(ActionStatus.INVALID_PROJECT_CODE, listForMessage);
- }
- }
-
- else
- return;
- }
-
- }
-
- protected void specialCharsChecking(String field) throws Exception {
- charactersInRangeChecking(33, 44, field);
- charactersInRangeChecking(47, 47, field);
- charactersInRangeChecking(58, 64, field);
- charactersInRangeChecking(91, 94, field);
- charactersInRangeChecking(96, 96, field);
- charactersInRangeChecking(123, 126, field);
- }
-
- @Test
- public void updateServiceSuccessfully() throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 200, null, listForMessage);
-
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-
- }
-
- protected void checkErrorResponse(ActionStatus actionStatus, ArrayList<String> arrList, RestResponse response)
- throws Exception, JSONException {
- ErrorValidationUtils.checkBodyResponseOnError(actionStatus.name(), arrList, response.getResponse());
- }
-
- protected List<String> addServiceNameToTagsList(String serviceName, List<String> tagsList) {
- tagsList.add(serviceName);
- return tagsList;
-
- }
-
- // @Test
- // public void updateMetadateSuccessTest() throws Exception {
- // CloseableHttpClient httpClient = HttpClients.createDefault();
- // HttpGet httpGet =
- // ServiceRestUtils.createGetServiceGetRquest(serviceDetails,
- // sdncDesignerDetails);
- // CloseableHttpResponse response = httpClient.execute(httpGet);
- // assertTrue(response.getStatusLine().getStatusCode() == 200);
- // String responseString = new
- // BasicResponseHandler().handleResponse(response);
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(responseString);
- // assertTrue("service object creation failed the returned object is null",
- // serviceObject != null);
- // String currentCategory = serviceObject.getCategories().get(0).getName();
- // String currentServiceName = serviceObject.getName();
- // String currentProjectCode = serviceObject.getProjectCode();
- // String currentIcon = serviceObject.getIcon();
- // String currentDescription = serviceObject.getDescription();
- // List<String> currentTags = serviceObject.getTags();
- //
- // String newCategory = ServiceCategoriesEnum.VOIP.getValue();
- // serviceDetails.addCategory(newCategory);
- // // String newServiceName = "updated name";
- // // serviceDetails.setServiceName(newServiceName);
- // String newProjectCode = "68686868";
- // serviceDetails.setProjectCode(newProjectCode);
- // String newIcon = "updated-icon";
- // serviceDetails.setIcon(newIcon);
- // String newDescription = "updated description <html></html>";
- // serviceDetails.setDescription(newDescription);
- // List<String> newTags = new ArrayList<>();
- // newTags.add("update1");
- // newTags.add("update2");
- // newTags.add(currentServiceName);
- // serviceDetails.setTags(newTags);
- // HttpPut httpPut =
- // ServiceRestUtils.createUpdateServiceMetaDataPutRequest(serviceDetails,
- // sdncDesignerDetails);
- // response = httpClient.execute(httpPut);
- // assertTrue(response.getStatusLine().getStatusCode() == 200);
- // responseString = new BasicResponseHandler().handleResponse(response);
- // String serviceUid =
- // ServiceRestUtils.getServiceUniqueIdFromString(responseString);
- //
- // ServiceReqDetails details = new ServiceReqDetails();
- // details.setUniqueId(serviceUid);
- //
- // httpGet = ServiceRestUtils.createGetServiceGetRquest(details,
- // sdncDesignerDetails);
- // response = httpClient.execute(httpGet);
- // assertTrue(response.getStatusLine().getStatusCode() == 200);
- // responseString = new BasicResponseHandler().handleResponse(response);
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(responseString);
- // assertTrue("service object creation failed the returned object is null",
- // serviceObject != null);
- // String updatedCategory = serviceObject.getCategories().get(0).getName();
- // String updatedServiceName = serviceObject.getName();
- // String updatedProjectCode = serviceObject.getProjectCode();
- // String updatedIcon = serviceObject.getIcon();
- // String updatedDescription = serviceObject.getDescription();
- // List<String> updatedTags = serviceObject.getTags();
- // assertFalse("category did not cahnge",
- // currentCategory.equals(updatedCategory));
- // assertEquals("categoruy did not match expacted value", updatedCategory,
- // newCategory);
- // // assertFalse("service name did not change",
- // currentServiceName.equals(updatedServiceName) );
- // // assertEquals("service name did not match expacted
- // value",updatedServiceName,newServiceName);
- // assertFalse("projectCode did not change",
- // currentProjectCode.equals(updatedProjectCode));
- // assertEquals("projectCode not match expacted value", updatedProjectCode,
- // newProjectCode);
- // assertFalse("icon did not change", currentIcon.equals(updatedIcon));
- // assertEquals("icon did not match expacted value", updatedIcon, newIcon);
- // assertFalse("description did not change",
- // currentDescription.equals(updatedDescription));
- // assertEquals("description did not match expacted value", "updated
- // description", updatedDescription);
- // assertFalse("tags did not change", currentTags.containsAll(updatedTags));
- // assertTrue("tags did not match expacted value",
- // updatedTags.containsAll(newTags));
- // }
-
- @Test
- public void updateService_ByOtherDesigner() throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails2);
- validateResponse(updateServiceResponse, 409, ActionStatus.RESTRICTED_OPERATION, listForMessage);
-
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void updateService_ByAdmin() throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncAdminDetails);
- validateResponse(updateServiceResponse, 409, ActionStatus.RESTRICTED_OPERATION, listForMessage);
-
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void updateServiceNotExist() throws Exception {
- updatedServiceDetails.setUniqueId("nnnnn");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 404, ActionStatus.SERVICE_NOT_FOUND,
- new ArrayList<String>(Arrays.asList("")));
- }
-
- @Test
- public void updateCheckedinService() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKIN);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 409, ActionStatus.RESTRICTED_OPERATION, listForMessage);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- }
-
- @Test
- public void updateCertifiedService() throws Exception {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
-
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 409, ActionStatus.RESTRICTED_OPERATION, listForMessage);
- getServiceAndValidate(serviceDetails, sdncDesignerDetails, sdncAdminDetails, LifecycleStateEnum.CERTIFIED);
- }
-
- // TODO Irrelevant
- // @Test(enabled = false)
- // public void updateService_NameCaseSensitiveTest() throws Exception {
- // ServiceRestUtils.setServiceUniqueId(serviceDetails.getName().toUpperCase());
- //
- // RestResponse updateServiceResponse =
- // ServiceRestUtils.updateService(updatedServiceDetails,
- // sdncDesignerDetails);
- // validateResponse(updateServiceResponse, 200, null, listForMessage);
- //
- // Service serviceFromJsonResponse =
- // ResponseParser.convertServiceResponseToJavaObject(updateServiceResponse.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(updatedServiceDetails,
- // serviceFromJsonResponse, sdncDesignerDetails, (LifecycleStateEnum)null);
- //
- // getServiceAndValidate(updatedServiceDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- // }
-
- // @Test
- // public void updateApprovedDistributionServiceTest() throws Exception {
- // // addMandatoryArtifactsToService();
- // certifyService(serviceDetails, serviceDetails.getVersion());
- //
- // RestResponse approveResponse =
- // ServiceRestUtils.sendApproveDistribution(sdncAdminDetails,
- // serviceDetails.getUniqueId(), userRemarks);
- // // validateResponse(approveResponse, 200, null, listForMessage);
- //
- // RestResponse updateServiceResponse =
- // ServiceRestUtils.updateService(updatedServiceDetails,
- // sdncDesignerDetails);
- // validateResponse(updateServiceResponse, 409,
- // ActionStatus.RESTRICTED_OPERATION, listForMessage);
- //
- // getServiceAndValidate(serviceDetails, sdncDesignerDetails,
- // sdncAdminDetails,LifecycleStateEnum.CERTIFIED);
- // }
-
- @Test
- public void updateServiceByMethod_delete() throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.createServiceByHttpMethod(updatedServiceDetails,
- sdncDesignerDetails, "DELETE", Urls.UPDATE_SERVICE_METADATA);
- validateResponse(updateServiceResponse, 405, ActionStatus.NOT_ALLOWED, listForMessage);
-
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void updateServiceByMethod_get() throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.createServiceByHttpMethod(updatedServiceDetails,
- sdncDesignerDetails, "GET", Urls.UPDATE_SERVICE_METADATA);
- validateResponse(updateServiceResponse, 405, ActionStatus.NOT_ALLOWED, listForMessage);
-
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void updateServiceByMethod_post() throws Exception {
- RestResponse updateServiceResponse = ServiceRestUtils.createServiceByHttpMethod(updatedServiceDetails,
- sdncDesignerDetails, "POST", Urls.UPDATE_SERVICE_METADATA);
- validateResponse(updateServiceResponse, 405, ActionStatus.NOT_ALLOWED, listForMessage);
-
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void updateCheckoutCertifiedService() throws Exception // certify a
- // service
- // and
- // checkout
- // it
- {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKOUT);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.SERVICE_CATEGORY_CANNOT_BE_CHANGED, listForMessage);
-
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- // ---------------------------------------------------------Validation
- // Tests---------------------------------------------------------
-
- @Test
- public void missingCategoryTest1() throws Exception {
- List<CategoryDefinition> categories = updatedServiceDetails.getCategories();
- CategoryDefinition categoryDefinition = categories.get(0);
- CategoryDefinition categoryDefinition2 = categoryDefinition;
- categoryDefinition2.setName("");
- categories.set(0, categoryDefinition2);
- updatedServiceDetails.setCategories(categories);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_CATEGORY, Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingCategoryTest2() throws Exception {
- updatedServiceDetails.setCategories(null);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_CATEGORY, Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingServiceNameTest1() throws Exception {
- updatedServiceDetails.setName(StringUtils.EMPTY);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.MISSING_COMPONENT_NAME, Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingServiceNameTest2() throws Exception {
-
- updatedServiceDetails.setName(null);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.MISSING_COMPONENT_NAME, Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- // TODO Irrelevant
- @Test(enabled = false)
- public void missingProjectCodeTest1() throws Exception {
- updatedServiceDetails.setProjectCode(StringUtils.EMPTY);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.MISSING_PROJECT_CODE, listForMessage);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- // TODO Irrelevant
- @Test(enabled = false)
- public void missingProjectCodeTest2() throws Exception {
-
- updatedServiceDetails.setProjectCode(null);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.MISSING_PROJECT_CODE, listForMessage);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingIconTest1() throws Exception {
- updatedServiceDetails.setIcon(StringUtils.EMPTY);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_ICON, Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingIconTest2() throws Exception {
- updatedServiceDetails.setIcon(null);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_ICON, Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingDescriptionTest1() throws Exception {
- updatedServiceDetails.setDescription(StringUtils.EMPTY);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
- Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingDescriptionTest2() throws Exception {
- updatedServiceDetails.setDescription(null);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
- Arrays.asList("Service"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingTagsTest1() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<String>());
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_TAGS, listForMessage);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingTagsTest2() throws Exception {
- updatedServiceDetails.setTags(null);
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.COMPONENT_MISSING_TAGS, listForMessage);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingTagsTest3() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList(StringUtils.EMPTY)));
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.INVALID_FIELD_FORMAT,
- Arrays.asList("Service", "tag"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void missingTagsTest4() throws Exception {
- updatedServiceDetails
- .setTags(new ArrayList<>(Arrays.asList(StringUtils.EMPTY, updatedServiceDetails.getName())));
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- validateResponse(updateServiceResponse, 400, ActionStatus.INVALID_FIELD_FORMAT,
- Arrays.asList("Service", "tag"));
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- // update non-settable/"updatable" parameters tests
-
- // ------------------------------------------correct
- // values------------------------------------------
- @Test
- public void contactIdValidationTest1() throws Exception {
- updatedServiceDetails.setContactId("ab3456");
- correctUpdate();
- }
-
- @Test
- public void contactIdValidationTest2() throws Exception {
-
- updatedServiceDetails.setContactId("cd789E");
- correctUpdate();
- }
-
- @Test
- public void contactIdValidationTest3() throws Exception {
-
- updatedServiceDetails.setContactId("ef4567");
- correctUpdate();
- }
-
- @Test
- public void contactIdValidationTest4() throws Exception {
- updatedServiceDetails.setContactId("AA012A");
- correctUpdate();
- }
-
- @Test
- public void contactIdValidationTest5() throws Exception {
- updatedServiceDetails.setContactId("CD012c");
- correctUpdate();
- }
-
- @Test
- public void contactIdValidationTest6() throws Exception {
- updatedServiceDetails.setContactId("EF0123");
- correctUpdate();
- }
-
- // ------------------------------------------invalid
- // values------------------------------------------
- @Test
- public void contactIdValidationTest7() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKIN);
- updatedServiceDetails.setContactId("ab0001");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void contactIdValidationTest8() throws Exception {
- // addMandatoryArtifactsToService();
-
- RestResponse certifyServiceResp = LifecycleRestUtils.certifyService(serviceDetails);
- Service certifyServiceServ = ResponseParser
- .convertServiceResponseToJavaObject(certifyServiceResp.getResponse());
- ServiceReqDetails certifyService = new ServiceReqDetails(certifyServiceServ);
- updatedServiceDetails = new ServiceReqDetails(certifyService);
- updatedServiceDetails.setContactId("ab0001");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void contactIdValidationTest9() throws Exception {
- updatedServiceDetails.setContactId("01345a");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, Arrays.asList("Service"));
- }
-
- @Test
- public void contactIdValidationTest10() throws Exception {
- updatedServiceDetails.setContactId("0y000B");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, Arrays.asList("Service"));
- }
-
- @Test
- public void contactIdValidationTest11() throws Exception {
- updatedServiceDetails.setContactId("Y1000b");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, Arrays.asList("Service"));
- }
-
- @Test
- public void contactIdValidationTest12() throws Exception {
- updatedServiceDetails.setContactId("abxyzC");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, Arrays.asList("Service"));
- }
-
- @Test
- public void contactIdValidationTest13() throws Exception {
- updatedServiceDetails.setContactId("cdXYZc");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest14() throws Exception {
- updatedServiceDetails.setContactId("efXY1D");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest15() throws Exception {
- updatedServiceDetails.setContactId("EFabcD");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest16() throws Exception {
- updatedServiceDetails.setContactId("EFABCD");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest17() throws Exception {
- updatedServiceDetails.setContactId("EFABC1");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest18() throws Exception {
- updatedServiceDetails.setContactId("efui1D");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest19() throws Exception {
- updatedServiceDetails.setContactId("efui1!");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest20() throws Exception {
- updatedServiceDetails.setContactId("ef555!");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest21() throws Exception {
- updatedServiceDetails.setContactId(",f555");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest22() throws Exception {
- updatedServiceDetails.setContactId("EF55.5");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest23() throws Exception {
- updatedServiceDetails.setContactId("ab000");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest24() throws Exception {
- updatedServiceDetails.setContactId("ab000c0");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest25() throws Exception {
- updatedServiceDetails.setContactId(" ab0001");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CONTACT, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void contactIdValidationTest26() throws Exception {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKOUT);
- updatedServiceDetails = new ServiceReqDetails(serviceDetails);
- updatedServiceDetails.setContactId("xy0002");
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest1() throws Exception {
- updatedServiceDetails.setName(multipleString("a", 49));
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest2() throws Exception {
- updatedServiceDetails.setName(multipleString("b", 50));
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest3() throws Exception {
- updatedServiceDetails.setName("testNamE");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest4() throws Exception {
- updatedServiceDetails.setName("Testname");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest5() throws Exception {
- updatedServiceDetails.setName("Test_name");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest6() throws Exception {
- updatedServiceDetails.setName("Test name");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest7() throws Exception {
- updatedServiceDetails.setName("Test-name");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest8() throws Exception {
- updatedServiceDetails.setName("Test.name");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest9() throws Exception {
- updatedServiceDetails.setName("...1...");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest10() throws Exception {
- updatedServiceDetails.setName("-a_1. Arrrrrr");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest11() throws Exception {
- updatedServiceDetails.setName("Testname1234567890");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- correctUpdate();
- }
-
- @Test
- public void serviceNameValidationTest14() throws Exception {
- updatedServiceDetails.setName(StringUtils.SPACE); // one space with
- // nothing
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- // updateWithInvalidValue(ActionStatus.INVALID_COMPONENT_NAME, new
- // ArrayList<>(Arrays.asList("Service")));
- validateResponse(updateServiceResponse, 400, ActionStatus.MISSING_COMPONENT_NAME,
- new ArrayList<>(Arrays.asList("Service")));
- }
-
- // ------------------------------------------invalid
- // values------------------------------------------
- @Test
- public void serviceNameValidationTest12() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKIN);
- updatedServiceDetails.setName("TestNamE");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- }
-
- @Test
- public void serviceNameValidationTest13() throws Exception {
- updatedServiceDetails.setName(multipleString("c", 51));
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- updateWithInvalidValue(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT,
- new ArrayList<>(Arrays.asList("Service", "50")));
- }
-
- @Test
- public void serviceNameValidationTest15() throws Exception {
- specialCharsChecking("name");
- }
-
- @Test
- public void serviceNameValidationTest16() throws Exception {
- // addMandatoryArtifactsToService();
- LifecycleRestUtils.certifyService(serviceDetails);
- updatedServiceDetails.setName("testnamename");
- updatedServiceDetails.setCategories(serviceDetails.getCategories());
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- getServiceAndValidate(serviceDetails, sdncDesignerDetails, sdncTesterDetails, LifecycleStateEnum.CERTIFIED);
- }
-
- @Test
- public void serviceNameValidationTest17() throws Exception {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKOUT);
- updatedServiceDetails.setName("TestNamE");
- updatedServiceDetails.setCategories(serviceDetails.getCategories());
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- RestResponse updateServiceResponse2 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- validateResponse(updateServiceResponse2, 400, ActionStatus.SERVICE_NAME_CANNOT_BE_CHANGED, listForMessage);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void serviceNameValidationTest18() throws Exception {
- updatedServiceDetails.setName(" testname ");
- updatedServiceDetails
- .setTags(addServiceNameToTagsList(updatedServiceDetails.getName(), updatedServiceDetails.getTags()));
- RestResponse updateServiceResponse1 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse1);
- assertNotNull(updateServiceResponse1.getErrorCode());
- assertEquals(200, updateServiceResponse1.getErrorCode().intValue());
- updatedServiceDetails.setName(updatedServiceDetails.getName());
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse1);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void iconValidationTest1() throws Exception {
- updatedServiceDetails.setIcon(multipleString("a", 24));
- correctUpdate();
- }
-
- @Test
- public void iconValidationTest2() throws Exception {
- updatedServiceDetails.setIcon(multipleString("b", 25));
- correctUpdate();
- }
-
- @Test
- public void iconValidationTest3() throws Exception {
- updatedServiceDetails.setIcon("testNamE");
- correctUpdate();
- }
-
- @Test
- public void iconValidationTest4() throws Exception {
- updatedServiceDetails.setIcon("Testname");
- correctUpdate();
- }
-
- @Test
- public void iconValidationTest5() throws Exception {
- updatedServiceDetails.setIcon("Test_name");
- correctUpdate();
- }
-
- @Test
- public void iconValidationTest6() throws Exception {
- updatedServiceDetails.setIcon("Test-name");
- correctUpdate();
- }
-
- @Test
- public void iconValidationTest7() throws Exception {
- updatedServiceDetails.setIcon("Testname1234567890");
- correctUpdate();
- }
-
- @Test
- public void iconValidationTest8() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKIN);
- updatedServiceDetails.setIcon("TestNamE");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void iconValidationTest9() throws Exception {
- // addMandatoryArtifactsToService();
- LifecycleRestUtils.certifyService(serviceDetails);
- updatedServiceDetails.setIcon("testnamename");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- // ------------------------------------------invalid
- // values------------------------------------------
- @Test
- public void iconValidationTest10() throws Exception {
- updatedServiceDetails.setIcon("Test name");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_ICON, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void iconValidationTest11() throws Exception {
- updatedServiceDetails.setIcon(StringUtils.SPACE); // one space with
- // nothing
- updateWithInvalidValue(ActionStatus.COMPONENT_MISSING_ICON, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void iconValidationTest12() throws Exception {
- updatedServiceDetails.setIcon("Test.name");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_ICON, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void iconValidationTest13() throws Exception {
- specialCharsChecking("icon");
- charactersInRangeChecking(46, 46, "icon");
- }
-
- @Test
- public void iconValidationTest14() throws Exception {
- updatedServiceDetails.setIcon(multipleString("c", 26));
- updateWithInvalidValue(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT,
- new ArrayList<>(Arrays.asList("Service", "25")));
- }
-
- @Test
- public void iconValidationTest15() throws Exception {
- // addMandatoryArtifactsToService();
- RestResponse certifyServiceResp = LifecycleRestUtils.certifyService(serviceDetails);
- Service certifyServiceServ = ResponseParser
- .convertServiceResponseToJavaObject(certifyServiceResp.getResponse());
- ServiceReqDetails certifyService = new ServiceReqDetails(certifyServiceServ);
- updatedServiceDetails = new ServiceReqDetails(certifyService);
- updatedServiceDetails.setIcon("testnamename");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void iconValidationTest16() throws Exception {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKOUT);
- updatedServiceDetails = new ServiceReqDetails(serviceDetails);
- updatedServiceDetails.setIcon("TestNamE");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.SERVICE_ICON_CANNOT_BE_CHANGED, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void iconValidationTest17() throws Exception {
- updatedServiceDetails.setIcon(" Icon ");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_ICON, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void categoryValidationTest1() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKIN);
- updatedServiceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void categoryValidationTest2() throws Exception {
- // updatedServiceDetails.addCategory("someCategory");
- updatedServiceDetails.setCategories(null);
- updatedServiceDetails.addCategoryChain("someCategory", null);
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CATEGORY, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void categoryValidationTest3() throws Exception {
- updatedServiceDetails.setCategories(null);
- updatedServiceDetails.addCategoryChain("SomeCategory10", null);
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CATEGORY, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void categoryValidationTest4() throws Exception {
- updatedServiceDetails.setCategories(null);
- updatedServiceDetails.addCategoryChain("some Category", null);
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_CATEGORY, new ArrayList<>(Arrays.asList("Service")));
- }
-
- @Test
- public void categoryValidationTest5() throws Exception {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
- updatedServiceDetails = new ServiceReqDetails(serviceDetails);
- updatedServiceDetails.addCategory("Network L1-3");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void categoryValidationTest6() throws Exception {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKOUT);
- updatedServiceDetails = new ServiceReqDetails(serviceDetails);
- updatedServiceDetails = serviceDetails;
- List<CategoryDefinition> categories = updatedServiceDetails.getCategories();
- CategoryDefinition categoryDefinition = categories.get(0);
- CategoryDefinition categoryDefinition2 = categoryDefinition;
- categoryDefinition2.setName("ccc");
- categories.set(0, categoryDefinition2);
- updatedServiceDetails.setCategories(categories);
- RestResponse updateServiceResponse2 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- validateResponse(updateServiceResponse2, 400, ActionStatus.SERVICE_CATEGORY_CANNOT_BE_CHANGED, listForMessage);
- getServiceAndValidate(serviceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void categoryValidationTest7() throws Exception {
- updatedServiceDetails.removeAllCategories();
- updatedServiceDetails.addCategory(ServiceCategoriesEnum.NETWORK_L3.getValue());
- correctUpdate();
- }
-
- @Test
- public void categoryValidationTest8() throws Exception {
- updatedServiceDetails.setCategories(null);
- updatedServiceDetails.addCategoryChain("Network L1-3", null);
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest1() throws Exception {
- updatedServiceDetails
- .setTags(new ArrayList<>(Arrays.asList(multipleString("a", 49), updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest2() throws Exception {
- updatedServiceDetails
- .setTags(new ArrayList<>(Arrays.asList(multipleString("B", 50), updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest3() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(
- Arrays.asList(multipleString("A", 50), multipleString("B", 50), updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest5() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("testTaG", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest6() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("Testtag", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest7() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("Test_tag", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest8() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("Test tag", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest9() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("Test-tag", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest10() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("Test.tag", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest11() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("...1...", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest12() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("-a_1. Arrrrrr", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest13() throws Exception {
- updatedServiceDetails
- .setTags(new ArrayList<>(Arrays.asList("Testtag1234567890", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest14() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("1", "2", "2", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest15() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKIN);
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("TestTaG", updatedServiceDetails.getName())));
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void tagsValidationTest16() throws Exception {
- // addMandatoryArtifactsToService();
- LifecycleRestUtils.certifyService(serviceDetails);
- updatedServiceDetails = new ServiceReqDetails(serviceDetails);
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("testtagtag", updatedServiceDetails.getName())));
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- checkErrorResponse(ActionStatus.RESTRICTED_OPERATION, listForMessage, updateServiceResponse);
- }
-
- @Test
- public void tagsValidationTest17() throws Exception {
- // addMandatoryArtifactsToService();
- certifyService(serviceDetails, serviceDetails.getVersion());
- LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, serviceDetails.getVersion(),
- LifeCycleStatesEnum.CHECKOUT);
- updatedServiceDetails = new ServiceReqDetails(serviceDetails);
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList("TestTaG", updatedServiceDetails.getName())));
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest18() throws Exception {
- int lengthOfServiceName = updatedServiceDetails.getName().length();
- int maxLengthTag = 50;
- int tagsCount = 1024 - lengthOfServiceName;
- ArrayList<String> tagsList = new ArrayList<>();
- tagsList.add(updatedServiceDetails.getName());
- while (tagsCount > maxLengthTag) {
- tagsList.add(multipleString("a", maxLengthTag));
- tagsCount -= maxLengthTag + 1
- + 1/* (50 and comma of each tag + one space, totally 52) */;
- }
- tagsList.add(multipleString("a", tagsCount));
- updatedServiceDetails.setTags(tagsList);
- correctUpdate();
- }
-
- @Test
- public void tagsValidationTest19() throws Exception {
- updatedServiceDetails.setTags(new ArrayList<>(Arrays.asList(" Tag ", updatedServiceDetails.getName())));
- RestResponse updateServiceResponse1 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse1);
- assertNotNull(updateServiceResponse1.getErrorCode());
- assertEquals(200, updateServiceResponse1.getErrorCode().intValue());
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse1);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void tagsValidationTest20() throws Exception {
- ArrayList<String> tagsList = new ArrayList<>();
- tagsList.add(updatedServiceDetails.getName());
- tagsList.add("");
- updatedServiceDetails.setTags(tagsList);
- updateWithInvalidValue(ActionStatus.INVALID_FIELD_FORMAT, Arrays.asList("Service", "tag"));
- }
-
- // ------------------------------------------invalid
- // values------------------------------------------
-
- @Test
- public void tagsValidationTest21() throws Exception {
- ArrayList<String> tagsList = new ArrayList<>();
- tagsList.add("onetag");
- updatedServiceDetails.setTags(tagsList);
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME, listForMessage);
-
- }
-
- @Test
- public void tagsValidationTest22() throws Exception {
- specialCharsChecking("tags");
- }
-
- @Test
- public void descriptionValidationTest1() throws Exception {
- updatedServiceDetails.setDescription(multipleString("a", 1023));
- correctUpdate();
- }
-
- @Test
- public void descriptionValidationTest2() throws Exception {
- updatedServiceDetails.setDescription(multipleString("a", 1024));
- correctUpdate();
- }
-
- @Test
- public void descriptionValidationTest3() throws Exception {
- updatedServiceDetails.setDescription(multipleString("aB", 1024 / 2));
- correctUpdate();
- }
-
- @Test
- public void descriptionValidationTest4() throws Exception {
- updatedServiceDetails.setDescription("1234567890");
- correctUpdate();
- }
-
- @Test
- public void descriptionValidationTest5() throws Exception {
- updatedServiceDetails.setDescription("desc ription");
- correctUpdate();
- }
-
- @Test
- public void descriptionValidationTest6() throws Exception {
- updatedServiceDetails.setDescription("desc\tription");
- RestResponse updateServiceResponse1 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse1);
- assertNotNull(updateServiceResponse1.getErrorCode());
- assertEquals(200, updateServiceResponse1.getErrorCode().intValue());
- updatedServiceDetails.setDescription("desc ription");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse1);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void descriptionValidationTest7() throws Exception {
- updatedServiceDetails.setDescription("desc ription ");
- RestResponse updateServiceResponse2 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse2);
- assertNotNull(updateServiceResponse2.getErrorCode());
- assertEquals(200, updateServiceResponse2.getErrorCode().intValue());
- updatedServiceDetails.setDescription("desc ription");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse2);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void descriptionValidationTest8() throws Exception {
- updatedServiceDetails.setDescription("desc" + StringUtils.LF + "ription");
- RestResponse updateServiceResponse3 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse3);
- assertNotNull(updateServiceResponse3.getErrorCode());
- assertEquals(200, updateServiceResponse3.getErrorCode().intValue());
- updatedServiceDetails.setDescription("desc ription");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse3);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void descriptionValidationTest9() throws Exception {
- updatedServiceDetails.setDescription("<html>Hello, <b>world!</b></html>");
- RestResponse updateServiceResponse4 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse4);
- assertNotNull(updateServiceResponse4.getErrorCode());
- assertEquals(200, updateServiceResponse4.getErrorCode().intValue());
- updatedServiceDetails.setDescription("Hello, world!");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse4);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void descriptionValidationTest10() throws Exception {
- updatedServiceDetails.setDescription("\uC2B5");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_DESCRIPTION, new ArrayList<>(Arrays.asList("Service")));
-
- }
-
- @Test
- public void descriptionValidationTest10_a() throws Exception {
- updatedServiceDetails.setDescription("æ–‡");
- updateWithInvalidValue(ActionStatus.COMPONENT_INVALID_DESCRIPTION, new ArrayList<>(Arrays.asList("Service")));
-
- }
-
- @Test
- public void descriptionValidationTest10_b() throws Exception {
- updatedServiceDetails.setDescription("\uC2B5abc");
- RestResponse updateServiceResponse5 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse5);
- assertNotNull(updateServiceResponse5.getErrorCode());
- assertEquals(200, updateServiceResponse5.getErrorCode().intValue());
- updatedServiceDetails.setDescription("abc");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse5);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-
- }
-
- @Test
- public void descriptionValidationTest11() throws Exception {
- updatedServiceDetails.setDescription("&<>");
- RestResponse updateServiceResponse6 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse6);
- assertNotNull(updateServiceResponse6.getErrorCode());
- assertEquals(200, updateServiceResponse6.getErrorCode().intValue());
- updatedServiceDetails.setDescription("&amp;&lt;&gt;");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse6);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void descriptionValidationTest12() throws Exception {
- updatedServiceDetails.setDescription("æ–‡ test");
- RestResponse updateServiceResponse7 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse7);
- assertNotNull(updateServiceResponse7.getErrorCode());
- assertEquals(200, updateServiceResponse7.getErrorCode().intValue());
- updatedServiceDetails.setDescription("test");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse7);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void descriptionValidationTest13() throws Exception {
- updatedServiceDetails.setDescription(" description");
- RestResponse updateServiceResponse8 = ServiceRestUtils.updateService(updatedServiceDetails,
- sdncDesignerDetails);
- assertNotNull(updateServiceResponse8);
- assertNotNull(updateServiceResponse8.getErrorCode());
- assertEquals(200, updateServiceResponse8.getErrorCode().intValue());
- updatedServiceDetails.setDescription("description");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse8);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- }
-
- @Test
- public void descriptionValidationTest14() throws Exception {
- updatedServiceDetails.setDescription(multipleString("a", 1025));
- updateWithInvalidValue(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
- new ArrayList<>(Arrays.asList("Service", "1024")));
- }
-
- @Test
- public void projectCodeValidationTest1() throws Exception {
- String desc = StringUtils.EMPTY;
- for (int i = 0; i < 10; i++) {
- desc += Integer.toString(i);
- if (i >= 4) {
- updatedServiceDetails.setProjectCode(desc);
- correctUpdate();
- }
- }
- }
-
- @Test
- public void projectCodeValidationTest2() throws Exception {
- updatedServiceDetails.setProjectCode(multipleString("1", 6));
- correctUpdate();
- }
-
- @Test
- public void projectCodeValidationTest3() throws Exception {
- this.specialCharsChecking("projectCode");
- }
-
- // TODO Irrelevant
- @Test(enabled = false)
- public void projectCodeValidationTest4() throws Exception {
- updatedServiceDetails.setProjectCode(multipleString(" ", 5) + "99999");
- RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, sdncDesignerDetails);
- assertNotNull(updateServiceResponse);
- assertNotNull(updateServiceResponse.getErrorCode());
- assertEquals(200, updateServiceResponse.getErrorCode().intValue());
- updatedServiceDetails.setProjectCode("12345");
- validateActualVsExpected(updatedServiceDetails, updateServiceResponse);
- getServiceAndValidate(updatedServiceDetails, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-
- }
-
- @Test
- public void projectCodeValidationTest5() throws Exception {
- updatedServiceDetails.setProjectCode(multipleString("0", 11));
- updateWithInvalidValue(ActionStatus.INVALID_PROJECT_CODE, listForMessage);
- }
-
- @Test
- public void projectCodeValidationTest6() throws Exception {
- updatedServiceDetails.setProjectCode(multipleString("1", 4));
- updateWithInvalidValue(ActionStatus.INVALID_PROJECT_CODE, listForMessage);
- }
-
- @Test
- public void projectCodeValidationTest7() throws Exception {
- updatedServiceDetails.setProjectCode("123456789");
- correctUpdate();
- }
-
- // ////US553874
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion01_isVNF_toTrue() throws Exception{
- //
- // //choose the user to create service
- // User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceRestUtils.constructFieldsForAuditValidation(serviceDetails, "0.1",
- // sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //
- // //Update Service IsVNF to True
- // restResponse =
- // ServiceRestUtils.updateService(serviceDetails.getUniqueId(),
- // serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 200, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // }
- //
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion02_isVNF_toFalse() throws Exception{
- //
- // //choose the user to create service
- // User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceRestUtils.constructFieldsForAuditValidation(serviceDetails, "0.1",
- // sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //
- // //Update Service IsVNF to True
- // restResponse =
- // ServiceRestUtils.updateService(serviceDetails.getUniqueId(),
- // serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 200, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- // }
- //
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion01_isVNF_TrueToNull() throws Exception{
- //
- // //choose the user to create service
- // User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceRestUtils.constructFieldsForAuditValidation(serviceDetails, "0.1",
- // sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //
- // //Update Service IsVNF to True
- // restResponse =
- // ServiceRestUtils.updateService(serviceDetails.getUniqueId(),
- // serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 400, restResponse.getErrorCode().intValue());
- // List<String> variables = Arrays.asList("VNF Service Indicator");
- // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_DATA.name(),
- // variables, restResponse.getResponse());
- //
- // //get service and verify that service created with isVNF is remained with
- // isVNF = true
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- // }
- //
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion01_isVNF_FalseToNull() throws Exception{
- //
- // //choose the user to create service
- // User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceRestUtils.constructFieldsForAuditValidation(serviceDetails, "0.1",
- // sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //
- // //Update Service IsVNF to True
- // restResponse =
- // ServiceRestUtils.updateService(serviceDetails.getUniqueId(),
- // serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 400, restResponse.getErrorCode().intValue());
- // List<String> variables = Arrays.asList("VNF Service Indicator");
- // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_DATA.name(),
- // variables, restResponse.getResponse());
- //
- // //get service and verify that service created with isVNF is remained with
- // isVNF = true
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- // }
- //
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion02_IsVNF_toTrue() throws Exception{
- //
- // //choose the user to create service
- // User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // LifecycleRestUtils.changeServiceState(serviceDetails,
- // sdncDesignerDetails, serviceDetails.getVersion(),
- // LifeCycleStatesEnum.CHECKIN);
- // LifecycleRestUtils.changeServiceState(serviceDetails,
- // sdncDesignerDetails, serviceDetails.getVersion(),
- // LifeCycleStatesEnum.CHECKOUT);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceRestUtils.constructFieldsForAuditValidation(serviceDetails, "0.1",
- // sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //
- // //Update Service IsVNF to True
- // restResponse =
- // ServiceRestUtils.updateService(serviceDetails.getUniqueId(),
- // serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 200, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // }
- //
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion02_IsVNF_toFalse() throws Exception{
- //
- // //choose the user to create service
- // User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // LifecycleRestUtils.changeServiceState(serviceDetails,
- // sdncDesignerDetails, serviceDetails.getVersion(),
- // LifeCycleStatesEnum.CHECKIN);
- // LifecycleRestUtils.changeServiceState(serviceDetails,
- // sdncDesignerDetails, serviceDetails.getVersion(),
- // LifeCycleStatesEnum.CHECKOUT);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceRestUtils.constructFieldsForAuditValidation(serviceDetails, "0.1",
- // sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //
- // //Update Service IsVNF to false
- // restResponse =
- // ServiceRestUtils.updateService(serviceDetails.getUniqueId(),
- // serviceDetails, sdncUserDetails);
- // //restResponse =
- // ServiceRestUtils.updateService(serviceDetails.getUniqueId(),
- // serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 200, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // }
- //
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion11_IsVNF_toFalse() throws Exception{
- // // Can't update isVNF when service version is 1.X
- // User sdncUserDetails =
- // ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- // //String serviceUniqueName =
- // ServiceRestUtils.getServiceUniqueId(serviceByNameAndVersion);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceRestUtils.constructFieldsForAuditValidation(serviceDetails, "0.1",
- // sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //// ServiceRestUtils.addServiceMandatoryArtifacts(sdncUserDetails,
- // restResponse);
- // RestResponse response =
- // ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails,
- // sdncUserDetails, serviceDetails.getUniqueId(),
- // ComponentTypeEnum.SERVICE);
- // assertTrue("response code is not 201, returned: " +
- // response.getErrorCode(),response.getErrorCode() == 201);
- // RestResponse changeServiceState =
- // LCSbaseTest.certifyService(serviceDetails, sdncDesignerDetails);
- // assertTrue("certify service request returned status:" +
- // changeServiceState.getErrorCode(),changeServiceState.getErrorCode() ==
- // 200);
- // LifecycleRestUtils.changeServiceState(serviceDetails, sdncUserDetails,
- // LifeCycleStatesEnum.CHECKOUT);
- //
- // //Update Service IsVNF to false
- // restResponse = ServiceRestUtils.updateService(serviceDetails,
- // sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating service metadata", 400,
- // restResponse.getErrorCode().intValue());
- // List<String> variables = new ArrayList<String>();
- // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_IS_VNF_CANNOT_BE_CHANGED.name(),
- // variables, restResponse.getResponse());
- //
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "1.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- //
- // }
- //
- // @JsonIgnore
- // @Test
- // public void UpdateServiceVersion11_IsVNF_toTrue() throws Exception{
- // // Can't update isVNF when service version is 1.X
- // User sdncUserDetails =
- // ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- // // new service details
- // // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService();
- // // clean audit DB before updating service
- // DbUtils.cleanAllAudits();
- // ServiceRestUtils.deleteServiceById(serviceDetails.getUniqueId(),
- // sdncUserDetails.getUserId());
- // serviceDetails = ElementFactory.getDefaultService();
- //
- // //send create service toward BE
- // RestResponse restResponse =
- // ServiceRestUtils.createService(serviceDetails, sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating Interface Artifact",
- // 201, restResponse.getErrorCode().intValue());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // RestResponse serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "0.1");
- // Service serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- // //String serviceUniqueName =
- // ServiceRestUtils.getServiceUniqueId(serviceByNameAndVersion);
- //
- // //validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // ServiceValidationUtils.constructFieldsForAuditValidation(serviceDetails,
- // "0.1", sdncUserDetails);
- // String auditAction="Create";
- // expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setPrevVersion("");
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setStatus("201");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- //
- //// ServiceRestUtils.addServiceMandatoryArtifacts(sdncUserDetails,
- // restResponse);
- // RestResponse response =
- // ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails,
- // sdncUserDetails, serviceDetails.getUniqueId(),
- // ComponentTypeEnum.SERVICE);
- // assertTrue("response code is not 201, returned: " +
- // response.getErrorCode(),response.getErrorCode() == 201);
- // RestResponse changeServiceState =
- // LCSbaseTest.certifyService(serviceDetails, sdncDesignerDetails);
- // assertTrue("certify service request returned status:" +
- // changeServiceState.getErrorCode(),changeServiceState.getErrorCode() ==
- // 200);
- // LifecycleRestUtils.changeServiceState(serviceDetails, sdncUserDetails,
- // LifeCycleStatesEnum.CHECKOUT);
- //
- // //Update Service IsVNF to false
- // restResponse = ServiceRestUtils.updateService(serviceDetails,
- // sdncUserDetails);
- // assertNotNull("check error code exists in response after create service",
- // restResponse.getErrorCode());
- // assertEquals("Check response code after updating service metadata", 400,
- // restResponse.getErrorCode().intValue());
- // List<String> variables = new ArrayList<String>();
- // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_IS_VNF_CANNOT_BE_CHANGED.name(),
- // variables, restResponse.getResponse());
- //
- // //get service and verify that service created with isVNF defined in
- // serviceDetails
- // serviceByNameAndVersion =
- // ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails,
- // serviceDetails.getName(), "1.1");
- // serviceObject =
- // ResponseParser.convertServiceResponseToJavaObject(serviceByNameAndVersion.getResponse());
- // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails,
- // serviceObject, sdncUserDetails,
- // LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- // }
-
-}
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
deleted file mode 100644
index d509966490..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java
+++ /dev/null
@@ -1,1693 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.user;
-
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedUserCRUDAudit;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-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.UserRestUtils;
-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.UserValidationUtils;
-import org.testng.AssertJUnit;
-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;
- protected User sdncDesignerUser;
- protected User sdncGovernorUser;
- protected User sdncTesterUser;
-
- public static final int STATUS_CODE_SUCCESS = 200;
- public static final int STATUS_CODE_SUCSESS_CREATED = 201;
- public static final int STATUS_CODE_SUCCESS_DELETE_GET = 200;
- public static final int STATUS_CODE_INVALID_CONTENT = 400;
- public static final int STATUS_CODE_MISSING_DATA = 400;
- public static final int STATUS_CODE_MISSING_INFORMATION = 403;
- public static final int STATUS_CODE_RESTRICTED_ACCESS = 403;
- public static final int STATUS_CODE_NOT_FOUND = 404;
- public static final int STATUS_CODE_RESTRICTED_OPERATION = 409;
- public static final int USER_ALREADY_EXIST = 409;
- public static final int INVALID_ROLE = 400;
-
- @Rule
- public static TestName name = new TestName();
-
- public CreateUserApiTest() {
- super(name, CreateUserApiTest.class.getName());
- }
-
- @BeforeMethod
- public void init() {
- sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncDesignerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- sdncGovernorUser = ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR);
- sdncTesterUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
-
- }
-
- // Story : REST API to provision new user (POST) - US429379
- // must parameters: UserId and Email
-
- // **********************************************************201***************************************************
- // create user with full parameter set(UserID, First Name, Last Name, Email,
- // Role = "DESIGNER", Creator details)
- // expected 201 Created
- @Test
- public void createUser() throws Exception {
-
- // user initialization
- String httpCspUserId = "km2000";
- String userFirstName = "Kot";
- String userLastName = "Matroskin";
- String email = "km2000@intl.sdc.com";
- String role = "ADMIN";
- User sdncUserDetails = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- String addUser = "AddUser";
- UserRestUtils.deleteUser(sdncUserDetails, sdncAdminUser, true);
- DbUtils.cleanAllAudits();
- RestResponse createUserResponse = UserRestUtils.createUser(sdncUserDetails, sdncAdminUser);
-
- AssertJUnit.assertNotNull("check response object is not null after create user", createUserResponse);
- AssertJUnit.assertNotNull("check error code exists in response after create user",
- createUserResponse.getErrorCode());
- AssertJUnit.assertEquals("Check response code after create user", 201,
- createUserResponse.getErrorCode().intValue());
-
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, createUserResponse.getResponse());
-
- ExpectedUserCRUDAudit constructFieldsForAuditValidation = Convertor.constructFieldsForAuditValidation(addUser,
- sdncAdminUser, ActionStatus.CREATED, sdncUserDetails, null);
- AuditValidationUtils.validateAddUserAudit(constructFieldsForAuditValidation, addUser);
- RestResponse getUserResponse = UserRestUtils.getUser(sdncUserDetails, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, getUserResponse.getResponse());
- }
-
- protected static final String ADD_USER = "AddUser";
-
- private User mechIdUser = new User();
- private User emptyUser = new User();
- private static final User adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- @AfterMethod
- public void setup() throws IOException {
- UserRestUtils.deactivateUser(mechIdUser, adminUser);
- }
-
- // create default user(UserID, Email, Creator details)
- // expected: role = DESIGNER, first and last name = null, 201 Created
- @Test
- public void createDefaultUser() throws Exception {
- // user initialization
- String httpCspUserId = "km2000";
- String userFirstName = null;
- String userLastName = null;
- String email = null;
- String role = null;
- User sdncUserDetails = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
-
- deleteUserAndAudit(sdncUserDetails);
- RestResponse createUserResponse = UserRestUtils.createUser(sdncUserDetails, sdncAdminUser);
-
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
-
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, createUserResponse.getResponse());
- UserValidationUtils.validateAddUserAuditMessage(sdncUserDetails, sdncAdminUser, "201",
- UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- RestResponse getUserResponse = UserRestUtils.getUser(sdncUserDetails, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, getUserResponse.getResponse());
-
- }
-
- // create user with one optional parameter first name (UserID, Email, First
- // Name, Creator details)
- // expected: role = DESIGNER, last name = null, 201 Created
- @Test
- public void createUserFirstName() throws Exception {
- // user initialization
- String httpCspUserId = "km2000";
- String userFirstName = "Kot";
- String userLastName = null;
- String email = null;
- String role = null;
- User sdncUserDetails = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
-
- deleteUserAndAudit(sdncUserDetails);
- RestResponse createUserResponse = UserRestUtils.createUser(sdncUserDetails, sdncAdminUser);
-
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
-
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, createUserResponse.getResponse());
- UserValidationUtils.validateAddUserAuditMessage(sdncUserDetails, sdncAdminUser, "201",
- UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- RestResponse getUserResponse = UserRestUtils.getUser(sdncUserDetails, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, getUserResponse.getResponse());
- }
-
- @Test
- public void createDeleteOpsUser() throws Exception {
-
- String httpCspUserId = "oo2000";
- String userFirstName = "ops";
- String userLastName = "opsLast";
- String email = "ops@intl.sdc.com";
- String role = "OPS";
- User sdncUserDetails = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
-
- deleteUserAndAudit(sdncUserDetails);
- RestResponse createUserResponse = UserRestUtils.createUser(sdncUserDetails, sdncAdminUser);
-
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
-
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, createUserResponse.getResponse());
- UserValidationUtils.validateAddUserAuditMessage(sdncUserDetails, sdncAdminUser, "201",
- UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- RestResponse getUserResponse = UserRestUtils.getUser(sdncUserDetails, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, getUserResponse.getResponse());
-
- UserRestUtils.deleteUser(sdncUserDetails, sdncAdminUser, true);
- RestResponse getDeletedUserResponse = UserRestUtils.getUser(sdncUserDetails, sdncAdminUser);
- assertEquals("Check response code after delete user", 404, getDeletedUserResponse.getErrorCode().intValue());
-
- }
-
- @Test
- public void createDeleteGOVERNORUser() throws Exception {
-
- String httpCspUserId = "gg2000";
- String userFirstName = "gov";
- String userLastName = "govLast";
- String email = "gov@intl.sdc.com";
- String role = "GOVERNOR";
- User sdncUserDetails = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
-
- deleteUserAndAudit(sdncUserDetails);
- RestResponse createUserResponse = UserRestUtils.createUser(sdncUserDetails, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
-
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, createUserResponse.getResponse());
- UserValidationUtils.validateAddUserAuditMessage(sdncUserDetails, sdncAdminUser, "201",
- UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- RestResponse getUserResponse = UserRestUtils.getUser(sdncUserDetails, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(sdncUserDetails, getUserResponse.getResponse());
-
- UserRestUtils.deleteUser(sdncUserDetails, sdncAdminUser, true);
- RestResponse getDeletedUserResponse = UserRestUtils.getUser(sdncUserDetails, sdncAdminUser);
- assertEquals("Check response code after delete user", 404, getDeletedUserResponse.getErrorCode().intValue());
-
- }
-
- // Benny
- // Admin Create OPS user
- @Test
- public void createOpsUser() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "aa1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- User expectedOpsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedOpsUser);
- RestResponse createUserResponse = UserRestUtils.createUser(expectedOpsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedOpsUser, createUserResponse.getResponse());
- deleteAndCheckUserResponse(expectedOpsUser, 200);
-
- }
-
- // Admin Create GOVERNOR user
- @Test
- public void createGovernorUser() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "aa1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- User expectedUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedUser);
- RestResponse createUserResponse = UserRestUtils.createUser(expectedUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedUser, createUserResponse.getResponse());
- RestResponse getUserResponse = UserRestUtils.getUser(expectedUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedUser, getUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(expectedUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from OPS to GOVERNOR
- @Test
- public void updateOpsUserRole() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ab1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- String updatedRole = "GOVERNOR";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User governerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
-
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(governerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(governerUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Designer Create OPS user -409 Response Restricted operation
- @Test
- public void createOpsUserByDesigner() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "aa1122";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- User expectedOpsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedOpsUser);
- RestResponse createUserResponse = UserRestUtils.createUser(expectedOpsUser, sdncDesignerUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 409, createUserResponse.getErrorCode().intValue());
- assertEquals("Check response code after create user", "Conflict", createUserResponse.getResponseMessage());
- }
-
- // Tester Create OPS user -409 Response Restricted operation
- @Test
- public void createOpsUserByTester() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "aa1122";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- User expectedOpsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedOpsUser);
- RestResponse createUserResponse = UserRestUtils.createUser(expectedOpsUser, sdncTesterUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 409, createUserResponse.getErrorCode().intValue());
- assertEquals("Check response code after create user", "Conflict", createUserResponse.getResponseMessage());
- }
-
- // Designer Try Update OPS user role to GOVERNOR - Response 409
- @Test
- public void updateOpsUserRolebyDesigner() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "bt751e";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- String updatedRole = "GOVERNOR";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User governerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // Admin create user with OPS role
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // Designer user try to update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncDesignerUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 409, updateUserRoleResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating user", "Conflict",
- updateUserRoleResponse.getResponseMessage());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Tester Try Update OPS user role to GOVERNOR - Response 409
- @Test
- public void updateOpsUserRolebyTester() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "bt751w";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- String updatedRole = "GOVERNOR";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User governerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // Admin create user with OPS role
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // Designer user try to update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncTesterUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 409, updateUserRoleResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating user", "Conflict",
- updateUserRoleResponse.getResponseMessage());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from OPS to Designer
- @Test
- public void updateOpsUserRoleFromOpsToDesigner() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ab1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- String updatedRole = "DESIGNER";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User designerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
-
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(designerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(designerUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from OPS to TESTER
- @Test
- public void updateOpsUserRoleFromOpsToTester() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ac1001";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- String updatedRole = "TESTER";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User testerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
-
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(testerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(testerUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Tester try to Update user role from OPS to GOVERNOR - Response 409
- // Conflict
- @Test
- public void updateOpsUserRoleByTester() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ad1001";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- String updatedRole = "GOVERNOR";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User governerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- // Create user by Admin
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR by Tester
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncTesterUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 409, updateUserRoleResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating user", "Conflict",
- updateUserRoleResponse.getResponseMessage());
-
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Designer try to Update user role from OPS to GOVERNOR - Response 409
- // Conflict
- @Test
- public void updateOpsUserRoleByDesigner() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ad1001";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- String updatedRole = "GOVERNOR";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- // User governerUser = new User(userFirstName,
- // userLastName,httpCspUserId, email, updatedRole);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- // Create user by Admin
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR by Tester
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncDesignerUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 409, updateUserRoleResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating user", "Conflict",
- updateUserRoleResponse.getResponseMessage());
-
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Create OPS user - user already exist
- @Test
- public void createOpsUserAlreadyExist() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "af1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "OPS";
- User expectedOpsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedOpsUser);
- RestResponse createUserResponse = UserRestUtils.createUser(expectedOpsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedOpsUser, createUserResponse.getResponse());
- // Create user that already exists
- RestResponse createUserAgainResponse = UserRestUtils.createUser(expectedOpsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserAgainResponse);
- assertNotNull("check error code exists in response after create user", createUserAgainResponse.getErrorCode());
- assertEquals("Check response code after create user", 409, createUserAgainResponse.getErrorCode().intValue());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(expectedOpsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from OPS to GOVERNOR - user already has GOVERNOR
- // role
- @Test
- public void updateRoleToSameRole() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ag1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- String updatedRole = "GOVERNOR";
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User governerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- RestResponse createUserResponse = UserRestUtils.createUser(opsUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, createUserResponse.getResponse());
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from GOVERNOR to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- opsUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(governerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(governerUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from Tester to GOVERNOR - 200 response
-
- // Admin Update user role from Designer to GOVERNOR - 200 response
- @Test
- public void updateUserRoleDesignerToGovernor() throws Exception {
- DbUtils.cleanAllAudits();
- String httpCspUserId = "ah1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "DESIGNER";
- String updatedRole = "GOVERNOR";
- User designerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User governerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(designerUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(designerUser, createUserResponse.getResponse());
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from TESTER to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- designerUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
- // Update user role
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(governerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(governerUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(designerUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update deactivated user role - response 404 (user not found)
- @Test
- public void updateRoleToDeactivatedUser() throws Exception {
- DbUtils.cleanAllAudits();
- String httpCspUserId = "aj1001";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "DESIGNER";
- String updatedRole = "GOVERNOR";
- User designerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User governerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(designerUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(designerUser, createUserResponse.getResponse());
- deleteAndCheckUserResponse(designerUser, 200);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role - user deActivted
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- designerUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after create user", 404, updateUserRoleResponse.getErrorCode().intValue());
- }
-
- // Admin Update user role, user does not exist in DB - response 404 (user
- // not found)
- @Test
- public void updateRoleForNonExistingUser() throws Exception {
- DbUtils.cleanAllAudits();
- String httpCspUserId = "aj1001";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "DESIGNER";
- String updatedRole = "GOVERNOR";
- User designerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- // User governerUser = new User(userFirstName,
- // userLastName,httpCspUserId, email, updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role - user deActivted
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- designerUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 404, updateUserRoleResponse.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from GOVERNOR to TESTER
- @Test
- public void updateRoleFromGovernorToTester() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ak1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- String updatedRole = "TESTER";
- User governorUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User testerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(governorUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(governorUser, createUserResponse.getResponse());
-
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- governorUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(testerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(testerUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(governorUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from GOVERNOR to DESIGNER
- @Test
- public void updateRoleFromGovernorToDesigner() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ak1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- String updatedRole = "DESIGNER";
- User governorUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User designerUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(governorUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(governorUser, createUserResponse.getResponse());
-
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- governorUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(designerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(designerUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(governorUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role from GOVERNOR to OPS
- @Test
- public void updateRoleFromGovernorToOps() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ak1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- String updatedRole = "OPS";
- User governorUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User opsUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(governorUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(governorUser, createUserResponse.getResponse());
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- governorUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(opsUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(opsUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- deleteAndCheckUserResponse(governorUser, 200);
-
- }
-
- private void deleteAndCheckUserResponse(User userDetailes, int expectedResponseCode) throws IOException {
- RestResponse deleteUser = UserRestUtils.deleteUser(sdncGovernorUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteUser);
- assertEquals("Check response code after deleting user", expectedResponseCode,
- deleteUser.getErrorCode().intValue());
- }
-
- // Admin Update user role from GOVERNOR to ADMIN
- @Test
- public void updateRoleFromGovernorToAdmin() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ak1000";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- String updatedRole = "ADMIN";
- User governorUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User adminUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(governorUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(governorUser, createUserResponse.getResponse());
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- governorUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 200, updateUserRoleResponse.getErrorCode().intValue());
-
- RestResponse getUpdatedRoleUserResponse = UserRestUtils.getUser(adminUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(adminUser, getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(governorUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role to non existing role - Response 400 Bad Request
- @Test
- public void updateRoleToNonExistingRole() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "al1001";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- String updatedRole = "VVVVVVV";
- User governorUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User newUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(governorUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(governorUser, createUserResponse.getResponse());
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role from OPS to GOVERNOR
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- governorUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 400, updateUserRoleResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating user", "Bad Request",
- updateUserRoleResponse.getResponseMessage());
-
- // RestResponse getUpdatedRoleUserResponse =
- // UserRestUtils.getUser(adminUser,sdncAdminUser);
- // UserValidationUtils.validateUserDetailsOnResponse(adminUser,getUpdatedRoleUserResponse.getResponse());
- // Delete OPS user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(governorUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // Admin Update user role to null - Response 400 Bad Request
- @Test
- public void updateRoleToNull() throws Exception {
- DbUtils.cleanAllAudits();
-
- String httpCspUserId = "ax1001";
- String userFirstName = "Benny";
- String userLastName = "Tal";
- String email = "optBenny@intl.sdc.com";
- String role = "GOVERNOR";
- String updatedRole = "";
- User governorUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- User newUser = new User(userFirstName, userLastName, httpCspUserId, email, updatedRole, null);
- // UserRestUtils.deleteUser(opsUser, sdncAdminUser, true);
- // UserRestUtils.deleteUser(UserUpdateRole, sdncAdminUser);
- RestResponse createUserResponse = UserRestUtils.createUser(governorUser, sdncAdminUser);
- assertNotNull("check response object is not null after create user", createUserResponse);
- assertNotNull("check error code exists in response after create user", createUserResponse.getErrorCode());
- assertEquals("Check response code after create user", 201, createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(governorUser, createUserResponse.getResponse());
- // opsUser.setRole(updatedRole);
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // update user role
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- governorUser.getUserId());
- assertNotNull("check response object is not null after updating user", updateUserRoleResponse);
- assertNotNull("check error code exists in response after updating user", updateUserRoleResponse.getErrorCode());
- assertEquals("Check response code after updating user", 400, updateUserRoleResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating user", "Bad Request",
- updateUserRoleResponse.getResponseMessage());
- // Delete user
- RestResponse deleteOpsUser = UserRestUtils.deleteUser(governorUser, sdncAdminUser, true);
- assertNotNull("check response object is not null after deleting user", deleteOpsUser);
- assertEquals("Check response code after deleting user", 200, deleteOpsUser.getErrorCode().intValue());
-
- }
-
- // create user with one optional parameter last name (UserID, Email, Last
- // Name, Creator details)
- // expected: role = DESIGNER, first name = null, 201 Created
- // @Test
- // public void createUserLastName(){
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // // create user with one optional parameter role name (UserID, Email, Role
- // = "TESTER", Creator details)
- // // expected: first and last name = null, 201 Created
- // @Test
- // public void createUserRoleName(){
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // // create user with two optional parameters first name and role (UserID,
- // Email, First Name, Role = "ADMIN", Creator details)
- // // expected: last name = null, 201 Created
- // @Test
- // public void createUserFirstNameAndRole(){
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // // create user with two optional parameters first and last name(UserID,
- // Email, First Name, Last name, Creator details)
- // // expected: role = DESIGNER, 201 Created
- // @Test
- // public void createUserFirstAndLastName(){
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- //
- //
- //
- // //
- // **********************************************************Create*user*failed***************************************************
- //
- // //
- // **********************************************************403***************************************************
- // // create default user without creator details (UserID, Email)
- // // expected: 403 Forbidden, error message:"Error : Missing information"
- // @Test
- // public void createDefaultUserNonCreatorDetails(){
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // // create user with part of creator details (UserID, Email, First name,
- // Last Name, Role, Part of creator details)
- // // expected: 403 Forbidden, error message:"Error : Missing information"
- // @Test
- // public void createUserPartOfCreatorDetails(){
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // // create user with full parameter set, non admin creator(UserID, First
- // Name, Last Name, Email, Role, Creator details)
- // // expected: 403 Forbidden, error message:
- // "Error : Restricted operation"
- // @Test
- // public void createUserNonAdminCreator(){
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // //
- // **********************************************************405***************************************************
- //
- // // create user with full parameter set by sending http PUT request
- // (UserID, First Name, Last Name, Email, Role, Creator details)
- // // expected: 405 not Allowed, error message:
- // "Error : Method not allowed"
- // @Test
- // public void createUserPutRequest(){
- // // send PUT create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // // create default user by sending http PUT request (UserID, Email,
- // Creator details)
- // // expected: 405 not Allowed, error message:
- // "Error : Method not allowed"
- // @Test
- // public void createDefaultUserPutRequest(){
- // // send PUT create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // // create user with full parameter set by sending http DELETE request
- // (UserID, First Name, Last Name, Email, Role, Creator details)
- // // expected: 405 not Allowed, error message:
- // "Error : Method not allowed"
- // @Test
- // public void createUserDeleteRequest(){
- // // send DELETE create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // // create default user by sending http DELETE request (UserID, Email,
- // Creator details)
- // // expected: 405 not Allowed, error message:
- // "Error : Method not allowed"
- // @Test
- // public void createDefaultUserDeleteRequest(){
- // // send DELETE create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // // create user with full parameter set by sending http GET request
- // (UserID, First Name, Last Name, Email, Role, Creator details)
- // // expected: 405 not Allowed, error message:
- // "Error : Method not allowed"
- // @Test
- // public void createUserGetRequest(){
- // // send GET create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // // create default user by sending http GET request (UserID, Email,
- // Creator details)
- // // expected: 405 not Allowed, error message:
- // "Error : Method not allowed"
- // @Test
- // public void createDefaultUserGetRequest(){
- // // send GET create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // //
- // **********************************************************409***************************************************
- //
- // // create the same user twice with full parameter set(UserID, First Name,
- // Last Name, Email, Role, Creator details)
- // // expected 409 Conflict, error message:
- // "Error : User with '%s' ID already exists", where: %s - USER_ID
- // @Test
- // public void createSameUserTwice(){
- // // send POST create user request
- // // validate data on response
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // // create user twice, first full details (UserID, First Name, Last Name,
- // Email, Role, Creator details), second default user (UserID, Email, Role,
- // Creator details)
- // // expected 409 Conflict, error message:
- // "Error : User with '%s' ID already exists", where: %s - USER_ID
- // @Test
- // public void createFullThanDefaultUserTwice(){
- // // send POST create user request
- //
- // // validate data on response
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // // create user twice, first default user (UserID, Email, Role, Creator
- // details), second full details (UserID, First Name, Last Name, Email,
- // Role, Creator details)
- // // expected 409 Conflict, error message:
- // "Error : User with '%s' ID already exists", where: %s - USER_ID
- // @Test
- // public void createDefaulThanFullUserTwice(){
- // // send POST create user request
- //
- // // validate data on response
- // // send POST create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- //
- // //
- // **********************************************************400***************************************************
- // // create default user with invalid email address format(UserID, Email,
- // Creator details)
- // // expected: 400, error message:
- // "Error : Invalid Content . Invalid e-mail address '%s'", where %s -
- // email address
- // @Test
- // public void createDefaultUserInvalidEmailAddressFormat(){
- // // send GET create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // // create an user with invalid role type (UserID, Email,Role = "TESTER-1"
- // ,Creator details)
- // // expected: 400, error message:
- // "Error : Invalid Content . Invalid role '%s'", where %s - role type
- // @Test
- // public void createUserInvalidRoleType(){
- // // send GET create user request
- // // validate data on response
- // // check the audit message
- // }
- //
- // //
- // **********************************************************500***************************************************
- // // create default user when BE is down (UserID, Email, Creator details)
- // // expected: 500, error message:
- // "Error : Internal Server Error . Try later again."
- // @Test
- // public void createDefaultUserBeNoAccess(){
- // // send GET create user request
- // // validate data on response
- // // check the audit message
- // }
- //
-
- // Benny US570551
-
- @Test
- public void createProductManagerUser() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Man";
- String email = "prodMan@intl.sdc.com";
- String role = "PRODUCT_MANAGER";
- User expectedProductManagerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- UserRestUtils.deleteUser(expectedProductManagerUser, sdncAdminUser, true);
- DbUtils.deleteFromEsDbByPattern("_all");
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductManagerUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_SUCSESS_CREATED,
- createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, createUserResponse.getResponse());
- // Audit validation
- UserValidationUtils.validateAddUserAuditMessage(expectedProductManagerUser, sdncAdminUser,
- Integer.toString(STATUS_CODE_SUCSESS_CREATED), UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // get user and compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductManagerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, getUserResponse.getResponse());
- // Delete ProductManager user
- RestResponse deleteProductManagerUser = UserRestUtils.deleteUser(expectedProductManagerUser, sdncAdminUser,
- true);
- assertEquals("Check response code after deleting OPS user", STATUS_CODE_SUCCESS,
- deleteProductManagerUser.getErrorCode().intValue());
- }
-
- @Test
- public void createProductStrategistUser() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Strategist";
- String email = "prodStr@intl.sdc.com";
- String role = "PRODUCT_STRATEGIST";
- User expectedProductStrategistUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- UserRestUtils.deleteUser(expectedProductStrategistUser, sdncAdminUser, true);
- DbUtils.deleteFromEsDbByPattern("_all");
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_SUCSESS_CREATED,
- createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductStrategistUser,
- createUserResponse.getResponse());
- // Audit validation
- UserValidationUtils.validateAddUserAuditMessage(expectedProductStrategistUser, sdncAdminUser,
- Integer.toString(STATUS_CODE_SUCSESS_CREATED), UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // get user and compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductStrategistUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductStrategistUser, getUserResponse.getResponse());
- // Delete ProductStrategist user
- RestResponse deleteProductStrategistUser = UserRestUtils.deleteUser(expectedProductStrategistUser,
- sdncAdminUser, true);
- assertNotNull("Check response object is not null after deleting OPS user", deleteProductStrategistUser);
- assertEquals("Check response code after deleting OPS user", 200,
- deleteProductStrategistUser.getErrorCode().intValue());
- }
-
- @Test
- public void createProductStrategistUserByNonAdminUser() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Strategist";
- String email = "prodStr@intl.sdc.com";
- String role = "PRODUCT_STRATEGIST";
- User expectedProductStrategistUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- UserRestUtils.deleteUser(expectedProductStrategistUser, sdncAdminUser, true);
- DbUtils.deleteFromEsDbByPattern("_all");
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductStrategistUser, sdncDesignerUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_RESTRICTED_OPERATION,
- createUserResponse.getErrorCode().intValue());
- // Audit validation
- expectedProductStrategistUser.setUserId("");
- expectedProductStrategistUser.setFirstName(null);
- expectedProductStrategistUser.setLastName(null);
- expectedProductStrategistUser.setEmail("");
- expectedProductStrategistUser.setRole("");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductStrategistUser, sdncDesignerUser,
- Integer.toString(STATUS_CODE_RESTRICTED_OPERATION), errorInfo.getAuditDesc(""),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // Try to get user - user is not created
- expectedProductStrategistUser.setUserId("pm1000");
- expectedProductStrategistUser.setFirstName("Prod");
- expectedProductStrategistUser.setLastName("Strategist");
- expectedProductStrategistUser.setEmail("prodStr@intl.sdc.com");
- expectedProductStrategistUser.setRole("PRODUCT_STRATEGIST");
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, getUserResponse.getErrorCode().intValue());
- }
-
- @Test
- public void createProductManagerUserByNonAdminUser() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Man";
- String email = "prodStr@intl.sdc.com";
- String role = "PRODUCT_MANAGER";
- User expectedProductStrategistUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- UserRestUtils.deleteUser(expectedProductStrategistUser, sdncAdminUser, true);
- DbUtils.deleteFromEsDbByPattern("_all");
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductStrategistUser, sdncDesignerUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_RESTRICTED_OPERATION,
- createUserResponse.getErrorCode().intValue());
- // Audit validation
- expectedProductStrategistUser.setUserId("");
- expectedProductStrategistUser.setFirstName(null);
- expectedProductStrategistUser.setLastName(null);
- expectedProductStrategistUser.setEmail("");
- expectedProductStrategistUser.setRole("");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductStrategistUser, sdncDesignerUser,
- Integer.toString(STATUS_CODE_RESTRICTED_OPERATION), errorInfo.getAuditDesc(""),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // Try to get user - user is not created
- expectedProductStrategistUser.setUserId("pm1000");
- expectedProductStrategistUser.setFirstName("Prod");
- expectedProductStrategistUser.setLastName("Strategist");
- expectedProductStrategistUser.setEmail("prodStr@intl.sdc.com");
- expectedProductStrategistUser.setRole("PRODUCT_MANAGER");
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, getUserResponse.getErrorCode().intValue());
- }
-
- @Test
- public void createProductStrategistUserByNonExistingUser() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Strategist";
- String email = "prodStr@intl.sdc.com";
- String role = "PRODUCT_STRATEGIST";
- User noSdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- noSdncUserDetails.setRole("blabla");
- noSdncUserDetails.setUserId("bt750h");
- User expectedProductStrategistUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- DbUtils.deleteFromEsDbByPattern("_all");
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductStrategistUser, noSdncUserDetails);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_NOT_FOUND,
- createUserResponse.getErrorCode().intValue());
- // Audit validation
- expectedProductStrategistUser.setUserId("");
- expectedProductStrategistUser.setFirstName(null);
- expectedProductStrategistUser.setLastName(null);
- expectedProductStrategistUser.setEmail("");
- expectedProductStrategistUser.setRole("");
- noSdncUserDetails.setFirstName("");
- noSdncUserDetails.setLastName("");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.USER_NOT_FOUND.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductStrategistUser, noSdncUserDetails,
- Integer.toString(STATUS_CODE_NOT_FOUND), errorInfo.getAuditDesc(noSdncUserDetails.getUserId()),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // Try to get user - user is not created
- expectedProductStrategistUser.setUserId("pm1000");
- expectedProductStrategistUser.setFirstName("Prod");
- expectedProductStrategistUser.setLastName("Strategist");
- expectedProductStrategistUser.setEmail("prodStr@intl.sdc.com");
- expectedProductStrategistUser.setRole("PRODUCT_STRATEGIST");
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, getUserResponse.getErrorCode().intValue());
- }
-
- @Test
- public void createProductManagerUserByNonExistingUser() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Man";
- String email = "prodStr@intl.sdc.com";
- String role = "PRODUCT_MANAGER";
- User noSdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- noSdncUserDetails.setRole("blabla");
- noSdncUserDetails.setUserId("bt750h");
- User expectedProductStrategistUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- DbUtils.deleteFromEsDbByPattern("_all");
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductStrategistUser, noSdncUserDetails);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_NOT_FOUND,
- createUserResponse.getErrorCode().intValue());
- // Audit validation
- expectedProductStrategistUser.setUserId("");
- expectedProductStrategistUser.setFirstName(null);
- expectedProductStrategistUser.setLastName(null);
- expectedProductStrategistUser.setEmail("");
- expectedProductStrategistUser.setRole("");
- noSdncUserDetails.setFirstName("");
- noSdncUserDetails.setLastName("");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.USER_NOT_FOUND.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductStrategistUser, noSdncUserDetails,
- Integer.toString(STATUS_CODE_NOT_FOUND), errorInfo.getAuditDesc(noSdncUserDetails.getUserId()),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // Try to get user - user is not created
- expectedProductStrategistUser.setUserId("pm1000");
- expectedProductStrategistUser.setFirstName("Prod");
- expectedProductStrategistUser.setLastName("Strategist");
- expectedProductStrategistUser.setEmail("prodStr@intl.sdc.com");
- expectedProductStrategistUser.setRole("PRODUCT_MANAGER");
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, getUserResponse.getErrorCode().intValue());
- }
-
- @Test(enabled = false)
- public void updateProjectManagerRole() throws Exception {
- // Update user role from PRODUCT_STRATEGIST to PRODUCT_MANAGER
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Man";
- String email = "prodMan@intl.sdc.com";
- String role = "PRODUCT_MANAGER";
- String updatedRole = "GOVERNOR";
- User expectedProductManagerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedProductManagerUser);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductManagerUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_SUCSESS_CREATED,
- createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, createUserResponse.getResponse());
- // Update user role
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // Update user role from PRODUCT_STRATEGIST to PRODUCT_MANAGER
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- expectedProductManagerUser.getUserId());
- assertEquals("Check response code after create user", STATUS_CODE_SUCCESS,
- updateUserRoleResponse.getErrorCode().intValue());
- expectedProductManagerUser.setRole(updatedRole);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser,
- updateUserRoleResponse.getResponse());
- // Audit validation
- UserValidationUtils.validateAddUserAuditMessage(expectedProductManagerUser, sdncAdminUser,
- Integer.toString(STATUS_CODE_SUCCESS), UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("UpdateUser"));
- // get user and compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductManagerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, getUserResponse.getResponse());
- // Delete ProductManager user
- RestResponse deleteProductManagerUser = UserRestUtils.deleteUser(expectedProductManagerUser, sdncAdminUser,
- true);
- assertEquals("Check response code after deleting OPS user", STATUS_CODE_SUCCESS,
- deleteProductManagerUser.getErrorCode().intValue());
- }
-
- @Test(enabled = false)
- public void updateProductStrategistRole() throws Exception {
- // Update user role from PRODUCT_STRATEGIST to PRODUCT_MANAGER
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Strategist";
- String email = "prodMan@intl.sdc.com";
- String role = "PRODUCT_STRATEGIST";
- String updatedRole = "TESTER";
- User expectedProductManagerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedProductManagerUser);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductManagerUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_SUCSESS_CREATED,
- createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, createUserResponse.getResponse());
- // Update user role
- User newRoleUser = new User();
- newRoleUser.setRole(updatedRole);
- // Update user role from PRODUCT_STRATEGIST to PRODUCT_MANAGER
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- expectedProductManagerUser.getUserId());
- assertEquals("Check response code after create user", STATUS_CODE_SUCCESS,
- updateUserRoleResponse.getErrorCode().intValue());
- expectedProductManagerUser.setRole(updatedRole);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser,
- updateUserRoleResponse.getResponse());
- // Audit validation
- UserValidationUtils.validateAddUserAuditMessage(expectedProductManagerUser, sdncAdminUser,
- Integer.toString(STATUS_CODE_SUCCESS), UserResponseMessageEnum.SUCCESS_MESSAGE.getValue(),
- UserValidationUtils.getAddUserAuditMessage("UpdateUser"));
- // get user and compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductManagerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, getUserResponse.getResponse());
- // Delete ProductManager user
- RestResponse deleteProductManagerUser = UserRestUtils.deleteUser(expectedProductManagerUser, sdncAdminUser,
- true);
- assertEquals("Check response code after deleting OPS user", STATUS_CODE_SUCCESS,
- deleteProductManagerUser.getErrorCode().intValue());
- }
-
- @Test
- public void createProductManagerUserAlreadyExit() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Man";
- String email = "prodMan@intl.sdc.com";
- String role = "PRODUCT_MANAGER";
- User expectedProductManagerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedProductManagerUser);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductManagerUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_SUCSESS_CREATED,
- createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, createUserResponse.getResponse());
- // create same user again
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse createUserAgainResponse = UserRestUtils.createUser(expectedProductManagerUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", USER_ALREADY_EXIST,
- createUserAgainResponse.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.USER_ALREADY_EXIST.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductManagerUser, sdncAdminUser,
- Integer.toString(USER_ALREADY_EXIST), errorInfo.getAuditDesc(expectedProductManagerUser.getUserId()),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // get user and compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductManagerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, getUserResponse.getResponse());
- // Delete ProductManager user
- RestResponse deleteProductManagerUser = UserRestUtils.deleteUser(expectedProductManagerUser, sdncAdminUser,
- true);
- assertEquals("Check response code after deleting OPS user", STATUS_CODE_SUCCESS,
- deleteProductManagerUser.getErrorCode().intValue());
- }
-
- @Test
- public void createProductStrategistUserAlreadyExit() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Strategist";
- String email = "prodMan@intl.sdc.com";
- String role = "PRODUCT_STRATEGIST";
- User expectedProductManagerUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedProductManagerUser);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductManagerUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_SUCSESS_CREATED,
- createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, createUserResponse.getResponse());
- // create same user again
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse createUserAgainResponse = UserRestUtils.createUser(expectedProductManagerUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", USER_ALREADY_EXIST,
- createUserAgainResponse.getErrorCode().intValue());
- // Audit validation
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.USER_ALREADY_EXIST.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductManagerUser, sdncAdminUser,
- Integer.toString(USER_ALREADY_EXIST), errorInfo.getAuditDesc(expectedProductManagerUser.getUserId()),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // get user and compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductManagerUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductManagerUser, getUserResponse.getResponse());
- // Delete ProductManager user
- RestResponse deleteProductManagerUser = UserRestUtils.deleteUser(expectedProductManagerUser, sdncAdminUser,
- true);
- assertEquals("Check response code after deleting OPS user", STATUS_CODE_SUCCESS,
- deleteProductManagerUser.getErrorCode().intValue());
- }
-
- @Test(enabled = false)
- public void UpdateProductStrategistToNonExistingRole() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Strategist";
- String email = "prodMan@intl.sdc.com";
- String role = "PRODUCT_STRATEGIST";
- String nonExistingRole = "BLABLA";
- User expectedProductStrategistUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedProductStrategistUser);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", STATUS_CODE_SUCSESS_CREATED,
- createUserResponse.getErrorCode().intValue());
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductStrategistUser,
- createUserResponse.getResponse());
- // Update user Role to non Existing role
- User newRoleUser = new User();
- newRoleUser.setRole(nonExistingRole);
- DbUtils.deleteFromEsDbByPattern("_all");
- RestResponse updateUserRoleResponse = UserRestUtils.updateUserRole(newRoleUser, sdncAdminUser,
- expectedProductStrategistUser.getUserId());
- assertEquals("Check response code after updating user role", INVALID_ROLE,
- updateUserRoleResponse.getErrorCode().intValue());
-
- // Audit validation
- /*
- * expectedProductStrategistUser.setUserId("");
- * expectedProductStrategistUser.setFirstName(null);
- * expectedProductStrategistUser.setLastName(null);
- * expectedProductStrategistUser.setEmail("");
- * expectedProductStrategistUser.setRole("");
- */
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_ROLE.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductStrategistUser, sdncAdminUser,
- Integer.toString(INVALID_ROLE), errorInfo.getAuditDesc(nonExistingRole),
- UserValidationUtils.getAddUserAuditMessage("UpdateUser"));
- // get user and compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductStrategistUser, sdncAdminUser);
- UserValidationUtils.validateUserDetailsOnResponse(expectedProductStrategistUser, getUserResponse.getResponse());
- // Delete ProductManager user
- RestResponse deleteProductManagerUser = UserRestUtils.deleteUser(expectedProductStrategistUser, sdncAdminUser,
- true);
- assertEquals("Check response code after deleting OPS user", STATUS_CODE_SUCCESS,
- deleteProductManagerUser.getErrorCode().intValue());
- }
-
- @Test(enabled = false)
- public void createUserWithNonExistingRole() throws Exception {
- String httpCspUserId = "pm1000";
- String userFirstName = "Prod";
- String userLastName = "Strategist";
- String email = "prodMan@intl.sdc.com";
- String role = "BLABLA";
- User expectedProductStrategistUser = new User(userFirstName, userLastName, httpCspUserId, email, role, null);
- deleteUserAndAudit(expectedProductStrategistUser);
- // create user
- RestResponse createUserResponse = UserRestUtils.createUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check response code after create Product-Manager user", INVALID_ROLE,
- createUserResponse.getErrorCode().intValue());
-
- // Audit validation
- /*
- * expectedProductStrategistUser.setUserId("");
- * expectedProductStrategistUser.setFirstName(null);
- * expectedProductStrategistUser.setLastName(null);
- * expectedProductStrategistUser.setEmail("");
- * expectedProductStrategistUser.setRole("");
- */
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_ROLE.name());
- UserValidationUtils.validateAddUserAuditMessage(expectedProductStrategistUser, sdncAdminUser,
- Integer.toString(INVALID_ROLE), errorInfo.getAuditDesc(role),
- UserValidationUtils.getAddUserAuditMessage("AddUser"));
- // get user - verify user is not createdand compare with expected
- RestResponse getUserResponse = UserRestUtils.getUser(expectedProductStrategistUser, sdncAdminUser);
- assertEquals("Check user not created", STATUS_CODE_NOT_FOUND, getUserResponse.getErrorCode().intValue());
-
- }
-
- private void deleteUserAndAudit(User sdncUserDetails) throws IOException {
- UserRestUtils.deleteUser(sdncUserDetails, sdncAdminUser, true);
- DbUtils.cleanAllAudits();
- }
-
-}
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
deleted file mode 100644
index c5a55614d9..0000000000
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.user;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-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.DistributionStatusEnum;
-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.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.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.*;
-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());
- @Rule
- public static TestName name = new TestName();
-
- public GovernorWorkspaceApiTest() {
- super(name, GovernorWorkspaceApiTest.class.getName());
-
- }
-
- protected final User admin1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- protected final User governor = ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR);
- protected final User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- protected ResourceReqDetails resourceDetails1;
- protected ComponentInstanceReqDetails componentInstanceReqDetails;
- protected ArtifactReqDetails heatArtifactDetails;
-
- protected final String serviceVersion = "0.1";
- protected final String servicesString = "services";
- protected final String userRemarks = "commentTest";
-
- protected ServiceReqDetails serviceDetails11 = null;
- protected ServiceReqDetails serviceDetails22 = null;
- protected ServiceReqDetails serviceDetails33 = null;
-
- @BeforeMethod
- public void initBeforeTest() throws Exception {
- DbUtils.deleteFromEsDbByPattern("_all");
- Resource resourceObj = AtomicOperationUtils
- .createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- resourceDetails1 = new ResourceReqDetails(resourceObj);
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- createThreeServices(sdncDesignerDetails1);
- }
-
- protected void createThreeServices(User user) throws Exception {
-
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
-
- RestResponse addInformationalArtifactToResource = ArtifactRestUtils.addInformationalArtifactToResource(
- heatArtifactDetails, sdncDesignerDetails1, resourceDetails1.getUniqueId());
- RestResponse certifyResource = LifecycleRestUtils.certifyResource(resourceDetails1);
- componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance("defaultInstance", resourceDetails1);
-
- serviceDetails11 = ElementFactory.getDefaultService();
- serviceDetails22 = ElementFactory.getDefaultService();
- serviceDetails33 = ElementFactory.getDefaultService();
-
- serviceDetails11.setName(serviceDetails11.getName() + "1");
- List<String> tags = serviceDetails11.getTags();
- tags.add(serviceDetails11.getName());
- serviceDetails11.setTags(tags);
-
- serviceDetails22.setName(serviceDetails11.getName() + "2");
- tags = serviceDetails22.getTags();
- tags.add(serviceDetails22.getName());
- serviceDetails22.setTags(tags);
-
- serviceDetails33.setName(serviceDetails11.getName() + "3");
- tags = serviceDetails33.getTags();
- tags.add(serviceDetails33.getName());
- serviceDetails33.setTags(tags);
-
- RestResponse createServiceResponse1 = createService(user, serviceDetails11);
- RestResponse createServiceResponse2 = createService(user, serviceDetails22);
- RestResponse createServiceResponse3 = createService(user, serviceDetails33);
- }
-
- protected RestResponse createService(User user, ServiceReqDetails serviceDetails) throws Exception, IOException {
- RestResponse createServiceResponse1 = ServiceRestUtils.createService(serviceDetails, user);
- assertNotNull("check response object is not null after creating service", createServiceResponse1);
- assertNotNull("check if error code exists in response after creating service",
- createServiceResponse1.getErrorCode());
- assertEquals("Check response code after creating service", 201,
- createServiceResponse1.getErrorCode().intValue());
- Service convertServiceResponseToJavaObject = ResponseParser
- .convertServiceResponseToJavaObject(createServiceResponse1.getResponse());
- serviceDetails.setUniqueId(convertServiceResponseToJavaObject.getUniqueId());
- logger.debug("Created service1 ={}", serviceDetails);
- addResourceWithHeatArt(serviceDetails);
- return createServiceResponse1;
- }
-
- protected void addResourceWithHeatArt(ServiceReqDetails serviceDetails) throws Exception {
-
- RestResponse createResourceInstance = ComponentInstanceRestUtils.createComponentInstance(
- componentInstanceReqDetails, sdncDesignerDetails1, serviceDetails.getUniqueId(),
- ComponentTypeEnum.SERVICE);
- // System.out.println("serviceUID --->" + serviceDetails.getUniqueId());
- assertEquals("Check response code ", 201, createResourceInstance.getErrorCode().intValue());
- }
-
- protected void certifyAllServices() throws Exception {
- LifecycleRestUtils.certifyService(serviceDetails11);
- LifecycleRestUtils.certifyService(serviceDetails22);
- LifecycleRestUtils.certifyService(serviceDetails33);
- }
-
- protected boolean isElementInArray(String elementId, JSONArray jsonArray) throws Exception {
- for (int i = 0; i < jsonArray.size(); i++) {
- JSONObject jobject = (JSONObject) jsonArray.get(i);
-
- if (jobject.get("uniqueId").toString().equals(elementId)) {
- return true;
- }
- }
- return false;
- }
-
- protected void approveDistributionStatusOfCertifiedService(ServiceReqDetails serviceDetails, User user)
- throws Exception {
- approveDistributionStatusOfService(serviceDetails, user, "1.0");
- }
-
- protected void approveDistributionStatusOfService(ServiceReqDetails serviceDetails, User user, String version)
- throws Exception {
- RestResponse res = LifecycleRestUtils.sendApproveDistribution(user, serviceDetails.getUniqueId(), userRemarks);
- assertEquals(200, res.getErrorCode().intValue());
- ServiceValidationUtils.validateDistrubtionStatusValue(res, DistributionStatusEnum.DISTRIBUTED);
- }
-
- protected void rejectDistributionStatusOfService(ServiceReqDetails serviceDetails, User user) throws Exception {
- rejectDistributionStatusOfService(serviceDetails, user, "1.0");
- }
-
- protected void rejectDistributionStatusOfService(ServiceReqDetails serviceDetails, User user, String version)
- throws Exception {
- RestResponse res = LifecycleRestUtils.rejectDistribution(serviceDetails, version, user, userRemarks);
- assertEquals(200, res.getErrorCode().intValue());
- ServiceValidationUtils.validateDistrubtionStatusValue(res, DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED);
- }
-
- protected JSONArray getFollowedListAsJsonArray(User user) throws Exception {
- RestResponse getGovernorFollowed = ServiceRestUtils.getFollowed(user);
- assertNotNull(getGovernorFollowed);
- assertNotNull(getGovernorFollowed.getErrorCode());
- assertEquals(200, getGovernorFollowed.getErrorCode().intValue());
-
- JSONArray listArrayFromRestResponse = ServiceRestUtils.getListArrayFromRestResponse(getGovernorFollowed);
-
- return listArrayFromRestResponse;
- }
-
- protected void changeDistributionStatusOfAllService(boolean approved, User user) throws Exception {
- if (approved) {
- approveDistributionStatusOfCertifiedService(serviceDetails11, user);
- approveDistributionStatusOfCertifiedService(serviceDetails22, user);
- approveDistributionStatusOfCertifiedService(serviceDetails33, user);
- } else {
- rejectDistributionStatusOfService(serviceDetails11, user);
- rejectDistributionStatusOfService(serviceDetails22, user);
- rejectDistributionStatusOfService(serviceDetails33, user);
- }
-
- }
-
- protected JSONArray checkFollowed(User user) throws Exception {
- JSONArray getFollowedList = getFollowedListAsJsonArray(user);
- assertFalse(getFollowedList.isEmpty());
- assertTrue(isElementInArray(serviceDetails11.getUniqueId(), getFollowedList));
- assertTrue(isElementInArray(serviceDetails22.getUniqueId(), getFollowedList));
- assertTrue(isElementInArray(serviceDetails33.getUniqueId(), getFollowedList));
-
- return getFollowedList;
- }
-
- // -------------------------------------T E S T
- // S------------------------------------------------------//
-
- @Test
- public void governorList_AllCertifiedVersionsOfService() throws Exception {
- certifyAllServices();
- String serviceUniqueIdCertified1 = serviceDetails11.getUniqueId();
- RestResponse res = LifecycleRestUtils.changeServiceState(serviceDetails11, sdncDesignerDetails1, "1.0",
- LifeCycleStatesEnum.CHECKOUT);
- assertEquals(200, res.getErrorCode().intValue());
-
- JSONArray getFollowedList = getFollowedListAsJsonArray(governor);
- assertFalse(getFollowedList.isEmpty());
- assertFalse(isElementInArray(serviceDetails11.getUniqueId(), getFollowedList));
- assertTrue(isElementInArray(serviceDetails22.getUniqueId(), getFollowedList));
- assertTrue(isElementInArray(serviceDetails33.getUniqueId(), getFollowedList));
- assertTrue(isElementInArray(serviceUniqueIdCertified1, getFollowedList));
- assertEquals(3, getFollowedList.size());
-
- // certifyService(serviceDetails11, "1.1");
- LifecycleRestUtils.certifyService(serviceDetails11);
-
- JSONArray governorFollowedList2 = checkFollowed(governor);
- assertEquals(4, governorFollowedList2.size());
- assertTrue(isElementInArray(serviceDetails11.getUniqueId(), governorFollowedList2));
- assertTrue(isElementInArray(serviceUniqueIdCertified1, governorFollowedList2));
-
- }
-
- // -------------------------------------T E S T
- // S------------------------------------------------------//
-
- @Test
- public void governorList_distributionNotApproved() throws Exception {
- certifyAllServices();
-
- JSONArray checkFollowed = checkFollowed(governor);
- assertEquals(3, checkFollowed.size());
- }
-
- @Test
- public void governorGetEmptyListTest_notCertifiedServices() throws Exception {
- JSONArray governorFollowedList = getFollowedListAsJsonArray(governor);
-
- assertTrue(governorFollowedList.isEmpty());
- }
-
- @Test
- public void governorList_distributionApproved() throws Exception {
- certifyAllServices();
- boolean approved = true;
- changeDistributionStatusOfAllService(approved, governor);
-
- JSONArray checkFollowed = checkFollowed(governor);
- assertEquals(3, checkFollowed.size());
- }
-
- @Test(enabled = false)
- public void governorList_distributed() throws Exception {
- certifyAllServices();
-
- LifecycleRestUtils.changeDistributionStatus(serviceDetails11, "1.0", governor, userRemarks,
- DistributionStatusEnum.DISTRIBUTED);
- LifecycleRestUtils.changeDistributionStatus(serviceDetails22, "1.0", governor, userRemarks,
- DistributionStatusEnum.DISTRIBUTED);
- LifecycleRestUtils.changeDistributionStatus(serviceDetails33, "1.0", governor, userRemarks,
- DistributionStatusEnum.DISTRIBUTED);
-
- JSONArray governorFollowedList = getFollowedListAsJsonArray(governor);
- assertFalse(governorFollowedList.isEmpty());
- assertTrue(isElementInArray(serviceDetails11.getUniqueId(), governorFollowedList));
- assertTrue(isElementInArray(serviceDetails22.getUniqueId(), governorFollowedList));
- assertTrue(isElementInArray(serviceDetails33.getUniqueId(), governorFollowedList));
- }
-
- @Test
- public void governorList_distributionRejected() throws Exception {
- certifyAllServices();
- boolean distributionRejected = false;
- changeDistributionStatusOfAllService(distributionRejected, governor);
-
- JSONArray checkFollowed = checkFollowed(governor);
- assertEquals(3, checkFollowed.size());
- }
-
-}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java
index 917d980184..bddc06169a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java
@@ -233,7 +233,7 @@ public class GetAssetServlet extends ComponentBaseTest {
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void getToscaModelSuccess() throws Exception {
Resource resource;
diff --git a/test-apis-ci/src/main/resources/ci/conf/testngLifeCycle.xml b/test-apis-ci/src/main/resources/ci/conf/testngLifeCycle.xml
index aa390dc213..005bdba0f3 100644
--- a/test-apis-ci/src/main/resources/ci/conf/testngLifeCycle.xml
+++ b/test-apis-ci/src/main/resources/ci/conf/testngLifeCycle.xml
@@ -3,25 +3,7 @@
<suite name="lifeCycle" parallel="none">
<test name="Test">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_cerificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceResourceLCSTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_UndoCheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_UndoCheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_StartCertificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_CheckinCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_CheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceCertWithResourceInstances"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CrossCheckOutTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CertifyVFWithNotCertRIs"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_request4CerCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CleanupIntermediateReources"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_CheckOutCIT"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_cerificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CertifyServiceWithNotCertRI"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_CheckInCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_request4CerCITest"/>
<class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_StartCertificationCITest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- lifeCycle -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/artifacts.xml b/test-apis-ci/src/main/resources/ci/testSuites/artifacts.xml
index 24229b8586..1352e75d58 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/artifacts.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/artifacts.xml
@@ -1,19 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Artifacts" >
- <test name="Artifacts">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.DownloadComponentArt" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.ArtifactServletTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateHeatArtFieldsTypes" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.PlaceHolderValidations" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateArtResponse" />
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.CrudArt" />
- </classes>
- </test>
+<suite name="Artifacts">
+ <test name="Artifacts">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.artifacts.DownloadComponentArt"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateHeatArtFieldsTypes"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.artifacts.PlaceHolderValidations"/>
+ </classes>
+ </test>
</suite> <!-- Artifacts -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/category.xml b/test-apis-ci/src/main/resources/ci/testSuites/category.xml
index f2a0b3790c..3de83431e8 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/category.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/category.xml
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="category" >
+<suite name="category">
<test name="Test">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.category.CategoriesTests"/>
<class name="org.openecomp.sdc.ci.tests.execute.category.GroupingTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.category.SubCategoriesTest"/>
</classes>
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/ciFull.xml b/test-apis-ci/src/main/resources/ci/testSuites/ciFull.xml
index 26a85fd9c6..47624c6266 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/ciFull.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/ciFull.xml
@@ -1,221 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="ciFull" configfailurepolicy="continue" verbose="2">
- <test name="Category">
- <classes>
- <class name="org.openecomp.sdc.ci.tests.execute.category.ElementsApiTest" />
- <class name="org.openecomp.sdc.ci.tests.execute.category.CategoriesTests">
- <methods>
- <exclude name="importCategories" />
- <exclude name="getServiceCategoryHierarchySuccessFlow" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.category.CatalogDataApiTest" />
- <class name="org.openecomp.sdc.ci.tests.execute.category.GroupingTest" >
- <methods>
- <exclude name="createProductGroupForNonExistingCategory" />
- <exclude name="createProductGroupForNonExistingSunCategory" />
- <exclude name="getProductCategoryHierarchySuccessFlow" />
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.category.SubCategoriesTest">
- <methods>
- <exclude name="createProductSubCategoryForNonExistingCategory" />
- <exclude name="createResourceSubCategoryForNonExistingCategory" />
- <exclude name="getResourceCategoryHierarchySuccessFlow" />
- </methods>
- </class>
- </classes>
- </test> <!-- Test -->
- <test name="Distribution">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.distribution.AuthanticationTests" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.distribution.DistributionDownloadArtifactTest">
- <methods>
- <exclude name="downloadServiceArtifact_ServiceVersionNotFound" />
- </methods>
- </class>
- </classes>
- </test> <!-- Test -->
- <test name="General">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.general.ManageEcompConsumerCredentials">
- <methods>
- <exclude name="createEcompCredentialsByNoExistingIUser" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.general.FeProxyTest" />
- <class name="org.openecomp.sdc.ci.tests.execute.general.UuidTest" />
- </classes>
- </test>
- <test name="Resource">
- <classes>
- <!-- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.SimultaneousApiTest" /> -->
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.ComponentRelationshipInVfTest">
- <methods>
- <exclude name="associateOneOfTwoCPsToVl_ThenDiscocciate" />
- <exclude name="disassociateRelationInVfNotFound" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.UpdateResourceMetadataTest">
- <methods>
- <exclude name="UpdateResourceCategory_negativeFlow" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.VFResourceInstanceNameCRUD"/>
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.VfComponentInstanceCRUDTest">
- <methods>
- <exclude name="createAllAtomicInstancesTestGetReqCapAPI_suc" />
- <exclude name="createVfcInstance_UserIdIsEmpty" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.ValidateExtendedVfData" />
- </classes>
- </test>
- <test name="Product">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest">
- <methods>
- <exclude name="undoCheckOutNotExist" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductComponentInstanceCRUDTest">
- <methods>
- <exclude name="createServiceInstanceNameIsNull" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ChangeServiceInstanceVersionTest">
- <methods>
- <exclude name="changeServiceInstanceVersionToNonExisitingServiceVersion" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductGetFollowedTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductToscaYamlGenerationTest" />
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest">
- <methods>
- <exclude name="checkInProductNotExist" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest" />
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCrudTest">
- <methods>
- <exclude name="updateProductDescriptionRemoveSpacesFromBeginning" />
- <exclude name="updateProductDescriptionRemoveSpacesFromTheEnd" />
- <exclude name="updateProductDescriptionValidCharacters02" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductCreateWithValidationsTest">
- <methods>
- <exclude name="createProductDescriptionRemoveSpacesFromBeginning" />
- <exclude name="createProductDescriptionRemoveSpacesFromTheEnd" />
- <exclude name="createProductDescriptionValidCharacters01" />
- <exclude name="createProductDescriptionValidCharacters02" />
- </methods>
- </class>
- </classes>
- </test>
- <test name="Service">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.GetServiceLatestVersionTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.CreateServiceMetadataApiTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.ReqCapOccurrencesTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.ChangeServiceDistributionStatusApiTest">
- <methods>
- <exclude name="approveCertifiedService_byDesigner" />
- <exclude name="approveCertifiedService_byOps" />
- <exclude name="approveCertifiedService_byTester" />
- <exclude
- name="distributionStatusChange_approve_Reject_AprroveBysdncAdminDetails" />
- <exclude name="rejectCertifiedService_byDesigner" />
- <exclude name="rejectCertifiedService_byOps" />
- <exclude name="rejectCertifiedService_byTester" />
- <exclude name="rejectCertifiedService_bysdncAdminDetails" />
- <exclude name="rejectCertifiedService_bysdncGovernorDeatails" />
- <exclude name="rejectNotCertifiedService_checkedin" />
- <exclude name="rejectNotCertifiedService_checkeout" />
- <exclude name="rejectNotCertifiedService_inProgress" />
- <exclude name="rejectNotCertifiedService_readyForCer" />
- <exclude name="rejectServiceNotFound" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.ServiceComponentInstanceCRUDTest">
- <methods>
- <exclude name="associateAfterCheckoutAllInstancesTest" />
- <exclude name="associateAfterDeletingResourceTest" />
- <exclude name="associateDissociateTwoVFs" />
- <exclude name="associateInstancesInTwoServiceVersionsTest" />
- <exclude name="associateNotCompitableReqCapTest" />
- <exclude name="associateOnceAgainExistingRelationTest" />
- <exclude name="associateResourceInstanceToResourceInstanceNotFoundTest" />
- <exclude
- name="associateTwoRelations_CheckinCheckout_DissoicateOneRelationInSecondVersion" />
- <exclude name="createResourceInstanceWithEmptyUserIdTest" />
- <exclude name="deleteNotFoundResourceInstanceTest" />
- <exclude name="deleteResourceInstanceWithEmptyUserIdTest" />
- <exclude name="dissociateOnceAgainTest" />
- <exclude name="dissociateRelationNotFoundTest" />
- <exclude name="dissoicateRelationWhileInstanceNotFound" />
- <exclude name="dissoicateWithEmptyUserIdHeaderTest" />
- <exclude name="relationDeletedAfterDeletingResourceInstanceTest" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.UpdateServiceMetadataTest">
- <methods>
- <exclude name="categoryValidationTest6" />
- <exclude name="categoryValidationTest7" />
- <exclude name="descriptionValidationTest11" />
- <exclude name="descriptionValidationTest12" />
- <exclude name="descriptionValidationTest13" />
- <exclude name="descriptionValidationTest7" />
- <exclude name="serviceNameValidationTest17" />
- <exclude name="updateCertifiedService" />
- <exclude name="updateCheckoutCertifiedService" />
- <exclude name="updateServiceByMethod_delete" />
- <exclude name="updateServiceByMethod_get" />
- <exclude name="updateServiceByMethod_post" />
- <exclude name="updateServiceNotExist" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.GetAllServiceVersions" />
- </classes>
- </test>
- <test name="Artifacts">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.DownloadComponentArt" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.ArtifactServletTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateHeatArtFieldsTypes" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.PlaceHolderValidations" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateArtResponse" />
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.CrudArt" />
- </classes>
- </test>
+ <test name="Category">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.category.CatalogDataApiTest"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.category.GroupingTest">
+ <methods>
+ <exclude name="createProductGroupForNonExistingCategory"/>
+ <exclude name="createProductGroupForNonExistingSunCategory"/>
+ <exclude name="getProductCategoryHierarchySuccessFlow"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.category.SubCategoriesTest">
+ <methods>
+ <exclude name="createProductSubCategoryForNonExistingCategory"/>
+ <exclude name="createResourceSubCategoryForNonExistingCategory"/>
+ <exclude name="getResourceCategoryHierarchySuccessFlow"/>
+ </methods>
+ </class>
+ </classes>
+ </test> <!-- Test -->
+ <test name="Distribution">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.distribution.AuthanticationTests"/>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.distribution.DistributionDownloadArtifactTest">
+ <methods>
+ <exclude name="downloadServiceArtifact_ServiceVersionNotFound"/>
+ </methods>
+ </class>
+ </classes>
+ </test> <!-- Test -->
+ <test name="General">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.general.FeProxyTest"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.general.UuidTest"/>
+ </classes>
+ </test>
+ <test name="Resource">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.SimultaneousApiTest"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.UpdateResourceMetadataTest">
+ <methods>
+ <exclude name="UpdateResourceCategory_negativeFlow"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.VFResourceInstanceNameCRUD"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest"/>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.resource.ValidateExtendedVfData"/>
+ </classes>
+ </test>
+ <test name="Product">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest">
+ <methods>
+ <exclude name="undoCheckOutNotExist"/>
+ </methods>
+ </class>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.product.ProductGetFollowedTest"/>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.product.ProductToscaYamlGenerationTest"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest">
+ <methods>
+ <exclude name="checkInProductNotExist"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest"/>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.product.ProductCreateWithValidationsTest">
+ <methods>
+ <exclude name="createProductDescriptionRemoveSpacesFromBeginning"/>
+ <exclude name="createProductDescriptionRemoveSpacesFromTheEnd"/>
+ <exclude name="createProductDescriptionValidCharacters01"/>
+ <exclude name="createProductDescriptionValidCharacters02"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+ <test name="Service">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.service.ChangeServiceDistributionStatusApiTest">
+ <methods>
+ <exclude name="approveCertifiedService_byDesigner"/>
+ <exclude name="approveCertifiedService_byOps"/>
+ <exclude name="approveCertifiedService_byTester"/>
+ <exclude
+ name="distributionStatusChange_approve_Reject_AprroveBysdncAdminDetails"/>
+ <exclude name="rejectCertifiedService_byDesigner"/>
+ <exclude name="rejectCertifiedService_byOps"/>
+ <exclude name="rejectCertifiedService_byTester"/>
+ <exclude name="rejectCertifiedService_bysdncAdminDetails"/>
+ <exclude name="rejectCertifiedService_bysdncGovernorDeatails"/>
+ <exclude name="rejectNotCertifiedService_checkedin"/>
+ <exclude name="rejectNotCertifiedService_checkeout"/>
+ <exclude name="rejectNotCertifiedService_inProgress"/>
+ <exclude name="rejectNotCertifiedService_readyForCer"/>
+ <exclude name="rejectServiceNotFound"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.service.GetAllServiceVersions"/>
+ </classes>
+ </test>
+ <test name="Artifacts">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.artifacts.DownloadComponentArt"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateHeatArtFieldsTypes"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.artifacts.PlaceHolderValidations"/>
+ </classes>
+ </test>
</suite> \ No newline at end of file
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/general.xml b/test-apis-ci/src/main/resources/ci/testSuites/general.xml
index bd7e6b6650..a63f36423e 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/general.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/general.xml
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="General" >
+<suite name="General">
<test name="Test">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.general.SampleTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.general.ManageEcompConsumerCredentials"/>
<class name="org.openecomp.sdc.ci.tests.execute.general.UuidTest"/>
</classes>
</test> <!-- Test -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/imports.xml b/test-apis-ci/src/main/resources/ci/testSuites/imports.xml
index ae4a5bc1f8..b9374cf47a 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/imports.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/imports.xml
@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Imports" >
+<suite name="Imports">
<test name="Imports">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportGenericResourceCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportCsarResourceTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportNewResourceCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportToscaResourceTest"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportGenericResourceCITest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Imports -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/product.xml b/test-apis-ci/src/main/resources/ci/testSuites/product.xml
index 4ea495d0d7..101b94a6bb 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/product.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/product.xml
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Product" >
+<suite name="Product">
<test name="Test">
<classes>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductLifecycleTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCrudTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductComponentInstanceCRUDTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Product -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/productAPIs.xml b/test-apis-ci/src/main/resources/ci/testSuites/productAPIs.xml
index 61950e9de7..df9aa9f152 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/productAPIs.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/productAPIs.xml
@@ -1,20 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="productAPIs" configfailurepolicy="continue" verbose="2" parallel="tests" thread-count="6">
+<suite name="productAPIs" configfailurepolicy="continue" verbose="2" parallel="tests"
+ thread-count="6">
<test name="Test">
<classes>
-
- <class name="org.openecomp.sdc.ci.tests.execute.product.ChangeServiceInstanceVersionTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductComponentInstanceCRUDTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductCreateWithValidationsTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCrudTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductGetFollowedTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest"/>
-
-
</classes>
</test> <!-- Test -->
</suite> <!-- Suite --> \ No newline at end of file
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/resource.xml b/test-apis-ci/src/main/resources/ci/testSuites/resource.xml
index 313fbb26db..4fd0e43a02 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/resource.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/resource.xml
@@ -1,374 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Sanity" configfailurepolicy="continue" >
-
- <!--
- <listeners>
- <listener class-name="org.openecomp.sdc.ci.tests.config.InvokedMethodListener" />
- </listeners>
- -->
-
+<suite name="Sanity" configfailurepolicy="continue">
<test verbose="2" name="Sanity">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ArtifactServletTest">
- <methods>
- <include name="upadteArtifactWithPayLoadToResourcseTest"/>
- <include name="createAndUpdateArtifactToInterface"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.CrudArt">
- <methods>
- <include name="addHeatArtifactToResourceAndCertify"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.LCS_Artifacts">
- <methods>
- <include name="LCS_inherit_artifact"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.InformationalArt">
- <methods>
- <include name="UpdateAllResourceMandatoryArtifacts"/>
- <include name="updateInformationalArtifactMetadataOfResource"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.InformationalArtCloudQuestionnaire">
- <methods>
- <include name="updateMandatoryInformationalArtifact_CloudQuestionnaire"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ServiceApiArtifactTest">
- <methods>
- <include name="uploadServiceApiArtifactSuccessfullyTest"/>
- <include name="updateApiArtifactSuccessfullyTest"/>
- <include name="deleteApiArtifactSuccessfully"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ServiceInformationalArtifact">
- <methods>
- <include name="updateMandatoryInformationalArtifact_ServiceQuestionnaire"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateArtResponse"/>
-
- <class name="org.openecomp.sdc.ci.tests.execute.category.CatalogDataApiTest"/>
-
- <class name="org.openecomp.sdc.ci.tests.execute.category.ElementsApiTest">
- <methods>
- <include name="getAllArtifactTypes"/>
- <include name="getConfiguration"/>
- <include name="getAllPropertyScopesSuccess"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.distribution.AuthanticationTests">
- <methods>
- <include name="downloadServiceArtifactSuccessWithAutantication"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.distribution.DistributionDownloadArtifactTest">
- <methods>
- <include name="downloadResourceArtifactSuccess"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.general.BasicHttpAuthenticationTest">
- <methods>
- <include name="sendAuthenticatedRequestTest_success"/>
- </methods>
- </class>
-
-
-
- <class name="org.openecomp.sdc.ci.tests.execute.general.FeProxyTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.general.ManageEcompConsumerCredentials">
- <methods>
- <include name="deleteEcompCredentialsMethodDelete"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.general.UuidTest">
- <methods>
- <include name="testE2EUuidHeaderReturnedAndPreserved"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportGenericResourceCITest">
- <methods>
- <include name="importAllTestResources"/>
- <include name="testImportCheckoutAndUpdateUserResource"/>
- <include name="testImportWithUpdateNormativeType"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportNewResourceCITest">
- <methods>
- <include name="importAllTestResources_toValidateNewAPI"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportToscaResourceTest">
- <methods>
- <include name="importToscaResource"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CleanupIntermediateReources">
- <methods>
- <include name="test28"/>
- <include name="test29"/>
- <include name="test30"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CleanupIntermediateServicesTest">
- <methods>
- <include name="testCleanupIntermediateServices"/>
- </methods>
- </class>
-
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ResourceLCS_cerificationCITest">
- <methods>
- <include name="verifyAllPrevVerDeleted"/>
- <include name="verifyStartWithDesignerCertByAdmin"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ResourceLCS_CheckInCITest">
- <methods>
- <include name="checkInTest_suc"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ResourceLCS_CheckOutCITest">
- <methods>
- <include name="checkOutTest_currState_READY_FOR_CERTIFICATION_ownerDSIGNER_performByADMIN_suc"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ResourceLCS_request4CerCITest">
- <methods>
- <include name="req4cer_fromCheckOut_designer_admin"/>
- </methods>
- </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.category.CatalogDataApiTest"/>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.distribution.AuthanticationTests">
+ <methods>
+ <include name="downloadServiceArtifactSuccessWithAutantication"/>
+ </methods>
+ </class>
+
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.distribution.DistributionDownloadArtifactTest">
+ <methods>
+ <include name="downloadResourceArtifactSuccess"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.general.FeProxyTest"/>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.general.UuidTest">
+ <methods>
+ <include name="testE2EUuidHeaderReturnedAndPreserved"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.imports.ImportGenericResourceCITest">
+ <methods>
+ <include name="importAllTestResources"/>
+ <include name="testImportCheckoutAndUpdateUserResource"/>
+ <include name="testImportWithUpdateNormativeType"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.property.AdditionalInformationServletTest">
+ <methods>
+ <include name="createResourceAdditionalInformationTestDuringLifecycle"/>
+ <include name="updateResourceAdditionalInformationTest"/>
+ <include name="deleteResourceAdditionalInformationTest"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.property.PropertyApisTest">
+ <methods>
+ <include name="testPropertyApis"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.GetAllResourceVersions">
+ <methods>
+ <include name="getResourceAllVersions_version15"/>
+ </methods>
+ </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ResourceLCS_StartCertificationCITest">
- <methods>
- <include name="startCer_suc"/>
- </methods>
- </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest">
+ <methods>
+ <include name="updateResourceMetadataSuccess"/>
+ </methods>
+ </class>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ResourceLCS_UndoCheckOutCITest">
- <methods>
- <include name="undoCheckOutTest_import_outAdmin_undoOut_designer"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceCertWithMandatoryArt">
- <methods>
- <include name="CertServiceWithHeatDeployArtOnResource"/>
- </methods>
- </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.UpdateResourceMetadataTest">
+ <methods>
+ <include name="UpdateDerivedFromSuccess"/>
+ </methods>
+ </class>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceCertWithResourceInstances">
- <methods>
- <include name="certServiceWithCertResource"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.property.AdditionalInformationServletTest">
- <methods>
- <include name="createResourceAdditionalInformationTestDuringLifecycle"/>
- <include name="updateResourceAdditionalInformationTest"/>
- <include name="deleteResourceAdditionalInformationTest"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.property.PropertyApisTest">
- <methods>
- <include name="testPropertyApis"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.property.PropertyServletTest">
- <methods>
- <include name="createCascadeVfResource"/>
- <include name="createPropertyTestSetClearDefaultValueInetegr"/>
- </methods>
- </class>
-
-
- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetAllLatestVersionNonAbstarctResources">
- <methods>
- <include name="resourceCertifiedTwiceCoutCinCout"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetAllResourceVersions">
- <methods>
- <include name="getResourceAllVersions_version15"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetFollwedElementsTest">
- <methods>
- <include name="getResourcesListBolongsToSpecificDesigner"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetResourceAbstractApiTest">
- <methods>
- <include name="getAbstractResourceList"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetResourceNotAbstractApiTest">
- <methods>
- <include name="getNotAbstractResourceList"/>
- </methods>
- </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.service.GetComponentAuditApiTest">
+ <methods>
+ <include name="testServiceAuditCertifiedVersion"/>
+ </methods>
+ </class>
- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetResourceTagsApiTest">
- <methods>
- <include name="getModifiedResourceTagsList"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest">
- <methods>
- <include name="updateResourceMetadataSuccess"/>
- </methods>
- </class>
- <!--
- <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceInstanceNameCRUD">
- <methods>
- <include name="updateResourceInstanceNameAfterServiceCertification"/>
- </methods>
- </class>
- -->
-<!-- <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceInstanceServletTest">
- <methods>
- <include name="updateRI_suc"/>
- </methods>
- </class> -->
+ <class name="org.openecomp.sdc.ci.tests.execute.user.ActivateDeActivateDeleteUser">
+ <methods>
+ <include name="authorizeDeActivatedUser"/>
+ </methods>
+ </class>
- <class name="org.openecomp.sdc.ci.tests.execute.resource.UpdateResourceMetadataTest">
- <methods>
- <include name="UpdateDerivedFromSuccess"/>
- </methods>
- </class>
-
+ <!-- Product tests start-->
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest">
+ <methods>
+ <include name="checkInProductByCreator"/>
+ </methods>
+ </class>
- <class name="org.openecomp.sdc.ci.tests.execute.service.GetComponentAuditApiTest">
- <methods>
- <include name="testServiceAuditCertifiedVersion"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.service.ServiceApiTest">
- <methods>
- <include name="createServiceTest"/>
- <include name="getFollowedServicesTester"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.service.ServiceInformationalArtifactApiTest">
- <methods>
- <include name="addArtifactSuccessfuly"/>
- <include name="deleteArtifact"/>
- <include name="updateArtifactMetadataSuccessfully"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.service.UpdateServiceMetadataTest">
- <methods>
- <include name="updateServiceSuccessfully"/>
- </methods>
- </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest">
+ <methods>
+ <include name="checkOutProductByPmNotInContacts"/>
+ </methods>
+ </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.user.ActivateDeActivateDeleteUser">
- <methods>
- <include name="authorizeDeActivatedUser"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.user.CreateUserApiTest">
- <methods>
- <include name="createUser"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.user.GovernorWorkspaceApiTest">
- <methods>
- <include name="governorList_AllCertifiedVersionsOfService"/>
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.user.OpsWorkspaceApiTest">
- <methods>
- <include name="opsList_AllCertifiedVersionsOfServiceApproved"/>
- </methods>
- </class>
-
- <!-- Product tests start-->
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest">
- <methods>
- <include name="checkInProductByCreator"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ChangeServiceInstanceVersionTest">
- <methods>
- <include name="changeServiceInstanceVersionByPm"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest">
- <methods>
- <include name="checkOutProductByPmNotInContacts"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductComponentInstanceCRUDTest">
- <methods>
- <include name="createServiceInstanceTest"/>
- <include name="deleteServiceInstanceByPm"/>
- <include name="updateServiceInstanceNameByPm"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCrudTest">
- <methods>
- <include name="createManyGroupingsDiffCategories"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductGetFollowedTest">
- <methods>
- <include name="followedPageTest"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest">
- <methods>
- <include name="undoCheckOutProductByPm"/>
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.interfaceoperation.InterfaceOperationsTest">
- <methods>
- <include name="addInterfaceOperationsOfGlobalTypeOnResource"/>
- <include name="addInterfaceOperationsOnResource"/>
- <include name="getInterfaceOperationsFromResource"/>
- <include name="updateInterfaceOperationsOnResource"/>
- <include name="deleteInterfaceOperationsFromResource"/>
- <include name="addInterfaceOperationsOfGlobalTypeOnPNFResource"/>
- <include name="addInterfaceOperationsOnPNFResource"/>
- <include name="getInterfaceOperationsFromPNFResource"/>
- <include name="updateInterfaceOperationsOnPNFResource"/>
- <include name="deleteInterfaceOperationsFromPNFResource"/>
- </methods>
- </class>
- <!-- Product tests end-->
- </classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductGetFollowedTest">
+ <methods>
+ <include name="followedPageTest"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest">
+ <methods>
+ <include name="undoCheckOutProductByPm"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.interfaceoperation.InterfaceOperationsTest">
+ <methods>
+ <include name="addInterfaceOperationsOfGlobalTypeOnResource"/>
+ <include name="addInterfaceOperationsOnResource"/>
+ <include name="getInterfaceOperationsFromResource"/>
+ <include name="updateInterfaceOperationsOnResource"/>
+ <include name="deleteInterfaceOperationsFromResource"/>
+ <include name="addInterfaceOperationsOfGlobalTypeOnPNFResource"/>
+ <include name="addInterfaceOperationsOnPNFResource"/>
+ <include name="getInterfaceOperationsFromPNFResource"/>
+ <include name="updateInterfaceOperationsOnPNFResource"/>
+ <include name="deleteInterfaceOperationsFromPNFResource"/>
+ </methods>
+ </class>
+ <!-- Product tests end-->
+ </classes>
</test> <!-- Test -->
</suite> <!-- Sanity -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/sanity.xml b/test-apis-ci/src/main/resources/ci/testSuites/sanity.xml
index f642170b34..320c3ccd43 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/sanity.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/sanity.xml
@@ -2,393 +2,227 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Sanity" configfailurepolicy="continue" verbose="2">
- <test name="sanityE2Eflows">
- <classes>
- <class name="org.openecomp.sdc.ci.tests.sanity.CrudE2E" />
- </classes>
- </test>
-
- <test name="General">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.general.BasicHttpAuthenticationTest">
- <methods>
- <include name="sendAuthenticatedRequestTest_success" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.general.FeProxyTest" />
- <class
- name="org.openecomp.sdc.ci.tests.execute.general.ManageEcompConsumerCredentials">
- <methods>
- <include name="deleteEcompCredentialsMethodDelete" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.general.UuidTest">
- <methods>
- <include name="testE2EUuidHeaderReturnedAndPreserved" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="ArtifactOnInstance">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.CrudArt">
- <methods>
- <include name="addDcaeInventoryToscaArtifactToResourceInstanceAndCertify" />
- <include name="addDcaeInventoryJsonArtifactToResourceInstanceAndCertify" />
- <include name="addDcaeInventoryPolicyArtifactToResourceInstanceAndCertify" />
- <include name="addDcaeInventoryDocArtifactToResourceInstanceAndCertify" />
- <include name="addDcaeInventoryBluePrintArtifactToResourceInstanceAndCertify" />
- <include name="addDcaeInventoryEventArtifactToResourceInstanceAndCertify" />
- <include name="updateArtifactDescriptionToResourceInstance" />
- <include name="deleteArtifactToResourceInstance" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="Artifact">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.ArtifactServletTest">
- <methods>
- <include name="upadteArtifactWithPayLoadToResourcseTest" />
- <include name="createAndUpdateArtifactToInterface" />
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.CrudArt">
- <methods>
- <include name="addHeatArtifactToResourceAndCertify" />
- </methods>
- </class>
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.LCS_Artifacts">
- <methods> <include name="LCS_inherit_artifact" /> </methods> </class> -->
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.InformationalArt">
- <methods> <include name="UpdateAllResourceMandatoryArtifacts" /> <include
- name="updateInformationalArtifactMetadataOfResource" /> </methods> </class>
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.InformationalArtCloudQuestionnaire">
- <methods> <include name="updateMandatoryInformationalArtifact_CloudQuestionnaire"
- /> </methods> </class> -->
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ServiceApiArtifactTest">
- <methods> <include name="uploadServiceApiArtifactSuccessfullyTest" /> <include
- name="updateApiArtifactSuccessfullyTest" /> <include name="deleteApiArtifactSuccessfully"
- /> </methods> </class> -->
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ServiceInformationalArtifact">
- <methods> <include name="updateMandatoryInformationalArtifact_ServiceQuestionnaire"
- /> </methods> </class> -->
-
- <class name="org.openecomp.sdc.ci.tests.execute.artifacts.ValidateArtResponse" />
-
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.artifacts.DownloadComponentArt">
- <methods>
- <include name="downloadArtifactFromResourceTest" />
- <include name="downloadArtifactFromServiceTest" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="Service">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.GetComponentAuditApiTest">
- <methods>
- <include name="testServiceAuditCertifiedVersion" />
- </methods>
- </class>
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.service.ServiceApiTest">
- <methods> <include name="createServiceTest" /> <include name="getFollowedServicesTester"
- /> </methods> </class> -->
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.service.ServiceInformationalArtifactApiTest">
- <methods> <include name="addArtifactSuccessfuly" /> <include name="deleteArtifact"
- /> <include name="updateArtifactMetadataSuccessfully" /> </methods> </class> -->
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.service.UpdateServiceMetadataTest">
- <methods>
- <include name="updateServiceSuccessfully" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="Resource">
- <classes>
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetAllLatestVersionNonAbstarctResources">
- <methods> <include name="resourceCertifiedTwiceCoutCinCout" /> </methods>
- </class> -->
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.GetAllResourceVersions">
- <methods>
- <include name="getResourceAllVersions_version15" />
- </methods>
- </class>
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetFollwedElementsTest">
- <methods> <include name="getResourcesListBolongsToSpecificDesigner" /> </methods>
- </class> -->
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetResourceAbstractApiTest">
- <methods> <include name="getAbstractResourceList" /> </methods> </class> -->
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.GetResourceNotAbstractApiTest">
- <methods>
- <include name="getNotAbstractResourceList" />
- </methods>
- </class>
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.resource.GetResourceTagsApiTest">
- <methods> <include name="getModifiedResourceTagsList" /> </methods> </class> -->
-
- <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest">
- <methods>
- <include name="updateResourceMetadataSuccess" />
- </methods>
- </class>
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceInstanceNameCRUD">
- <methods> <include name="updateResourceInstanceNameAfterServiceCertification"/>
- </methods> </class> -->
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceInstanceServletTest">
- <methods> <include name="updateRI_suc"/> </methods> </class> -->
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.resource.UpdateResourceMetadataTest">
- <methods>
- <include name="UpdateDerivedFromSuccess" />
- </methods>
- </class>
- </classes>
- </test>
- <test name="Product">
- <classes>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest">
- <methods>
- <include name="checkInProductByCreator" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ChangeServiceInstanceVersionTest">
- <methods>
- <include name="changeServiceInstanceVersionByPm" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest">
- <methods>
- <include name="checkOutProductByPmNotInContacts" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductComponentInstanceCRUDTest">
- <methods>
- <include name="createServiceInstanceTest" />
- <include name="deleteServiceInstanceByPm" />
- <include name="updateServiceInstanceNameByPm" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCrudTest">
- <methods>
- <include name="createManyGroupingsDiffCategories" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductGetFollowedTest">
- <methods>
- <include name="followedPageTest" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest">
- <methods>
- <include name="undoCheckOutProductByPm" />
- </methods>
- </class>
- <!-- Product tests end -->
- </classes>
- </test>
- <test name="Catalog">
- <classes>
- <class name="org.openecomp.sdc.ci.tests.execute.category.CatalogDataApiTest" />
- </classes>
- </test>
-
- <test name="distribution">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.distribution.AuthanticationTests">
- <methods>
- <include name="downloadServiceArtifactSuccessWithAutantication" />
- </methods>
- </class>
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.distribution.DistributionDownloadArtifactTest">
- <methods>
- <include name="downloadResourceArtifactSuccess" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="Category">
- <classes>
- <class name="org.openecomp.sdc.ci.tests.execute.category.ElementsApiTest">
- <methods>
- <include name="getAllArtifactTypes" />
- <include name="getConfiguration" />
- <include name="getAllPropertyScopesSuccess" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="Imports">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.imports.ImportGenericResourceCITest">
- <methods>
- <include name="importAllTestResources" />
- <include name="testImportCheckoutAndUpdateUserResource" />
- <include name="testImportWithUpdateNormativeType" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.imports.ImportNewResourceCITest">
- <methods>
- <include name="importAllTestResources_toValidateNewAPI" />
- </methods>
- </class>
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.imports.ImportToscaResourceTest">
- <methods>
- <include name="importToscaResource" />
- </methods>
- </class>
- <class
- name="org.openecomp.sdc.ci.tests.execute.imports.ImportToscaCapabilitiesWithProperties">
- <methods>
- <include name="importNodeTypeWithCapabilityWithPropertiesFromYmlSucceed" />
- <include name="importResourceWithCapabilityWithPropertiesOverridingCapTypePropertiesSucceed" />
- </methods>
- </class>
- </classes>
- </test> <!-- Test -->
-
- <test name="attribute">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.attribute.ComponentInstanceAttributeTest">
- <methods>
- <include name="testUpdateAttributeOnResourceInstance" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="inputs">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.inputs.InputsApiTests">
- <methods>
- <include name="testInputsMainFunctionality" />
- </methods>
- </class>
- </classes>
- </test>
-
- <test name="property">
- <classes>
- <class
- name="org.openecomp.sdc.ci.tests.execute.property.AdditionalInformationServletTest">
- <methods>
- <include name="createResourceAdditionalInformationTestDuringLifecycle" />
- <include name="updateResourceAdditionalInformationTest" />
- <include name="deleteResourceAdditionalInformationTest" />
- </methods>
- </class>
-
- <class name="org.openecomp.sdc.ci.tests.execute.property.PropertyApisTest">
- <methods>
- <include name="testPropertyApis" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.ci.tests.execute.property.ComponentInstancePropertyTest">
- <methods>
- <include name="nestedVfResourceProperty3Levels" />
- </methods>
- </class>
-
-
-
- <!-- <class name="org.openecomp.sdc.ci.tests.execute.property.PropertyServletTest">
- <methods> <include name="createCascadeVfResource" /> <include name="createPropertyTestSetClearDefaultValueInetegr"
- /> </methods> </class> -->
- </classes>
- </test>
-
- <test name="User">
- <classes>
-
- <!-- class
- name="org.openecomp.sdc.ci.tests.execute.user.ActivateDeActivateDeleteUser">
- <methods>
- <include name="authorizeDeActivatedUser" />
- </methods>
- </class-->
-
- <class name="org.openecomp.sdc.ci.tests.execute.user.CreateUserApiTest">
- <methods>
- <include name="createUser" />
- </methods>
- </class>
-
- <class
- name="org.openecomp.sdc.ci.tests.execute.user.GovernorWorkspaceApiTest">
- <methods>
- <include name="governorList_AllCertifiedVersionsOfService" />
- </methods>
- </class>
-
- </classes>
- </test>
-
- <test name="ExternalApis">
- <classes>
- <class name="org.openecomp.sdc.externalApis.GetAssetServlet" >
- <methods>
- <include name="getResourceAssetSuccess" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.externalApis.GetFilteredAssetServlet">
- <methods>
- <include name="getResourceAssetBySpecifiedCategoryAndSubCategory" />
- <include name="getServiceAssetBySpecifiedCategoryAndDistributionStatus" />
- </methods>
- </class>
- <class name="org.openecomp.sdc.externalApis.GetSpecificAssetMetadataServlet">
- <methods>
- <include name="getResourceAssetMetadataWithResourceInstancesSuccess" />
- <include name="getServiceAssetMetadataWithCertifiedResourceInstancesAndArtifactsOnRIsAndServiceSuccess" />
- </methods>
- </class>
- </classes>
- </test>
-
-
-
-
-
-
-
-</suite> \ No newline at end of file
+ <test name="sanityE2Eflows">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.sanity.CrudE2E"/>
+ </classes>
+ </test>
+
+ <test name="General">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.general.FeProxyTest"/>
+ <class name="org.openecomp.sdc.ci.tests.execute.general.UuidTest">
+ <methods>
+ <include name="testE2EUuidHeaderReturnedAndPreserved"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+
+ <test name="ArtifactOnInstance">
+ <classes>
+ </classes>
+ </test>
+
+ <test name="Artifact">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.artifacts.DownloadComponentArt">
+ <methods>
+ <include name="downloadArtifactFromResourceTest"/>
+ <include name="downloadArtifactFromServiceTest"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+
+ <test name="Service">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.service.GetComponentAuditApiTest">
+ <methods>
+ <include name="testServiceAuditCertifiedVersion"/>
+ </methods>
+ </class>
+
+ </classes>
+ </test>
+
+ <test name="Resource">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.resource.GetAllResourceVersions">
+ <methods>
+ <include name="getResourceAllVersions_version15"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest">
+ <methods>
+ <include name="updateResourceMetadataSuccess"/>
+ </methods>
+ </class>
+
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.resource.UpdateResourceMetadataTest">
+ <methods>
+ <include name="UpdateDerivedFromSuccess"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+ <test name="Product">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckinTest">
+ <methods>
+ <include name="checkInProductByCreator"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.product.ProductCheckoutTest">
+ <methods>
+ <include name="checkOutProductByPmNotInContacts"/>
+ </methods>
+ </class>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.product.ProductGetFollowedTest">
+ <methods>
+ <include name="followedPageTest"/>
+ </methods>
+ </class>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.product.ProductUndoCheckoutTest">
+ <methods>
+ <include name="undoCheckOutProductByPm"/>
+ </methods>
+ </class>
+ <!-- Product tests end -->
+ </classes>
+ </test>
+ <test name="Catalog">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.execute.category.CatalogDataApiTest"/>
+ </classes>
+ </test>
+
+ <test name="distribution">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.distribution.AuthanticationTests">
+ <methods>
+ <include name="downloadServiceArtifactSuccessWithAutantication"/>
+ </methods>
+ </class>
+
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.distribution.DistributionDownloadArtifactTest">
+ <methods>
+ <include name="downloadResourceArtifactSuccess"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+
+ <test name="Category">
+ <classes>
+ </classes>
+ </test>
+
+ <test name="Imports">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.imports.ImportGenericResourceCITest">
+ <methods>
+ <include name="importAllTestResources"/>
+ <include name="testImportCheckoutAndUpdateUserResource"/>
+ <include name="testImportWithUpdateNormativeType"/>
+ </methods>
+ </class>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.imports.ImportToscaCapabilitiesWithProperties">
+ <methods>
+ <include name="importNodeTypeWithCapabilityWithPropertiesFromYmlSucceed"/>
+ <include
+ name="importResourceWithCapabilityWithPropertiesOverridingCapTypePropertiesSucceed"/>
+ </methods>
+ </class>
+ </classes>
+ </test> <!-- Test -->
+
+ <test name="attribute">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.attribute.ComponentInstanceAttributeTest">
+ <methods>
+ <include name="testUpdateAttributeOnResourceInstance"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+
+ <test name="inputs">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.inputs.InputsApiTests">
+ <methods>
+ <include name="testInputsMainFunctionality"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+
+ <test name="property">
+ <classes>
+ <class
+ name="org.openecomp.sdc.ci.tests.execute.property.AdditionalInformationServletTest">
+ <methods>
+ <include name="createResourceAdditionalInformationTestDuringLifecycle"/>
+ <include name="updateResourceAdditionalInformationTest"/>
+ <include name="deleteResourceAdditionalInformationTest"/>
+ </methods>
+ </class>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.property.PropertyApisTest">
+ <methods>
+ <include name="testPropertyApis"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.ci.tests.execute.property.ComponentInstancePropertyTest">
+ <methods>
+ <include name="nestedVfResourceProperty3Levels"/>
+ </methods>
+ </class>
+
+ </classes>
+ </test>
+
+ <test name="User">
+ <classes>
+
+ </classes>
+ </test>
+
+ <test name="ExternalApis">
+ <classes>
+ <class name="org.openecomp.sdc.externalApis.GetAssetServlet">
+ <methods>
+ <include name="getResourceAssetSuccess"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.externalApis.GetFilteredAssetServlet">
+ <methods>
+ <include name="getResourceAssetBySpecifiedCategoryAndSubCategory"/>
+ <include name="getServiceAssetBySpecifiedCategoryAndDistributionStatus"/>
+ </methods>
+ </class>
+ <class name="org.openecomp.sdc.externalApis.GetSpecificAssetMetadataServlet">
+ <methods>
+ <include name="getResourceAssetMetadataWithResourceInstancesSuccess"/>
+ <include
+ name="getServiceAssetMetadataWithCertifiedResourceInstancesAndArtifactsOnRIsAndServiceSuccess"/>
+ </methods>
+ </class>
+ </classes>
+ </test>
+
+
+</suite> \ No newline at end of file
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/service.xml b/test-apis-ci/src/main/resources/ci/testSuites/service.xml
index 770d2bebf0..4b2842d7fc 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/service.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/service.xml
@@ -1,14 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Service" >
- <test name="Service">
+<suite name="Service">
+ <test name="Service">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.service.GetServiceLatestVersionTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.service.CreateServiceMetadataApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.service.ReqCapOccurrencesTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.service.ChangeServiceDistributionStatusApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.service.ServiceComponentInstanceCRUDTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.service.UpdateServiceMetadataTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.service.GetAllServiceVersions"/>
<class name="org.openecomp.sdc.ci.tests.execute.interfaceoperation.InterfaceOperationsTest">
<methods>
@@ -19,6 +14,6 @@
<include name="testCreateOperationWithLocalInterfaceAndDownloadArtifact"/>
</methods>
</class>
- </classes>
- </test>
+ </classes>
+ </test>
</suite> <!-- Service -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/testngLifeCycle.xml b/test-apis-ci/src/main/resources/ci/testSuites/testngLifeCycle.xml
index 54f1868470..7f1cba4d9c 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/testngLifeCycle.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/testngLifeCycle.xml
@@ -1,27 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="lifeCycle" >
+<suite name="lifeCycle">
<test name="Test">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_cerificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceResourceLCSTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_UndoCheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_UndoCheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_StartCertificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_CheckinCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_CheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceCertWithResourceInstances"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CrossCheckOutTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CertifyVFWithNotCertRIs"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_request4CerCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CleanupIntermediateReources"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_CheckOutCIT"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_cerificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CertifyServiceWithNotCertRI"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_CheckInCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_request4CerCITest"/>
<class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_StartCertificationCITest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- lifeCycle -->
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/user.xml b/test-apis-ci/src/main/resources/ci/testSuites/user.xml
index 948993c144..3ab1f971fb 100644
--- a/test-apis-ci/src/main/resources/ci/testSuites/user.xml
+++ b/test-apis-ci/src/main/resources/ci/testSuites/user.xml
@@ -1,17 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="User" >
+<suite name="User">
<test name="Test">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.user.AuthorizedUserApiTest_extend"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.AuthorizedUserApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.OpsWorkspaceApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.UserApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.GetAllAdminUsersApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.CRUDUserTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.CreateUserApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.GovernorWorkspaceApiTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.user.GetListsOfTesterUserApiTest"/>
<class name="org.openecomp.sdc.ci.tests.execute.user.ActivateDeActivateDeleteUser"/>
</classes>
</test> <!-- Test -->
diff --git a/test-apis-ci/testng.xml b/test-apis-ci/testng.xml
index 8a47ef6d62..f06b75aacf 100644
--- a/test-apis-ci/testng.xml
+++ b/test-apis-ci/testng.xml
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Suite" >
- <listeners>
- <listener class-name="org.openecomp.sdc.ci.tests.run.ExtentReporterNG" />
- </listeners>
+<suite name="Suite">
+ <listeners>
+ </listeners>
<test name="Test">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.category.CategoriesTests"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
diff --git a/test-apis-ci/testngLifeCycle.xml b/test-apis-ci/testngLifeCycle.xml
index aa390dc213..005bdba0f3 100644
--- a/test-apis-ci/testngLifeCycle.xml
+++ b/test-apis-ci/testngLifeCycle.xml
@@ -3,25 +3,7 @@
<suite name="lifeCycle" parallel="none">
<test name="Test">
<classes>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_cerificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceResourceLCSTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_UndoCheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_UndoCheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_StartCertificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_CheckinCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_CheckOutCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceCertWithResourceInstances"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CrossCheckOutTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CertifyVFWithNotCertRIs"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_request4CerCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CleanupIntermediateReources"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_CheckOutCIT"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_cerificationCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.CertifyServiceWithNotCertRI"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCS_CheckInCITest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_request4CerCITest"/>
<class name="org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest"/>
- <class name="org.openecomp.sdc.ci.tests.execute.lifecycle.ServiceLCS_StartCertificationCITest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- lifeCycle -->
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java
index b1a5b5060e..5dd7412666 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java
@@ -103,7 +103,7 @@ public class AdminUserManagment extends SetupCDTest {
// design changed and now one letter user should exist
//TC922253
- @Test(enabled = false)
+ @Test(enabled = true)
public void createInvalidMacIdTest() {
ExtentTestActions.log(Status.INFO, "Open bug 324032");
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java
index f9cb233448..5e240c025b 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java
@@ -289,7 +289,7 @@ public class ImportDCAE extends SetupCDTest {
}
// future removed from ui
- @Test(enabled = false)
+ @Test(enabled = true)
public void addUpdateDeleteSimplePropertiesToDCAEAssetTest() throws Exception {
createDCAEAsset();
@@ -313,7 +313,7 @@ public class ImportDCAE extends SetupCDTest {
}
// future removed from ui
- @Test(enabled = false)
+ @Test(enabled = true)
public void DCAEAssetInstancesInputScreenTest() throws Exception {
createDCAEAsset();
@@ -454,7 +454,7 @@ public class ImportDCAE extends SetupCDTest {
}
// future removed from ui
- @Test(enabled = false)
+ @Test(enabled = true)
public void addPropertyInCompositionScreenDCAEAssetTest() throws Exception {
createDCAEAsset();
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java
index fc4dd88185..df94a14b58 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java
@@ -569,7 +569,7 @@ public class Service extends SetupCDTest {
}
// future removed from ui
- @Test(enabled = false)
+ @Test(enabled = true)
public void inputsTest() throws Exception {
String fileName = "service_input_test_VF2.csar";
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java
index fe6718eea2..accea723b8 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java
@@ -340,7 +340,7 @@ public class VfAPI extends SetupCDTest {
}*/
// future removed from ui
- @Test(enabled = false)
+ @Test(enabled = true)
public void addUpdateDeleteSimplePropertiesToVfTest() throws Exception {
ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
ResourceUIUtils.createVF(vfMetaData, getUser());
@@ -366,7 +366,7 @@ public class VfAPI extends SetupCDTest {
}
// future removed from ui
- @Test(enabled = false)
+ @Test(enabled = true)
public void vfcInstancesInputScreenTest() throws Exception {
ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
ResourceUIUtils.createVF(vfMetaData, getUser());
@@ -450,7 +450,7 @@ public class VfAPI extends SetupCDTest {
VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser());
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testDownload() throws Exception {
// ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
// ResourceUIUtils.createResource(vfMetaData, getUser());
@@ -542,7 +542,7 @@ public class VfAPI extends SetupCDTest {
}
// future removed from ui
- @Test(enabled = false)
+ @Test(enabled = true)
public void addPropertyInCompositionScreenTest() throws Exception {
ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
ResourceUIUtils.createVF(vfMetaData, getUser());
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java
index f0d9d720ef..4523571085 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java
@@ -204,7 +204,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
// TC1438232 - Import VF Artifacts - Informational Artifacts - Artifact Name To Long
// TODO: make informational artifact name longer then 255
// TODO: windows/linux not allowed it
- @Test(enabled = false)
+ @Test(enabled = true)
public void importVfArtifactsInformationalArtifactsArtifactNameToLong() throws Exception {
String folder = "US825779";
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());