summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
committerMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
commited64b5edff15e702493df21aa3230b81593e6133 (patch)
treea4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-model/src/test
parent280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff)
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java3
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/JsonObjectTest.java12
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java36
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java172
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java45
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationSpringTest.java94
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java23
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentOperationTest.java102
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java3
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/HeatParametersOperationTest.java60
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java48
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/LifecycleOperationTest.java778
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java12
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java49
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RequirementOperationTest.java54
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceInstanceOperationTest.java787
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperationTest.java381
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ServiceOperationTest.java192
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaDefinitionPathCalculatorTest.java61
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java579
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java62
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java2
-rw-r--r--catalog-model/src/test/resources/application-context-test.xml2
23 files changed, 1946 insertions, 1611 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java
index f18aa61b74..c8917763a8 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java
@@ -33,8 +33,7 @@ public class ModelTestBase {
public static void init() {
if (ConfigurationManager.getConfigurationManager() == null) {
String appConfigDir = "src/test/resources/config";
- ConfigurationSource configurationSource = new FSConfigurationSource(
- ExternalConfiguration.getChangeListener(), appConfigDir);
+ ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
configurationManager = new ConfigurationManager(configurationSource);
Configuration configuration = new Configuration();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/JsonObjectTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/JsonObjectTest.java
index dd102e7ed5..b3476529e8 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/JsonObjectTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/JsonObjectTest.java
@@ -39,10 +39,8 @@ public class JsonObjectTest {
private ObjectMapper mapper;
UploadResourceInfo inputObjectRef;
- private final String INPUT_RESOURCE_STRING = "{ \"payloadData\" : \"My Test Object\", \"payloadName\" : \"TestName\", "
- + " \"description\":\"my_description\",\"tags\":[\"tag1\"], "
- + "\"artifactList\" : [ { \"artifactName\" : \"myArtifact0\", \"artifactPath\" : \"scripts/\", \"artifactType\" : \"PUPPET\", "
- + " \"artifactDescription\" : \"This is Description\", \"artifactData\" : null }, "
+ private final String INPUT_RESOURCE_STRING = "{ \"payloadData\" : \"My Test Object\", \"payloadName\" : \"TestName\", " + " \"description\":\"my_description\",\"tags\":[\"tag1\"], "
+ + "\"artifactList\" : [ { \"artifactName\" : \"myArtifact0\", \"artifactPath\" : \"scripts/\", \"artifactType\" : \"PUPPET\", " + " \"artifactDescription\" : \"This is Description\", \"artifactData\" : null }, "
+ "{ \"artifactName\" : \"myArtifact1\", \"artifactPath\" : \"scripts/\", \"artifactType\" : \"PUPPET\", \"artifactDescription\" : \"This is Description\", "
+ " \"artifactData\" : null } ], \"contactId\" : null, \"name\" : null, \"resourceIconPath\" : null, \"vendorName\" : null, \"vendorRelease\" : null , \"resourceType\" : \"VFC\" }";
@@ -51,14 +49,12 @@ public class JsonObjectTest {
mapper = new ObjectMapper();
ArrayList<UploadArtifactInfo> artifactList = new ArrayList<UploadArtifactInfo>();
for (int i = 0; i < 2; i++) {
- UploadArtifactInfo artifactInfo = new UploadArtifactInfo("myArtifact" + i, "scripts/",
- ArtifactTypeEnum.PUPPET, "This is Description");
+ UploadArtifactInfo artifactInfo = new UploadArtifactInfo("myArtifact" + i, "scripts/", ArtifactTypeEnum.PUPPET, "This is Description");
artifactList.add(artifactInfo);
}
ArrayList<String> tags = new ArrayList<>();
tags.add("tag1");
- inputObjectRef = new UploadResourceInfo("My Test Object", "TestName", "my_description", null, tags,
- artifactList);
+ inputObjectRef = new UploadResourceInfo("My Test Object", "TestName", "my_description", null, tags, artifactList);
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java
index 3e871f1fa0..eea11b6625 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java
@@ -21,46 +21,26 @@
package org.openecomp.sdc.be.model.operations.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.ModelTestBase;
-import org.openecomp.sdc.be.model.Operation;
-import org.openecomp.sdc.be.model.Point;
-import org.openecomp.sdc.be.model.PropertyConstraint;
-import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.operations.api.IAdditionalInformationOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
-import org.openecomp.sdc.be.model.tosca.ToscaType;
-import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint;
-import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint;
-import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint;
import org.openecomp.sdc.be.resources.data.UserData;
-import org.openecomp.sdc.exception.DeleteReferencedObjectException;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -76,9 +56,7 @@ import fj.data.Either;
@ContextConfiguration("classpath:application-context-test.xml")
public class AdditionalInformationOperationTest extends ModelTestBase {
- private Gson prettyGson = new GsonBuilder().setPrettyPrinting().create();
-
- private static String USER_ID = "muuserid";
+ private static String USER_ID = "muUserId";
private static String CATEGORY_NAME = "category/mycategory";
@javax.annotation.Resource(name = "titan-generic-dao")
@@ -136,8 +114,7 @@ public class AdditionalInformationOperationTest extends ModelTestBase {
int before = getNumberOfVerticesOnGraph();
- Resource newResource = createResource(USER_ID, CATEGORY_NAME, "testCreateAndDeleteResource", "0.1", null, false,
- true);
+ Resource newResource = createResource(USER_ID, CATEGORY_NAME, "testCreateAndDeleteResource", "0.1", null, false, true);
String resourceId = newResource.getUniqueId();
Either<Resource, StorageOperationStatus> deleteResource = resourceOperation.deleteResource(resourceId);
@@ -148,8 +125,7 @@ public class AdditionalInformationOperationTest extends ModelTestBase {
assertEquals("check number of vertices not changed", before, after);
}
- private Resource buildResourceMetadata(String userId, String category, String resourceName,
- String resourceVersion) {
+ private Resource buildResourceMetadata(String userId, String category, String resourceName, String resourceVersion) {
Resource resource = new Resource();
resource.setName(resourceName);
@@ -189,8 +165,7 @@ public class AdditionalInformationOperationTest extends ModelTestBase {
OperationTestsUtil.deleteAndCreateResourceCategory(names[0], names[1], titanDao);
}
- public Resource createResource(String userId, String category, String resourceName, String resourceVersion,
- String parentResourceName, boolean isAbstract, boolean isHighestVersion) {
+ public Resource createResource(String userId, String category, String resourceName, String resourceVersion, String parentResourceName, boolean isAbstract, boolean isHighestVersion) {
List<String> derivedFrom = new ArrayList<String>();
if (parentResourceName != null) {
@@ -206,8 +181,7 @@ public class AdditionalInformationOperationTest extends ModelTestBase {
assertTrue(result.isLeft());
Resource resultResource = result.left().value();
- assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT,
- resultResource.getLifecycleState());
+ assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultResource.getLifecycleState());
return resultResource;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java
index 0143e50dc7..875c34b780 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java
@@ -21,9 +21,9 @@
package org.openecomp.sdc.be.model.operations.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import java.util.ArrayList;
import java.util.HashMap;
@@ -48,6 +48,16 @@ import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
+import org.openecomp.sdc.be.model.operations.impl.CapabilityOperation;
+import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation;
+import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation;
+import org.openecomp.sdc.be.model.operations.impl.LifecycleOperation;
+import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
+import org.openecomp.sdc.be.model.operations.impl.RequirementOperation;
+import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
+import org.openecomp.sdc.be.model.operations.impl.ServiceOperation;
+import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
import org.openecomp.sdc.be.resources.data.ArtifactData;
import org.openecomp.sdc.be.resources.data.HeatParameterData;
@@ -106,7 +116,7 @@ public class ArtifactOperationTest extends ModelTestBase {
private static String RESOURCE_ID = "resourceId";
private static String RESOURCE_ID_2 = "resourceId2";
- private static String USER_ID = "muserid";
+ private static String USER_ID = "muUserId";
private static String CATEGORY_NAME = "category/mycategory";
@BeforeClass
@@ -121,7 +131,7 @@ public class ArtifactOperationTest extends ModelTestBase {
deleteAndCreateUser(USER_ID, "first_" + USER_ID, "last_" + USER_ID, null);
}
-// @Test
+ @Test
public void testAddArtifactToServiceVersionAndUUIDNotNull() {
CategoryDefinition category = new CategoryDefinition();
category.setName(CATEGORY_NAME);
@@ -135,11 +145,9 @@ public class ArtifactOperationTest extends ModelTestBase {
ArtifactDefinition artifactInfo = addArtifactToService(userId, serviceId, "install_apache");
- assertEquals("add informational artifact version : " + artifactInfo.getArtifactVersion(), "1",
- artifactInfo.getArtifactVersion());
+ assertEquals("add informational artifact version : " + artifactInfo.getArtifactVersion(), "1", artifactInfo.getArtifactVersion());
- assertNotNull("add informational artifact version : " + artifactInfo.getArtifactUUID(),
- artifactInfo.getArtifactUUID());
+ assertNotNull("add informational artifact version : " + artifactInfo.getArtifactUUID(), artifactInfo.getArtifactUUID());
Either<Service, StorageOperationStatus> service = serviceOperation.getService(serviceId);
assertTrue(service.isLeft());
@@ -159,8 +167,7 @@ public class ArtifactOperationTest extends ModelTestBase {
Either<Service, StorageOperationStatus> serviceDelete = serviceOperation.deleteService(serviceId);
- Either<List<ArtifactData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef,
- null, ArtifactData.class);
+ Either<List<ArtifactData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef, null, ArtifactData.class);
assertTrue(byCriteria.isRight());
assertEquals(TitanOperationStatus.NOT_FOUND, byCriteria.right().value());
@@ -168,7 +175,7 @@ public class ArtifactOperationTest extends ModelTestBase {
}
-// @Test
+ @Test
public void testUpdateArtifactToServiceVersionNotChanged() {
CategoryDefinition category = new CategoryDefinition();
category.setName(CATEGORY_NAME);
@@ -187,8 +194,7 @@ public class ArtifactOperationTest extends ModelTestBase {
artifactInfo.setDescription("jghlsk new desfnjdh");
- Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation.updateArifactOnResource(
- artifactInfo, serviceId, artifactInfo.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation.updateArifactOnResource(artifactInfo, serviceId, artifactInfo.getUniqueId(), NodeTypeEnum.Service, false);
String newVersion = artifact.left().value().getArtifactVersion();
String newArtUuid = artifactInfo.getArtifactUUID();
assertEquals("add informational artifact version : " + newVersion, newVersion, version);
@@ -212,8 +218,7 @@ public class ArtifactOperationTest extends ModelTestBase {
Either<Service, StorageOperationStatus> serviceDelete = serviceOperation.deleteService(serviceId);
- Either<List<ArtifactData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef,
- null, ArtifactData.class);
+ Either<List<ArtifactData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef, null, ArtifactData.class);
assertTrue(byCriteria.isRight());
assertEquals(TitanOperationStatus.NOT_FOUND, byCriteria.right().value());
@@ -226,26 +231,22 @@ public class ArtifactOperationTest extends ModelTestBase {
ArtifactDefinition artifactWithHeat = createResourceWithHeat();
- List<HeatParameterDefinition> heatParameters = artifactWithHeat.getHeatParameters();
+ List<HeatParameterDefinition> heatParameters = artifactWithHeat.getListHeatParameters();
assertNotNull(heatParameters);
assertTrue(heatParameters.size() == 1);
HeatParameterDefinition parameter = heatParameters.get(0);
HeatParameterData parameterData = new HeatParameterData(parameter);
- Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(),
- parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNode.isLeft());
- Either<ArtifactDefinition, StorageOperationStatus> removeArifact = artifactOperation.removeArifactFromResource(
- RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false);
+ Either<ArtifactDefinition, StorageOperationStatus> removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false);
assertTrue(removeArifact.isLeft());
ArtifactData artifactData = new ArtifactData(artifactWithHeat);
- Either<ArtifactData, TitanOperationStatus> artifactAfterDelete = titanDao.getNode(artifactData.getUniqueIdKey(),
- artifactData.getUniqueId(), ArtifactData.class);
+ Either<ArtifactData, TitanOperationStatus> artifactAfterDelete = titanDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class);
assertTrue(artifactAfterDelete.isRight());
- Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao
- .getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNodeAfterDelete.isRight());
titanDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID), ResourceMetadataData.class);
@@ -256,13 +257,12 @@ public class ArtifactOperationTest extends ModelTestBase {
ArtifactDefinition artifactWithHeat = createResourceWithHeat();
- List<HeatParameterDefinition> heatParameters = artifactWithHeat.getHeatParameters();
+ List<HeatParameterDefinition> heatParameters = artifactWithHeat.getListHeatParameters();
assertNotNull(heatParameters);
assertTrue(heatParameters.size() == 1);
HeatParameterDefinition parameter = heatParameters.get(0);
HeatParameterData parameterData = new HeatParameterData(parameter);
- Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(),
- parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNode.isLeft());
// update to artifact without params
@@ -272,24 +272,19 @@ public class ArtifactOperationTest extends ModelTestBase {
artifactNoParams.setArtifactVersion("2");
artifactNoParams.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- Either<ArtifactDefinition, StorageOperationStatus> updateArifact = artifactOperation.updateArifactOnResource(
- artifactNoParams, RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<ArtifactDefinition, StorageOperationStatus> updateArifact = artifactOperation.updateArifactOnResource(artifactNoParams, RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false);
assertTrue(updateArifact.isLeft());
ArtifactData artifactData = new ArtifactData(artifactWithHeat);
- Either<ArtifactData, TitanOperationStatus> artifactAfterUpdate = titanDao.getNode(artifactData.getUniqueIdKey(),
- artifactData.getUniqueId(), ArtifactData.class);
+ Either<ArtifactData, TitanOperationStatus> artifactAfterUpdate = titanDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class);
assertTrue(artifactAfterUpdate.isLeft());
ArtifactData artifactAfterUpdateValue = artifactAfterUpdate.left().value();
- assertTrue(artifactNoParams.getArtifactVersion()
- .equals(artifactAfterUpdateValue.getArtifactDataDefinition().getArtifactVersion()));
+ assertTrue(artifactNoParams.getArtifactVersion().equals(artifactAfterUpdateValue.getArtifactDataDefinition().getArtifactVersion()));
- Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao
- .getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNodeAfterDelete.isRight());
- artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource,
- true, false);
+ artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false);
titanDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID), ResourceMetadataData.class);
titanDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID_2), ResourceMetadataData.class);
}
@@ -299,13 +294,12 @@ public class ArtifactOperationTest extends ModelTestBase {
ArtifactDefinition artifactWithHeat = createResourceWithHeat();
- List<HeatParameterDefinition> heatParameters = artifactWithHeat.getHeatParameters();
+ List<HeatParameterDefinition> heatParameters = artifactWithHeat.getListHeatParameters();
assertNotNull(heatParameters);
assertTrue(heatParameters.size() == 1);
HeatParameterDefinition parameter = heatParameters.get(0);
HeatParameterData parameterData = new HeatParameterData(parameter);
- Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(),
- parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNode.isLeft());
// update to artifact without params
@@ -313,26 +307,20 @@ public class ArtifactOperationTest extends ModelTestBase {
artifactWithHeat.setArtifactChecksum(null);
artifactWithHeat.setPayloadData(null);
- Either<ArtifactDefinition, StorageOperationStatus> updateArifact = artifactOperation.updateArifactOnResource(
- artifactWithHeat, RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<ArtifactDefinition, StorageOperationStatus> updateArifact = artifactOperation.updateArifactOnResource(artifactWithHeat, RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false);
assertTrue(updateArifact.isLeft());
ArtifactData artifactData = new ArtifactData(artifactWithHeat);
- Either<ArtifactData, TitanOperationStatus> artifactAfterUpdate = titanDao.getNode(artifactData.getUniqueIdKey(),
- artifactData.getUniqueId(), ArtifactData.class);
+ Either<ArtifactData, TitanOperationStatus> artifactAfterUpdate = titanDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class);
assertTrue(artifactAfterUpdate.isLeft());
ArtifactData artifactAfterUpdateValue = artifactAfterUpdate.left().value();
- assertTrue(artifactWithHeat.getArtifactVersion()
- .equals(artifactAfterUpdateValue.getArtifactDataDefinition().getArtifactVersion()));
+ assertTrue(artifactWithHeat.getArtifactVersion().equals(artifactAfterUpdateValue.getArtifactDataDefinition().getArtifactVersion()));
- Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao
- .getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNodeAfterDelete.isLeft());
- Either<ArtifactDefinition, StorageOperationStatus> removeArifact = artifactOperation.removeArifactFromResource(
- RESOURCE_ID_2, (String) artifactAfterUpdateValue.getUniqueId(), NodeTypeEnum.Resource, true, false);
- removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(),
- NodeTypeEnum.Resource, true, false);
+ Either<ArtifactDefinition, StorageOperationStatus> removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID_2, (String) artifactAfterUpdateValue.getUniqueId(), NodeTypeEnum.Resource, true, false);
+ removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false);
titanDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID), ResourceMetadataData.class);
titanDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID_2), ResourceMetadataData.class);
@@ -345,17 +333,15 @@ public class ArtifactOperationTest extends ModelTestBase {
ResourceMetadataData resource2 = createResource(RESOURCE_ID_2);
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), ArtifactGroupTypeEnum.DEPLOYMENT.name());
- Either<GraphRelation, TitanOperationStatus> createRelation = titanDao.createRelation(resource2,
- new ArtifactData(artifactWithHeat), GraphEdgeLabels.ARTIFACT_REF, props);
+ Either<GraphRelation, TitanOperationStatus> createRelation = titanDao.createRelation(resource2, new ArtifactData(artifactWithHeat), GraphEdgeLabels.ARTIFACT_REF, props);
assertTrue(createRelation.isLeft());
- List<HeatParameterDefinition> heatParameters = artifactWithHeat.getHeatParameters();
+ List<HeatParameterDefinition> heatParameters = artifactWithHeat.getListHeatParameters();
assertNotNull(heatParameters);
assertTrue(heatParameters.size() == 1);
HeatParameterDefinition parameter = heatParameters.get(0);
HeatParameterData parameterData = new HeatParameterData(parameter);
- Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(),
- parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNode = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNode.isLeft());
ArtifactDefinition atifactToUpdate = new ArtifactDefinition(artifactWithHeat);
@@ -369,74 +355,59 @@ public class ArtifactOperationTest extends ModelTestBase {
List<HeatParameterDefinition> heatParametersUpdated = new ArrayList<HeatParameterDefinition>();
heatParamUpdate.setCurrentValue("55");
heatParametersUpdated.add(heatParamUpdate);
- atifactToUpdate.setHeatParameters(heatParametersUpdated);
+ atifactToUpdate.setListHeatParameters(heatParametersUpdated);
- Either<ArtifactDefinition, StorageOperationStatus> updateArifact = artifactOperation.updateArifactOnResource(
- atifactToUpdate, RESOURCE_ID_2, atifactToUpdate.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<ArtifactDefinition, StorageOperationStatus> updateArifact = artifactOperation.updateArifactOnResource(atifactToUpdate, RESOURCE_ID_2, atifactToUpdate.getUniqueId(), NodeTypeEnum.Resource, false);
assertTrue(updateArifact.isLeft());
// verify old artifact and parameter still exist
ArtifactData artifactData = new ArtifactData(artifactWithHeat);
- Either<ArtifactData, TitanOperationStatus> origArtifact = titanDao.getNode(artifactData.getUniqueIdKey(),
- artifactData.getUniqueId(), ArtifactData.class);
+ Either<ArtifactData, TitanOperationStatus> origArtifact = titanDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class);
assertTrue(origArtifact.isLeft());
ArtifactData origArtifactData = origArtifact.left().value();
- assertTrue(artifactWithHeat.getArtifactVersion()
- .equals(origArtifactData.getArtifactDataDefinition().getArtifactVersion()));
+ assertTrue(artifactWithHeat.getArtifactVersion().equals(origArtifactData.getArtifactDataDefinition().getArtifactVersion()));
- Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao
- .getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterDelete = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNodeAfterDelete.isLeft());
// verify new artifact and new parameter
ArtifactDefinition artifactDefinitionUpdated = updateArifact.left().value();
ArtifactData artifactDataUpdated = new ArtifactData(artifactDefinitionUpdated);
- Either<ArtifactData, TitanOperationStatus> updatedArtifact = titanDao
- .getNode(artifactDataUpdated.getUniqueIdKey(), artifactDataUpdated.getUniqueId(), ArtifactData.class);
+ Either<ArtifactData, TitanOperationStatus> updatedArtifact = titanDao.getNode(artifactDataUpdated.getUniqueIdKey(), artifactDataUpdated.getUniqueId(), ArtifactData.class);
assertTrue(updatedArtifact.isLeft());
ArtifactData updatedArtifactData = updatedArtifact.left().value();
- assertTrue(atifactToUpdate.getArtifactVersion()
- .equals(updatedArtifactData.getArtifactDataDefinition().getArtifactVersion()));
- assertFalse(
- ((String) updatedArtifactData.getUniqueId()).equalsIgnoreCase((String) origArtifactData.getUniqueId()));
+ assertTrue(atifactToUpdate.getArtifactVersion().equals(updatedArtifactData.getArtifactDataDefinition().getArtifactVersion()));
+ assertFalse(((String) updatedArtifactData.getUniqueId()).equalsIgnoreCase((String) origArtifactData.getUniqueId()));
- List<HeatParameterDefinition> heatParametersAfterUpdate = artifactDefinitionUpdated.getHeatParameters();
+ List<HeatParameterDefinition> heatParametersAfterUpdate = artifactDefinitionUpdated.getListHeatParameters();
assertNotNull(heatParametersAfterUpdate);
assertTrue(heatParametersAfterUpdate.size() == 1);
HeatParameterDefinition UpdatedHeatParameter = heatParametersAfterUpdate.get(0);
assertFalse(UpdatedHeatParameter.getUniqueId().equalsIgnoreCase((String) parameterData.getUniqueId()));
- Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterUpdate = titanDao.getNode(
- new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(), UpdatedHeatParameter.getUniqueId(),
- HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> parameterNodeAfterUpdate = titanDao.getNode(new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(), UpdatedHeatParameter.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNodeAfterUpdate.isLeft());
// delete new artifact
- Either<ArtifactDefinition, StorageOperationStatus> removeArifact = artifactOperation.removeArifactFromResource(
- RESOURCE_ID_2, artifactDefinitionUpdated.getUniqueId(), NodeTypeEnum.Resource, true, false);
+ Either<ArtifactDefinition, StorageOperationStatus> removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID_2, artifactDefinitionUpdated.getUniqueId(), NodeTypeEnum.Resource, true, false);
assertTrue(removeArifact.isLeft());
// verify old artifact and parameter still exist
origArtifact = titanDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class);
assertTrue(origArtifact.isLeft());
origArtifactData = origArtifact.left().value();
- assertTrue(artifactWithHeat.getArtifactVersion()
- .equals(origArtifactData.getArtifactDataDefinition().getArtifactVersion()));
+ assertTrue(artifactWithHeat.getArtifactVersion().equals(origArtifactData.getArtifactDataDefinition().getArtifactVersion()));
- parameterNodeAfterDelete = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(),
- HeatParameterData.class);
+ parameterNodeAfterDelete = titanDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class);
assertTrue(parameterNodeAfterDelete.isLeft());
// verify new artifact is deleted
- Either<ArtifactData, TitanOperationStatus> artifactAfterDelete = titanDao
- .getNode(artifactDataUpdated.getUniqueIdKey(), artifactDataUpdated.getUniqueId(), ArtifactData.class);
+ Either<ArtifactData, TitanOperationStatus> artifactAfterDelete = titanDao.getNode(artifactDataUpdated.getUniqueIdKey(), artifactDataUpdated.getUniqueId(), ArtifactData.class);
assertTrue(artifactAfterDelete.isRight());
- parameterNodeAfterDelete = titanDao.getNode(new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(),
- new HeatParameterData(UpdatedHeatParameter).getUniqueId(), HeatParameterData.class);
+ parameterNodeAfterDelete = titanDao.getNode(new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(), new HeatParameterData(UpdatedHeatParameter).getUniqueId(), HeatParameterData.class);
assertTrue(parameterNodeAfterDelete.isRight());
- artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource,
- true, false);
+ artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false);
titanDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID), ResourceMetadataData.class);
titanDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID_2), ResourceMetadataData.class);
}
@@ -455,10 +426,9 @@ public class ArtifactOperationTest extends ModelTestBase {
heatParam.setName("myParam");
heatParam.setType("number");
heatParams.add(heatParam);
- artifactDefinition.setHeatParameters(heatParams);
+ artifactDefinition.setListHeatParameters(heatParams);
- Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation
- .addArifactToComponent(artifactDefinition, RESOURCE_ID, NodeTypeEnum.Resource, true, false);
+ Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation.addArifactToComponent(artifactDefinition, RESOURCE_ID, NodeTypeEnum.Resource, true, false);
assertTrue(artifact.isLeft());
ArtifactDefinition artifactWithHeat = artifact.left().value();
return artifactWithHeat;
@@ -467,8 +437,7 @@ public class ArtifactOperationTest extends ModelTestBase {
private ArtifactDefinition addArtifactToService(String userId, String serviceId, String artifactName) {
ArtifactDefinition artifactInfo = createArtifactDefinition(userId, serviceId, artifactName);
- Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation
- .addArifactToComponent(artifactInfo, serviceId, NodeTypeEnum.Service, true, true);
+ Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation.addArifactToComponent(artifactInfo, serviceId, NodeTypeEnum.Service, true, true);
assertTrue(artifact.isLeft());
return artifact.left().value();
}
@@ -494,8 +463,7 @@ public class ArtifactOperationTest extends ModelTestBase {
return artifactInfo;
}
- public Service createService(String userId, CategoryDefinition category, String serviceName, String serviceVersion,
- boolean isHighestVersion) {
+ public Service createService(String userId, CategoryDefinition category, String serviceName, String serviceVersion, boolean isHighestVersion) {
Service service = buildServiceMetadata(userId, category, serviceName, serviceVersion);
@@ -510,14 +478,12 @@ public class ArtifactOperationTest extends ModelTestBase {
// assertEquals("check resource unique id",
// UniqueIdBuilder.buildServiceUniqueId(serviceName, serviceVersion),
// resultService.getUniqueId());
- assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT,
- resultService.getLifecycleState());
+ assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultService.getLifecycleState());
return resultService;
}
- private Service buildServiceMetadata(String userId, CategoryDefinition category, String serviceName,
- String serviceVersion) {
+ private Service buildServiceMetadata(String userId, CategoryDefinition category, String serviceName, String serviceVersion) {
Service service = new Service();
service.setName(serviceName);
@@ -541,6 +507,13 @@ public class ArtifactOperationTest extends ModelTestBase {
String[] names = category.split("/");
OperationTestsUtil.deleteAndCreateServiceCategory(category, titanDao);
OperationTestsUtil.deleteAndCreateResourceCategory(names[0], names[1], titanDao);
+
+ /*
+ * CategoryData categoryData = new CategoryData(); categoryData.setName(category);
+ *
+ * titanDao.deleteNode(categoryData, CategoryData.class); Either<CategoryData, TitanOperationStatus> createNode = titanDao.createNode(categoryData, CategoryData.class); System.out.println("after creating caetgory " + createNode);
+ */
+
}
private UserData deleteAndCreateUser(String userId, String firstName, String lastName, String role) {
@@ -565,8 +538,7 @@ public class ArtifactOperationTest extends ModelTestBase {
ResourceMetadataData serviceData1 = new ResourceMetadataData();
serviceData1.getMetadataDataDefinition().setUniqueId(resourceName);
- Either<ResourceMetadataData, TitanOperationStatus> createNode = titanDao.createNode(serviceData1,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> createNode = titanDao.createNode(serviceData1, ResourceMetadataData.class);
assertTrue("check resource created", createNode.isLeft());
return createNode.left().value();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
index 5b8420d5dc..f6f02457d5 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
@@ -118,22 +118,18 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
capabilityTypeDefinition.setDescription("desc1");
capabilityTypeDefinition.setType("tosca.capabilities.Container1");
- Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation
- .addCapabilityType(capabilityTypeDefinition, true);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true);
assertEquals("check capability type added", true, addCapabilityType1.isLeft());
CapabilityTypeDefinition capabilityTypeAdded = addCapabilityType1.left().value();
compareBetweenCreatedToSent(capabilityTypeDefinition, capabilityTypeAdded);
- Either<CapabilityTypeDefinition, TitanOperationStatus> capabilityTypeByUid = capabilityTypeOperation
- .getCapabilityTypeByUid(capabilityTypeAdded.getUniqueId());
+ Either<CapabilityTypeDefinition, TitanOperationStatus> capabilityTypeByUid = capabilityTypeOperation.getCapabilityTypeByUid(capabilityTypeAdded.getUniqueId());
compareBetweenCreatedToSent(capabilityTypeByUid.left().value(), capabilityTypeDefinition);
- Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType2 = capabilityTypeOperation
- .addCapabilityType(capabilityTypeDefinition, true);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType2 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true);
assertEquals("check capability type failed", true, addCapabilityType2.isRight());
- assertEquals("check returned error", StorageOperationStatus.SCHEMA_VIOLATION,
- addCapabilityType2.right().value());
+ assertEquals("check returned error", StorageOperationStatus.SCHEMA_VIOLATION, addCapabilityType2.right().value());
}
@@ -145,14 +141,12 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
capabilityTypeDefinition.setType("tosca.capabilities.Container2");
capabilityTypeDefinition.setDerivedFrom("derivedFrom");
- Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation
- .addCapabilityType(capabilityTypeDefinition, true);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true);
// assertEquals("check capability type parent not exist",
// StorageOperationStatus.INVALID_ID,
// addCapabilityType1.right().value());
// TODO: esofer change to INVALID_ID
- assertEquals("check capability type parent not exist", StorageOperationStatus.INVALID_ID,
- addCapabilityType1.right().value());
+ assertEquals("check capability type parent not exist", StorageOperationStatus.INVALID_ID, addCapabilityType1.right().value());
}
public CapabilityTypeDefinition createCapability(String capabilityTypeName) {
@@ -176,12 +170,10 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
capabilityTypeDefinition.setProperties(properties);
- Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation
- .addCapabilityType(capabilityTypeDefinition, true);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true);
CapabilityTypeDefinition capabilityTypeDefinitionCreated = addCapabilityType1.left().value();
- Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityType = capabilityTypeOperation
- .getCapabilityType(capabilityTypeDefinitionCreated.getUniqueId(), true);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityType = capabilityTypeOperation.getCapabilityType(capabilityTypeDefinitionCreated.getUniqueId(), true);
assertEquals("check capability type fetched", true, capabilityType.isLeft());
CapabilityTypeDefinition fetchedCTD = capabilityType.left().value();
@@ -215,12 +207,10 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
capabilityTypeDefinition.setProperties(properties);
- Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation
- .addCapabilityType(capabilityTypeDefinition, true);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true);
CapabilityTypeDefinition capabilityTypeDefinitionCreated = addCapabilityType1.left().value();
- Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityType = capabilityTypeOperation
- .getCapabilityType(capabilityTypeDefinitionCreated.getUniqueId());
+ Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityType = capabilityTypeOperation.getCapabilityType(capabilityTypeDefinitionCreated.getUniqueId());
assertEquals("check capability type fetched", true, capabilityType.isLeft());
CapabilityTypeDefinition fetchedCTD = capabilityType.left().value();
@@ -231,8 +221,7 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
private void compareProperties(Map<String, PropertyDefinition> first, Map<String, PropertyDefinition> second) {
- assertTrue("check properties are full or empty",
- ((first == null && second == null) || (first != null && second != null)));
+ assertTrue("check properties are full or empty", ((first == null && second == null) || (first != null && second != null)));
if (first != null) {
assertEquals("check properties size", first.size(), second.size());
@@ -254,16 +243,14 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
@Test
public void testGetCapabilityTypeNotFound() {
- Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityType = capabilityTypeOperation
- .getCapabilityType("not_exists");
+ Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityType = capabilityTypeOperation.getCapabilityType("not_exists");
assertEquals("check not found is returned", StorageOperationStatus.NOT_FOUND, capabilityType.right().value());
}
private void comparePropertyDefinition(PropertyDefinition first, PropertyDefinition second) {
- assertTrue("check objects are full or empty",
- ((first == null && second == null) || (first != null && second != null)));
+ assertTrue("check objects are full or empty", ((first == null && second == null) || (first != null && second != null)));
if (first != null) {
assertTrue("check property default value", compareValue(first.getDefaultValue(), second.getDefaultValue()));
assertTrue("check property description", compareValue(first.getDescription(), second.getDescription()));
@@ -275,8 +262,7 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
private void compareList(List<PropertyConstraint> first, List<PropertyConstraint> second) {
- assertTrue("check lists are full or empty",
- ((first == null && second == null) || (first != null && second != null)));
+ assertTrue("check lists are full or empty", ((first == null && second == null) || (first != null && second != null)));
if (first != null) {
assertEquals("check list size", first.size(), second.size());
}
@@ -302,8 +288,7 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
private PropertyDefinition buildProperty1() {
PropertyDefinition property1 = new PropertyDefinition();
property1.setDefaultValue("10");
- property1.setDescription(
- "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
+ property1.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
property1.setType(ToscaType.INTEGER.name().toLowerCase());
List<PropertyConstraint> constraints = new ArrayList<PropertyConstraint>();
GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0");
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationSpringTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationSpringTest.java
index 2dcb1ee72e..f07115af5b 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationSpringTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationSpringTest.java
@@ -44,6 +44,7 @@ import javax.annotation.Resource;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
@@ -154,71 +155,57 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
}
titanGenericDao.commit();
deleteAndCreateCategory(CATEGORY_NAME);
- UserData modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "rfc",
- ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
+ UserData modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "rfc", ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
rfcUser = convertUserDataToUser(modifierData);
}
@Test
+ @Ignore
public void testAddCapabilityPropertyValuesToResourceInstance() {
String rootName = "Root123";
- org.openecomp.sdc.be.model.Resource rootResource = createResource(rfcUser.getUserId(), CATEGORY_NAME, rootName,
- "1.0", null, false, true);
+ org.openecomp.sdc.be.model.Resource rootResource = createResource(rfcUser.getUserId(), CATEGORY_NAME, rootName, "1.0", null, false, true);
// certification request
- Either<? extends org.openecomp.sdc.be.model.Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Resource, rootResource, rfcUser, rfcUser, false);
+ Either<? extends org.openecomp.sdc.be.model.Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Resource, rootResource, rfcUser, rfcUser, false);
assertTrue(requestCertificationResult.isLeft());
- org.openecomp.sdc.be.model.Resource resultResource = (org.openecomp.sdc.be.model.Resource) requestCertificationResult
- .left().value();
+ org.openecomp.sdc.be.model.Resource resultResource = (org.openecomp.sdc.be.model.Resource) requestCertificationResult.left().value();
// start certification
- Either<? extends org.openecomp.sdc.be.model.Component, StorageOperationStatus> startCertificationResult = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Resource, resultResource, rfcUser, rfcUser, false);
+ Either<? extends org.openecomp.sdc.be.model.Component, StorageOperationStatus> startCertificationResult = lifecycleOperation.startComponentCertification(NodeTypeEnum.Resource, resultResource, rfcUser, rfcUser, false);
assertEquals(true, startCertificationResult.isLeft());
- Either<? extends org.openecomp.sdc.be.model.Component, StorageOperationStatus> certifiedResourceRes = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Resource, rootResource, rfcUser, rfcUser, false);
+ Either<? extends org.openecomp.sdc.be.model.Component, StorageOperationStatus> certifiedResourceRes = lifecycleOperation.certifyComponent(NodeTypeEnum.Resource, rootResource, rfcUser, rfcUser, false);
assertTrue(certifiedResourceRes.isLeft());
CapabilityTypeDefinition capabilityType = buildCapabilityType();
- Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityTypeRes = capabilityTypeOperation
- .addCapabilityType(capabilityType);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> capabilityTypeRes = capabilityTypeOperation.addCapabilityType(capabilityType);
assertTrue(capabilityTypeRes.isLeft());
CapabilityData capData = FactoryUtils.createCapabilityData();
- CapabilityDefinition capabilityDefinitionRoot = FactoryUtils
- .convertCapabilityDataToCapabilityDefinitionRoot(capData);
+ CapabilityDefinition capabilityDefinitionRoot = FactoryUtils.convertCapabilityDataToCapabilityDefinitionRoot(capData);
- Either<CapabilityDefinition, StorageOperationStatus> addCapabilityRootRes = capabilityOperation.addCapability(
- (String) certifiedResourceRes.left().value().getUniqueId(), capabilityDefinitionRoot.getName(),
- capabilityDefinitionRoot);
+ Either<CapabilityDefinition, StorageOperationStatus> addCapabilityRootRes = capabilityOperation.addCapability((String) certifiedResourceRes.left().value().getUniqueId(), capabilityDefinitionRoot.getName(), capabilityDefinitionRoot);
assertTrue(addCapabilityRootRes.isLeft());
String resourceName = "tosca.nodes.Apache.2.0";
- CapabilityDefinition capabilityDefinition = FactoryUtils
- .convertCapabilityDataToCapabilityDefinitionAddProperties(capData);
- org.openecomp.sdc.be.model.Resource resource = createResource(rfcUser.getUserId(), CATEGORY_NAME, resourceName,
- "0.1", rootName, false, true);
+ CapabilityDefinition capabilityDefinition = FactoryUtils.convertCapabilityDataToCapabilityDefinitionAddProperties(capData);
+ org.openecomp.sdc.be.model.Resource resource = createResource(rfcUser.getUserId(), CATEGORY_NAME, resourceName, "0.1", rootName, false, true);
- Either<CapabilityDefinition, StorageOperationStatus> addCapabilityRes = capabilityOperation
- .addCapability((String) resource.getUniqueId(), capabilityDefinition.getName(), capabilityDefinition);
+ Either<CapabilityDefinition, StorageOperationStatus> addCapabilityRes = capabilityOperation.addCapability((String) resource.getUniqueId(), capabilityDefinition.getName(), capabilityDefinition);
assertTrue(addCapabilityRes.isLeft());
List<ComponentInstanceProperty> properties = addCapabilityRes.left().value().getProperties();
assertTrue(properties.size() == 2);
- Either<org.openecomp.sdc.be.model.Resource, StorageOperationStatus> clonedResourceRes = resourceOperation
- .cloneComponent(resource, "0.2", false);
+ Either<org.openecomp.sdc.be.model.Resource, StorageOperationStatus> clonedResourceRes = resourceOperation.cloneComponent(resource, "0.2", false);
assertTrue(clonedResourceRes.isLeft());
org.openecomp.sdc.be.model.Resource clonedResource = clonedResourceRes.left().value();
ComponentInstance instance = buildResourceInstance(clonedResource.getUniqueId(), "1", "tosca.nodes.Apache");
Service origService = createService(rfcUser.getUserId(), CATEGORY_NAME, "my-service", "1.0", true);
- Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(),
- false);
+ Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(), false);
assertTrue(service2.isLeft());
origService = service2.left().value();
@@ -228,9 +215,7 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
Service fullService = origService;
- Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation
- .addComponentInstanceToContainerComponent((String) origService.getUniqueId(), NodeTypeEnum.Service, "1",
- true, instance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation.addComponentInstanceToContainerComponent((String) origService.getUniqueId(), NodeTypeEnum.Service, "1", true, instance, NodeTypeEnum.Resource, false);
assertTrue(status.isLeft());
ComponentInstance resourceInstance = status.left().value();
@@ -239,17 +224,14 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
List<ComponentInstanceProperty> propertyValues = FactoryUtils.createComponentInstancePropertyList();
capability.setProperties(propertyValues);
- Either<Map<CapabilityInstData, List<PropertyValueData>>, TitanOperationStatus> addCPVsToRiRes = componentInstanceOperation
- .addCapabilityPropertyValuesToResourceInstance(resourceInstance.getUniqueId(), capability, true);
+ Either<Map<CapabilityInstData, List<PropertyValueData>>, TitanOperationStatus> addCPVsToRiRes = componentInstanceOperation.addCapabilityPropertyValuesToResourceInstance(resourceInstance.getUniqueId(), capability, true);
assertTrue(addCPVsToRiRes.isLeft());
- Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0",
- false);
+ Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0", false);
assertTrue(createService.isLeft());
Map<String, List<CapabilityDefinition>> capabilitiesMap = createService.left().value().getCapabilities();
assertTrue(capabilitiesMap != null && capabilitiesMap.size() == 1);
- Map<String, CapabilityDefinition> capabilities = capabilitiesMap.values().iterator().next().stream()
- .collect(Collectors.toMap(CapabilityDefinition::getName, Function.identity()));
+ Map<String, CapabilityDefinition> capabilities = capabilitiesMap.values().iterator().next().stream().collect(Collectors.toMap(CapabilityDefinition::getName, Function.identity()));
assertTrue(capabilities.containsKey("Cap1") && capabilities.containsKey("Cap2"));
// String outputFile = exportGraphMl();
@@ -343,8 +325,7 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
public ResourceMetadataData createResource(String resourceName, TitanGenericDao titanGenericDao) {
ResourceMetadataData serviceData1 = new ResourceMetadataData();
serviceData1.getMetadataDataDefinition().setUniqueId(resourceName);
- Either<ResourceMetadataData, TitanOperationStatus> createNode = titanGenericDao.createNode(serviceData1,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> createNode = titanGenericDao.createNode(serviceData1, ResourceMetadataData.class);
assertTrue("check service created", createNode.isLeft());
return createNode.left().value();
}
@@ -352,21 +333,18 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
public ServiceMetadataData createServiceMetadataData(String serviceName, TitanGenericDao titanGenericDao) {
ServiceMetadataData serviceData1 = new ServiceMetadataData();
serviceData1.getMetadataDataDefinition().setUniqueId(serviceName);
- Either<ServiceMetadataData, TitanOperationStatus> createNode = titanGenericDao.createNode(serviceData1,
- ServiceMetadataData.class);
+ Either<ServiceMetadataData, TitanOperationStatus> createNode = titanGenericDao.createNode(serviceData1, ServiceMetadataData.class);
assertTrue("check service created", createNode.isLeft());
return createNode.left().value();
}
- public Service createService(String userId, String category, String serviceName, String serviceVersion,
- boolean isHighestVersion) {
+ public Service createService(String userId, String category, String serviceName, String serviceVersion, boolean isHighestVersion) {
Service service = buildServiceMetadata(userId, category, serviceName, serviceVersion);
service.setHighestVersion(isHighestVersion);
Either<Service, StorageOperationStatus> result = serviceOperation.createService(service, true);
assertTrue(result.isLeft());
Service resultService = result.left().value();
- assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT,
- resultService.getLifecycleState());
+ assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultService.getLifecycleState());
return resultService;
}
@@ -412,8 +390,7 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
return userData;
}
- public org.openecomp.sdc.be.model.Resource createResource(String userId, String category, String resourceName,
- String resourceVersion, String parentResourceName, boolean isAbstract, boolean isHighestVersion) {
+ public org.openecomp.sdc.be.model.Resource createResource(String userId, String category, String resourceName, String resourceVersion, String parentResourceName, boolean isAbstract, boolean isHighestVersion) {
String propName1 = "disk_size";
String propName2 = "num_cpus";
@@ -422,8 +399,7 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
if (parentResourceName != null) {
derivedFrom.add(parentResourceName);
}
- org.openecomp.sdc.be.model.Resource resource = buildResourceMetadata(userId, category, resourceName,
- resourceVersion);
+ org.openecomp.sdc.be.model.Resource resource = buildResourceMetadata(userId, category, resourceName, resourceVersion);
resource.setAbstract(isAbstract);
resource.setHighestVersion(isHighestVersion);
@@ -432,8 +408,7 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
PropertyDefinition property1 = new PropertyDefinition();
property1.setDefaultValue("10");
- property1.setDescription(
- "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
+ property1.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
property1.setType(ToscaType.INTEGER.name().toLowerCase());
List<PropertyConstraint> constraints = new ArrayList<PropertyConstraint>();
GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0");
@@ -466,18 +441,15 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
resource.setProperties(convertMapToList(properties));
- Either<org.openecomp.sdc.be.model.Resource, StorageOperationStatus> result = resourceOperation
- .createResource(resource, true);
+ Either<org.openecomp.sdc.be.model.Resource, StorageOperationStatus> result = resourceOperation.createResource(resource, true);
assertTrue(result.isLeft());
org.openecomp.sdc.be.model.Resource resultResource = result.left().value();
- assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT,
- resultResource.getLifecycleState());
+ assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultResource.getLifecycleState());
String resourceId = resultResource.getUniqueId();
- Either<PropertyDefinition, StorageOperationStatus> either = propertyOperation.getPropertyOfResource(propName1,
- resourceId);
+ Either<PropertyDefinition, StorageOperationStatus> either = propertyOperation.getPropertyOfResource(propName1, resourceId);
assertTrue(either.isLeft());
PropertyDefinition propertyDefinition = either.left().value();
@@ -485,14 +457,12 @@ public class ComponentInstanceOperationSpringTest extends ModelTestBase {
assertEquals("check property description", property1.getDescription(), propertyDefinition.getDescription());
assertEquals("check property type", property1.getType(), propertyDefinition.getType());
assertEquals("check property unique id", property1.getUniqueId(), propertyDefinition.getUniqueId());
- assertEquals("check property consitraints size", property1.getConstraints().size(),
- propertyDefinition.getConstraints().size());
+ assertEquals("check property consitraints size", property1.getConstraints().size(), propertyDefinition.getConstraints().size());
return resultResource;
}
- private org.openecomp.sdc.be.model.Resource buildResourceMetadata(String userId, String category,
- String resourceName, String resourceVersion) {
+ private org.openecomp.sdc.be.model.Resource buildResourceMetadata(String userId, String category, String resourceName, String resourceVersion) {
org.openecomp.sdc.be.model.Resource resource = new org.openecomp.sdc.be.model.Resource();
resource.setName(resourceName);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java
index e77c9f0291..c77769d7d2 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java
@@ -65,20 +65,16 @@ public class ComponentInstanceOperationTest {
ComponentInstance ri = FactoryUtils.createResourceInstance();
CapabilityData capData = FactoryUtils.createCapabilityData();
- Either<List<ImmutablePair<GraphNode, GraphEdge>>, TitanOperationStatus> childNodesReturned = prepareChildNodeRetValue(
- capData);
+ Either<List<ImmutablePair<GraphNode, GraphEdge>>, TitanOperationStatus> childNodesReturned = prepareChildNodeRetValue(capData);
- Mockito.when(titanGenericDao.getChildrenNodes(Mockito.anyString(), Mockito.anyString(),
- Mockito.any(GraphEdgeLabels.class), Mockito.any(NodeTypeEnum.class), Mockito.any()))
- .thenReturn(childNodesReturned);
+ Mockito.when(titanGenericDao.getChildrenNodes(Mockito.anyString(), Mockito.anyString(), Mockito.any(GraphEdgeLabels.class), Mockito.any(NodeTypeEnum.class), Mockito.any())).thenReturn(childNodesReturned);
// ImmutablePair<ComponentInstance, List<ImmutablePair<CapabilityData,
// GraphEdge>>> instanceAndCapabilities =
// componentInstanceOperation.getCapabilities(ri,
// NodeTypeEnum.Resource);
- Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> instanceAndCapabilities = componentInstanceOperation
- .getCapabilities(ri, NodeTypeEnum.Resource);
+ Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> instanceAndCapabilities = componentInstanceOperation.getCapabilities(ri, NodeTypeEnum.Resource);
// assertTrue(instanceAndCapabilities.left.getUniqueId().equals(ri.getUniqueId()));
assertTrue(instanceAndCapabilities.left().value().size() == 1);
@@ -90,19 +86,15 @@ public class ComponentInstanceOperationTest {
public void testGetRequirements() {
ComponentInstance ri = FactoryUtils.createResourceInstance();
RequirementData reqData = FactoryUtils.createRequirementData();
- Either<List<ImmutablePair<GraphNode, GraphEdge>>, TitanOperationStatus> childNodesReturned = prepareChildNodeRetValue(
- reqData);
+ Either<List<ImmutablePair<GraphNode, GraphEdge>>, TitanOperationStatus> childNodesReturned = prepareChildNodeRetValue(reqData);
- Mockito.when(titanGenericDao.getChildrenNodes(Mockito.anyString(), Mockito.anyString(),
- Mockito.any(GraphEdgeLabels.class), Mockito.any(NodeTypeEnum.class), Mockito.any()))
- .thenReturn(childNodesReturned);
+ Mockito.when(titanGenericDao.getChildrenNodes(Mockito.anyString(), Mockito.anyString(), Mockito.any(GraphEdgeLabels.class), Mockito.any(NodeTypeEnum.class), Mockito.any())).thenReturn(childNodesReturned);
// ImmutablePair<ComponentInstance, List<ImmutablePair<RequirementData,
// GraphEdge>>> instanceAndCapabilities =
// componentInstanceOperation.getRequirements(ri,
// NodeTypeEnum.Resource);
- Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> instanceAndCapabilities = componentInstanceOperation
- .getRequirements(ri, NodeTypeEnum.Resource);
+ Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> instanceAndCapabilities = componentInstanceOperation.getRequirements(ri, NodeTypeEnum.Resource);
// assertTrue(instanceAndCapabilities.left.getUniqueId().equals(ri.getUniqueId()));
// assertTrue(instanceAndCapabilities.right.size() == 1);
@@ -125,8 +117,7 @@ public class ComponentInstanceOperationTest {
return capabilityInstance;
}
- private Either<List<ImmutablePair<GraphNode, GraphEdge>>, TitanOperationStatus> prepareChildNodeRetValue(
- GraphNode data) {
+ private Either<List<ImmutablePair<GraphNode, GraphEdge>>, TitanOperationStatus> prepareChildNodeRetValue(GraphNode data) {
ImmutablePair<GraphNode, GraphEdge> pair = new ImmutablePair<>(data, FactoryUtils.createGraphEdge());
List<ImmutablePair<GraphNode, GraphEdge>> retList = new ArrayList<>();
retList.add(pair);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentOperationTest.java
index 14018d31f9..061393645a 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentOperationTest.java
@@ -93,13 +93,11 @@ public class ComponentOperationTest {
CapabilityData capData = FactoryUtils.createCapabilityData();
FactoryUtils.addComponentInstanceToVF(vf, ri);
- Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> capDataList = prepareCompOperationReturnValue(
- ri, capData);
+ Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> capDataList = prepareCompOperationReturnValue(ri, capData);
prepareMocksForCapabilitiesMethods(ri, capDataList);
- Map<String, List<CapabilityDefinition>> capabilities = compOperation
- .getCapabilities(vf, NodeTypeEnum.Resource, false).left().value();
+ Map<String, List<CapabilityDefinition>> capabilities = compOperation.getCapabilities(vf, NodeTypeEnum.Resource, false).left().value();
assertTrue(capabilities.size() == 1);
Entry<String, List<CapabilityDefinition>> entry = capabilities.entrySet().iterator().next();
assertTrue(entry.getKey().equals(capData.getType()));
@@ -116,13 +114,11 @@ public class ComponentOperationTest {
FactoryUtils.addComponentInstanceToVF(vf, ri);
- Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> reqDataEdgeList = prepareCompOperationReturnValue(
- ri, reqData);
+ Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> reqDataEdgeList = prepareCompOperationReturnValue(ri, reqData);
prepareMocksForRequirmenetsMethods(ri, reqDataEdgeList);
- Map<String, List<RequirementDefinition>> requirements = compOperation
- .getRequirements(vf, NodeTypeEnum.Resource, false).left().value();
+ Map<String, List<RequirementDefinition>> requirements = compOperation.getRequirements(vf, NodeTypeEnum.Resource, false).left().value();
assertTrue(requirements.size() == 1);
Entry<String, List<RequirementDefinition>> entry = requirements.entrySet().iterator().next();
assertTrue(entry.getKey().equals(FactoryUtils.Constants.DEFAULT_CAPABILITY_TYPE));
@@ -130,70 +126,51 @@ public class ComponentOperationTest {
assertTrue(entry.getValue().get(0).getUniqueId().equals(reqData.getUniqueId()));
}
- private void prepareMocksForRequirmenetsMethods(ComponentInstance ri,
- Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> reqDataEdgeList) {
+ private void prepareMocksForRequirmenetsMethods(ComponentInstance ri, Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> reqDataEdgeList) {
when(componentInstanceOperation.getRequirements(ri, NodeTypeEnum.Resource)).thenReturn(reqDataEdgeList);
when(requirementOperation.getRequirement(Mockito.anyString())).then(createReqDefAnswer());
}
- private void prepareMocksForCapabilitiesMethods(ComponentInstance ri,
- Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> capDataList) {
+ private void prepareMocksForCapabilitiesMethods(ComponentInstance ri, Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> capDataList) {
when(componentInstanceOperation.getCapabilities(ri, NodeTypeEnum.Resource)).thenReturn(capDataList);
- when(capabilityOperation.getCapabilityByCapabilityData(Mockito.any(CapabilityData.class)))
- .then(createCapDefByDataAnswer());
+ when(capabilityOperation.getCapabilityByCapabilityData(Mockito.any(CapabilityData.class))).then(createCapDefByDataAnswer());
List<ImmutablePair<CapabilityInstData, GraphEdge>> capInstList = new ArrayList<>();
CapabilityInstData curCapabilityInst = FactoryUtils.createCapabilityInstData();
GraphEdge edge = new GraphEdge();
Map<String, Object> properties = new HashMap<>();
- properties.put(GraphPropertiesDictionary.CAPABILITY_ID.getProperty(),
- capDataList.left().value().get(0).getLeft().getUniqueId());
+ properties.put(GraphPropertiesDictionary.CAPABILITY_ID.getProperty(), capDataList.left().value().get(0).getLeft().getUniqueId());
edge.setProperties(properties);
- ImmutablePair<CapabilityInstData, GraphEdge> pair = new ImmutablePair<CapabilityInstData, GraphEdge>(
- curCapabilityInst, edge);
+ ImmutablePair<CapabilityInstData, GraphEdge> pair = new ImmutablePair<CapabilityInstData, GraphEdge>(curCapabilityInst, edge);
capInstList.add(pair);
- when(titanGenericDao.getChildrenNodes(
- UniqueIdBuilder.getKeyByNodeType(
- NodeTypeEnum.getByNameIgnoreCase(ri.getOriginType().getInstanceType().trim())),
- ri.getUniqueId(), GraphEdgeLabels.CAPABILITY_INST, NodeTypeEnum.CapabilityInst,
+ when(titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByNameIgnoreCase(ri.getOriginType().getInstanceType().trim())), ri.getUniqueId(), GraphEdgeLabels.CAPABILITY_INST, NodeTypeEnum.CapabilityInst,
CapabilityInstData.class)).thenReturn(Either.left(capInstList));
- when(titanGenericDao.getChild(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByName(curCapabilityInst.getLabel())),
- curCapabilityInst.getUniqueId(), GraphEdgeLabels.INSTANCE_OF, NodeTypeEnum.Capability,
- CapabilityData.class)).thenReturn(Either.left(capDataList.left().value().get(0)));
+ when(titanGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByName(curCapabilityInst.getLabel())), curCapabilityInst.getUniqueId(), GraphEdgeLabels.INSTANCE_OF, NodeTypeEnum.Capability, CapabilityData.class))
+ .thenReturn(Either.left(capDataList.left().value().get(0)));
PropertyValueData propertyValueData = FactoryUtils.createPropertyData();
- ImmutablePair<PropertyValueData, GraphEdge> propPair = new ImmutablePair<PropertyValueData, GraphEdge>(
- propertyValueData, null);
+ ImmutablePair<PropertyValueData, GraphEdge> propPair = new ImmutablePair<PropertyValueData, GraphEdge>(propertyValueData, null);
List<ImmutablePair<PropertyValueData, GraphEdge>> propPairList = new ArrayList<>();
propPairList.add(propPair);
- when(titanGenericDao.getChildrenNodes(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByName(curCapabilityInst.getLabel())),
- curCapabilityInst.getUniqueId(), GraphEdgeLabels.PROPERTY_VALUE, NodeTypeEnum.PropertyValue,
+ when(titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByName(curCapabilityInst.getLabel())), curCapabilityInst.getUniqueId(), GraphEdgeLabels.PROPERTY_VALUE, NodeTypeEnum.PropertyValue,
PropertyValueData.class)).thenReturn(Either.left(propPairList));
- CapabilityDefinition capDef = FactoryUtils
- .convertCapabilityDataToCapabilityDefinitionAddProperties(capDataList.left().value().get(0).getLeft());
- List<PropertyDefinition> propDefList = capDef.getProperties().stream().filter(p -> p.getName().equals("host"))
- .collect(Collectors.toList());
+ CapabilityDefinition capDef = FactoryUtils.convertCapabilityDataToCapabilityDefinitionAddProperties(capDataList.left().value().get(0).getLeft());
+ List<PropertyDefinition> propDefList = capDef.getProperties().stream().filter(p -> p.getName().equals("host")).collect(Collectors.toList());
PropertyDefinition propDef = propDefList.get(0);
PropertyData propData = FactoryUtils.convertCapabilityDefinitionToCapabilityData(propDef);
ImmutablePair<PropertyData, GraphEdge> defPropPair = new ImmutablePair<PropertyData, GraphEdge>(propData, edge);
- when(titanGenericDao.getChild(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByName(propertyValueData.getLabel())),
- propertyValueData.getUniqueId(), GraphEdgeLabels.PROPERTY_IMPL, NodeTypeEnum.Property,
- PropertyData.class)).thenReturn(Either.left(defPropPair));
+ when(titanGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByName(propertyValueData.getLabel())), propertyValueData.getUniqueId(), GraphEdgeLabels.PROPERTY_IMPL, NodeTypeEnum.Property, PropertyData.class))
+ .thenReturn(Either.left(defPropPair));
List<CapabilityDefinition> capDefList = new ArrayList<>();
capDefList.add(capDef);
- when(componentInstanceOperation.updateCapDefPropertyValues(Mockito.any(ComponentInstance.class),
- Mockito.any(List.class))).thenReturn(Either.left(capDefList));
+ when(componentInstanceOperation.updateCapDefPropertyValues(Mockito.any(ComponentInstance.class), Mockito.any(List.class))).thenReturn(Either.left(capDefList));
}
- private <Data> Either<List<ImmutablePair<Data, GraphEdge>>, TitanOperationStatus> prepareCompOperationReturnValue(
- ComponentInstance ri, Data data) {
+ private <Data> Either<List<ImmutablePair<Data, GraphEdge>>, TitanOperationStatus> prepareCompOperationReturnValue(ComponentInstance ri, Data data) {
ImmutablePair<Data, GraphEdge> dataEdgePair = new ImmutablePair<>(data, new GraphEdge());
List<ImmutablePair<Data, GraphEdge>> dataEdgeList = new ArrayList<>();
dataEdgeList.add(dataEdgePair);
@@ -204,8 +181,7 @@ public class ComponentOperationTest {
return new Answer<Either<RequirementDefinition, TitanOperationStatus>>() {
@Override
- public Either<RequirementDefinition, TitanOperationStatus> answer(InvocationOnMock invocation)
- throws Throwable {
+ public Either<RequirementDefinition, TitanOperationStatus> answer(InvocationOnMock invocation) throws Throwable {
String reqDataId = (String) invocation.getArguments()[0];
return Either.left(FactoryUtils.convertRequirementDataIDToRequirementDefinition(reqDataId));
}
@@ -216,8 +192,7 @@ public class ComponentOperationTest {
return new Answer<Either<CapabilityDefinition, TitanOperationStatus>>() {
@Override
- public Either<CapabilityDefinition, TitanOperationStatus> answer(InvocationOnMock invocation)
- throws Throwable {
+ public Either<CapabilityDefinition, TitanOperationStatus> answer(InvocationOnMock invocation) throws Throwable {
CapabilityData capData = (CapabilityData) invocation.getArguments()[0];
return Either.left(FactoryUtils.convertCapabilityDataToCapabilityDefinitionAddProperties(capData));
}
@@ -228,15 +203,13 @@ public class ComponentOperationTest {
return new ComponentOperation() {
@Override
- protected StorageOperationStatus validateCategories(Component currentComponent, Component component,
- ComponentMetadataData componentData, NodeTypeEnum type) {
+ protected StorageOperationStatus validateCategories(Component currentComponent, Component component, ComponentMetadataData componentData, NodeTypeEnum type) {
// TODO Auto-generated method stub
return null;
}
@Override
- protected <T extends Component> StorageOperationStatus updateDerived(Component component,
- Component currentComponent, ComponentMetadataData updatedResourceData, Class<T> clazz) {
+ protected <T extends Component> StorageOperationStatus updateDerived(Component component, Component currentComponent, ComponentMetadataData updatedResourceData, Class<T> clazz) {
// TODO Auto-generated method stub
return null;
}
@@ -248,8 +221,7 @@ public class ComponentOperationTest {
}
@Override
- public Either<Integer, StorageOperationStatus> increaseAndGetComponentInstanceCounter(String componentId,
- boolean inTransaction) {
+ public Either<Integer, StorageOperationStatus> increaseAndGetComponentInstanceCounter(String componentId, boolean inTransaction) {
// TODO Auto-generated method stub
return null;
}
@@ -267,8 +239,7 @@ public class ComponentOperationTest {
}
@Override
- protected <T> Either<T, StorageOperationStatus> getComponentByNameAndVersion(String name, String version,
- Map<String, Object> additionalParams, boolean inTransaction) {
+ protected <T> Either<T, StorageOperationStatus> getComponentByNameAndVersion(String name, String version, Map<String, Object> additionalParams, boolean inTransaction) {
// TODO Auto-generated method stub
return null;
}
@@ -287,15 +258,13 @@ public class ComponentOperationTest {
// }
@Override
- public Either<List<ArtifactDefinition>, StorageOperationStatus> getAdditionalArtifacts(String resourceId,
- boolean recursively, boolean inTransaction) {
+ public Either<List<ArtifactDefinition>, StorageOperationStatus> getAdditionalArtifacts(String resourceId, boolean recursively, boolean inTransaction) {
// TODO Auto-generated method stub
return null;
}
@Override
- public <T> Either<T, StorageOperationStatus> cloneComponent(T other, String version,
- boolean inTransaction) {
+ public <T> Either<T, StorageOperationStatus> cloneComponent(T other, String version, boolean inTransaction) {
// TODO Auto-generated method stub
return null;
}
@@ -337,8 +306,7 @@ public class ComponentOperationTest {
}
@Override
- public Either<Component, StorageOperationStatus> markComponentToDelete(Component componentToDelete,
- boolean inTransaction) {
+ public Either<Component, StorageOperationStatus> markComponentToDelete(Component componentToDelete, boolean inTransaction) {
// TODO Auto-generated method stub
return null;
}
@@ -362,29 +330,25 @@ public class ComponentOperationTest {
}
@Override
- public <T> Either<T, StorageOperationStatus> cloneComponent(T other, String version,
- LifecycleStateEnum targetLifecycle, boolean inTransaction) {
+ public <T> Either<T, StorageOperationStatus> cloneComponent(T other, String version, LifecycleStateEnum targetLifecycle, boolean inTransaction) {
// TODO Auto-generated method stub
return null;
}
@Override
- public <T> Either<T, StorageOperationStatus> getComponent(String id,
- ComponentParametersView componentParametersView, boolean inTrasnaction) {
+ public <T> Either<T, StorageOperationStatus> getComponent(String id, ComponentParametersView componentParametersView, boolean inTrasnaction) {
// TODO Auto-generated method stub
return null;
}
@Override
- public <T> Either<List<T>, StorageOperationStatus> getFilteredComponents(Map<FilterKeyEnum, String> filters,
- boolean inTransaction) {
+ public <T> Either<List<T>, StorageOperationStatus> getFilteredComponents(Map<FilterKeyEnum, String> filters, boolean inTransaction) {
// TODO Auto-generated method stub
return null;
}
@Override
- protected <T> Either<T, StorageOperationStatus> updateComponentFilterResult(T component,
- boolean inTransaction, ComponentParametersView filterParametersView) {
+ protected <T> Either<T, StorageOperationStatus> updateComponentFilterResult(T component, boolean inTransaction, ComponentParametersView filterParametersView) {
// TODO Auto-generated method stub
return null;
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
index a529074db6..eb2615f19b 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
@@ -92,8 +92,7 @@ public class ElementOperationTest extends ModelTestBase {
public void testGetResourceAndServiceCategoty() {
String id = OperationTestsUtil.deleteAndCreateResourceCategory(CATEGORY, SUBCATEGORY, titanDao);
- Either<CategoryDefinition, ActionStatus> res = elementOperation.getCategory(NodeTypeEnum.ResourceNewCategory,
- id);
+ Either<CategoryDefinition, ActionStatus> res = elementOperation.getCategory(NodeTypeEnum.ResourceNewCategory, id);
assertTrue(res.isLeft());
CategoryDefinition categoryDefinition = (CategoryDefinition) res.left().value();
assertEquals(CATEGORY, categoryDefinition.getName());
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/HeatParametersOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/HeatParametersOperationTest.java
index 6765557bab..a71f97871f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/HeatParametersOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/HeatParametersOperationTest.java
@@ -73,13 +73,10 @@ public class HeatParametersOperationTest extends ModelTestBase {
GraphRelation graphRelation = new GraphRelation();
Either<GraphRelation, TitanOperationStatus> relationResult = Either.left(graphRelation);
- when(titanGenericDao.createNode((HeatParameterData) anyObject(), eq(HeatParameterData.class)))
- .thenReturn(either);
- when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(),
- eq(GraphEdgeLabels.HEAT_PARAMETER), anyMap())).thenReturn(relationResult);
+ when(titanGenericDao.createNode((HeatParameterData) anyObject(), eq(HeatParameterData.class))).thenReturn(either);
+ when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(), eq(GraphEdgeLabels.HEAT_PARAMETER), anyMap())).thenReturn(relationResult);
- Either<HeatParameterData, TitanOperationStatus> result = heatParametersOperation.addPropertyToGraph(propName,
- property, "resourceId.artifactId", NodeTypeEnum.ArtifactRef);
+ Either<HeatParameterData, TitanOperationStatus> result = heatParametersOperation.addPropertyToGraph(propName, property, "resourceId.artifactId", NodeTypeEnum.ArtifactRef);
assertTrue(result.isLeft());
@@ -103,13 +100,10 @@ public class HeatParametersOperationTest extends ModelTestBase {
GraphRelation graphRelation = new GraphRelation();
Either<GraphRelation, TitanOperationStatus> relationResult = Either.left(graphRelation);
- when(titanGenericDao.createNode((HeatParameterData) anyObject(), eq(HeatParameterData.class)))
- .thenReturn(either);
- when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(),
- eq(GraphEdgeLabels.HEAT_PARAMETER), anyMap())).thenReturn(relationResult);
+ when(titanGenericDao.createNode((HeatParameterData) anyObject(), eq(HeatParameterData.class))).thenReturn(either);
+ when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(), eq(GraphEdgeLabels.HEAT_PARAMETER), anyMap())).thenReturn(relationResult);
- StorageOperationStatus result = heatParametersOperation.addPropertiesToGraph(parameters,
- "resourceId.artifactId", NodeTypeEnum.ArtifactRef);
+ StorageOperationStatus result = heatParametersOperation.addPropertiesToGraph(parameters, "resourceId.artifactId", NodeTypeEnum.ArtifactRef);
assertEquals(StorageOperationStatus.OK, result);
@@ -133,8 +127,7 @@ public class HeatParametersOperationTest extends ModelTestBase {
@Test
public void testJsonValues() {
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.JSON, "{ \"member\" : \"50\"}"));
- HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(
- HeatParameterType.JSON.getType(), "{ \"member\" : \"50\"}");
+ HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.JSON.getType(), "{ \"member\" : \"50\"}");
StorageOperationStatus operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals(HeatParameterType.JSON.getType(), propertyDefinition.getType());
@@ -144,8 +137,7 @@ public class HeatParametersOperationTest extends ModelTestBase {
@Test
public void testListValues() {
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.COMMA_DELIMITED_LIST, "one, two"));
- HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(
- HeatParameterType.COMMA_DELIMITED_LIST.getType(), "one, two");
+ HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.COMMA_DELIMITED_LIST.getType(), "one, two");
StorageOperationStatus operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals(HeatParameterType.COMMA_DELIMITED_LIST.getType(), propertyDefinition.getType());
@@ -160,23 +152,19 @@ public class HeatParametersOperationTest extends ModelTestBase {
for (int i = 0; i < trueArray.length; i++) {
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.BOOLEAN, trueArray[i]));
- HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(
- HeatParameterType.BOOLEAN.getType(), trueArray[i]);
- StorageOperationStatus operationStatus = heatParametersOperation
- .validateAndUpdateProperty(propertyDefinition);
+ HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(), trueArray[i]);
+ StorageOperationStatus operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals("true", propertyDefinition.getDefaultValue());
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.BOOLEAN, trueArray[i]));
- propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(),
- trueArray[i].toUpperCase());
+ propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(), trueArray[i].toUpperCase());
operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals("true", propertyDefinition.getDefaultValue());
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.BOOLEAN, trueArray[i]));
- propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(),
- trueArray[i].toLowerCase());
+ propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(), trueArray[i].toLowerCase());
operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals("true", propertyDefinition.getDefaultValue());
@@ -184,23 +172,19 @@ public class HeatParametersOperationTest extends ModelTestBase {
for (int i = 0; i < falseArray.length; i++) {
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.BOOLEAN, falseArray[i]));
- HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(
- HeatParameterType.BOOLEAN.getType(), falseArray[i]);
- StorageOperationStatus operationStatus = heatParametersOperation
- .validateAndUpdateProperty(propertyDefinition);
+ HeatParameterDefinition propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(), falseArray[i]);
+ StorageOperationStatus operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals("false", propertyDefinition.getDefaultValue());
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.BOOLEAN, falseArray[i]));
- propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(),
- falseArray[i].toUpperCase());
+ propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(), falseArray[i].toUpperCase());
operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals("false", propertyDefinition.getDefaultValue());
assertTrue(heatParametersOperation.isValidValue(HeatParameterType.BOOLEAN, falseArray[i]));
- propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(),
- falseArray[i].toLowerCase());
+ propertyDefinition = buildHeatBooleanPropertyDefinition(HeatParameterType.BOOLEAN.getType(), falseArray[i].toLowerCase());
operationStatus = heatParametersOperation.validateAndUpdateProperty(propertyDefinition);
assertEquals(StorageOperationStatus.OK, operationStatus);
assertEquals("false", propertyDefinition.getDefaultValue());
@@ -272,15 +256,11 @@ public class HeatParametersOperationTest extends ModelTestBase {
GraphRelation graphRelation = new GraphRelation();
Either<GraphRelation, TitanOperationStatus> relationResult = Either.left(graphRelation);
- when(titanGenericDao.createNode((HeatParameterValueData) anyObject(), eq(HeatParameterValueData.class)))
- .thenReturn(either);
- when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(),
- eq(GraphEdgeLabels.PARAMETER_VALUE), anyMap())).thenReturn(relationResult);
- when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(),
- eq(GraphEdgeLabels.PARAMETER_IMPL), anyMap())).thenReturn(relationResult);
+ when(titanGenericDao.createNode((HeatParameterValueData) anyObject(), eq(HeatParameterValueData.class))).thenReturn(either);
+ when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(), eq(GraphEdgeLabels.PARAMETER_VALUE), anyMap())).thenReturn(relationResult);
+ when(titanGenericDao.createRelation((GraphNode) anyObject(), (GraphNode) anyObject(), eq(GraphEdgeLabels.PARAMETER_IMPL), anyMap())).thenReturn(relationResult);
- Either<HeatParameterValueData, TitanOperationStatus> result = heatParametersOperation
- .addHeatValueToGraph(property, "artifactLabel", "resourceInstanceId.artifactId", "resourceInstanceId");
+ Either<HeatParameterValueData, TitanOperationStatus> result = heatParametersOperation.addHeatValueToGraph(property, "artifactLabel", "resourceInstanceId.artifactId", "resourceInstanceId");
assertTrue(result.isLeft());
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java
index e1eb7db070..759fd2b811 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java
@@ -31,6 +31,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
@@ -42,6 +43,10 @@ import org.openecomp.sdc.be.model.ModelTestBase;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
+import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
+import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
+import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
import org.openecomp.sdc.be.resources.data.UserData;
@@ -61,7 +66,7 @@ public class InterfaceOperationTest {
private static Logger log = LoggerFactory.getLogger(InterfaceOperationTest.class.getName());
private Gson prettyGson = new GsonBuilder().setPrettyPrinting().create();
- private static String USER_ID = "muserId";
+ private static String USER_ID = "muUserId";
private static String CATEGORY_NAME = "category/mycategory";
// InterfaceLifecycleOperation interfaceOperation = new
// InterfaceLifecycleOperation();
@@ -107,7 +112,7 @@ public class InterfaceOperationTest {
}
- @Test
+/* @Test
public void addInterfaceToResourceTest() {
String capabilityTypeName = "mycapability1";
@@ -122,8 +127,7 @@ public class InterfaceOperationTest {
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "100.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "100.0", null, true, true);
String interfaceName = "standard";
InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
@@ -133,14 +137,12 @@ public class InterfaceOperationTest {
operations.put("Create", op);
interfaceDefinition.setOperations(operations);
- Either<InterfaceDefinition, StorageOperationStatus> result = interfaceOperation
- .addInterfaceToResource(interfaceDefinition, rootResource.getUniqueId(), "standard");
+ Either<InterfaceDefinition, StorageOperationStatus> result = interfaceOperation.addInterfaceToResource(interfaceDefinition, rootResource.getUniqueId(), "standard");
assertTrue(result.isLeft());
log.debug("{}", result.left().value());
- Either<Resource, StorageOperationStatus> getResourceRes = resourceOperation
- .getResource(rootResource.getUniqueId());
+ Either<Resource, StorageOperationStatus> getResourceRes = resourceOperation.getResource(rootResource.getUniqueId());
assertTrue(getResourceRes.isLeft());
Resource resourceWithInterface = getResourceRes.left().value();
Map<String, InterfaceDefinition> interfaces = resourceWithInterface.getInterfaces();
@@ -162,8 +164,7 @@ public class InterfaceOperationTest {
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "200.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "200.0", null, true, true);
String interfaceName = "standard";
InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
@@ -173,25 +174,21 @@ public class InterfaceOperationTest {
operations.put("create", op);
interfaceDefinition.setOperations(operations);
- Either<InterfaceDefinition, StorageOperationStatus> result = interfaceOperation
- .addInterfaceToResource(interfaceDefinition, rootResource.getUniqueId(), "standard");
+ Either<InterfaceDefinition, StorageOperationStatus> result = interfaceOperation.addInterfaceToResource(interfaceDefinition, rootResource.getUniqueId(), "standard");
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId());
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId());
assertTrue(fetchRootResource.isLeft());
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "400.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "400.0", rootResource.getName(), true, true);
assertTrue(result.isLeft());
log.debug("{}", result.left().value());
@@ -200,15 +197,13 @@ public class InterfaceOperationTest {
// String resourceId, String interfaceName, String
// operationName,Operation interf
- Either<Operation, StorageOperationStatus> opResult = interfaceOperation
- .updateInterfaceOperation(softwareComponent.getUniqueId(), "standard", "create", op);
+ Either<Operation, StorageOperationStatus> opResult = interfaceOperation.updateInterfaceOperation(softwareComponent.getUniqueId(), "standard", "create", op);
// PrintGraph pg = new PrintGraph();
// System.out.println(pg.buildGraphForWebgraphWiz(titanDao.getGraph().left().value()));
assertTrue(opResult.isLeft());
log.debug("{}", opResult.left().value());
- Either<Resource, StorageOperationStatus> getResourceRes = resourceOperation
- .getResource(softwareComponent.getUniqueId());
+ Either<Resource, StorageOperationStatus> getResourceRes = resourceOperation.getResource(softwareComponent.getUniqueId());
assertTrue(getResourceRes.isLeft());
Resource resourceWithInterface = getResourceRes.left().value();
Map<String, InterfaceDefinition> interfaces = resourceWithInterface.getInterfaces();
@@ -221,7 +216,7 @@ public class InterfaceOperationTest {
assertNotNull(operation);
assertNotNull(operation.getImplementation());
}
-
+*/
private void addImplementationToOperation(Operation op) {
ArtifactDataDefinition artifactDataDef = new ArtifactDataDefinition();
artifactDataDef.setArtifactChecksum("YTg2Mjg4MWJhNmI5NzBiNzdDFkMWI=");
@@ -254,6 +249,13 @@ public class InterfaceOperationTest {
private void deleteAndCreateCategory(String category) {
String[] names = category.split("/");
OperationTestsUtil.deleteAndCreateResourceCategory(names[0], names[1], titanDao);
+
+ /*
+ * CategoryData categoryData = new CategoryData(); categoryData.setName(category);
+ *
+ * titanDao.deleteNode(categoryData, CategoryData.class); Either<CategoryData, TitanOperationStatus> createNode = titanDao .createNode(categoryData, CategoryData.class); System.out.println("after creating caetgory " + createNode);
+ */
+
}
private UserData deleteAndCreateUser(String userId, String firstName, String lastName) {
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/LifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/LifecycleOperationTest.java
index 2b090f6f9f..23090fe143 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/LifecycleOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/LifecycleOperationTest.java
@@ -34,6 +34,7 @@ import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@@ -107,7 +108,7 @@ public class LifecycleOperationTest extends ModelTestBase {
private static final String CAPABILITY_NAME = "capName";
- private static final String USER_ID = "muserId";
+ private static final String USER_ID = "muUserId";
@javax.annotation.Resource
private TitanGenericDao titanGenericDao;
@@ -177,24 +178,19 @@ public class LifecycleOperationTest extends ModelTestBase {
@Before
public void setupBefore() {
clearGraph();
- UserData modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "co",
- ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
+ UserData modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "co", ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
checkoutUser = convertUserDataToUser(modifierData);
- modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "ci",
- ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
+ modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "ci", ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
checkinUser = convertUserDataToUser(modifierData);
- modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "rfc",
- ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
+ modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "rfc", ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
rfcUser = convertUserDataToUser(modifierData);
- modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "tester",
- ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "TESTER");
+ modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "tester", ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "TESTER");
testerUser = convertUserDataToUser(modifierData);
- modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "admin",
- ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
+ modifierData = deleteAndCreateUser(ResourceCreationUtils.MODIFIER_ATT_UID + "admin", ResourceCreationUtils.MODIFIER_FIRST_NAME, ResourceCreationUtils.MODIFIER_LAST_NAME, "ADMIN");
adminUser = convertUserDataToUser(modifierData);
modifierData = deleteAndCreateUser(USER_ID, "first_" + USER_ID, "last_" + USER_ID, "ADMIN");
@@ -229,13 +225,12 @@ public class LifecycleOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void getOwnerTest() {
- Resource resultResource = createTestResource(checkoutUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
+ Resource resultResource = createTestResource(checkoutUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -246,6 +241,7 @@ public class LifecycleOperationTest extends ModelTestBase {
/*********************** CHECKOUT ***************************************************************/
@Test
+ @Ignore
public void checkoutCertifiedTest() {
Resource resultResource = createTestResource(adminUser.getUserId(), "1.0", LifecycleStateEnum.CERTIFIED, null);
@@ -253,15 +249,13 @@ public class LifecycleOperationTest extends ModelTestBase {
Either<Resource, StorageOperationStatus> origResourceResult = resourceOperation.getResource(origUniqueId);
Resource origResource = origResourceResult.left().value();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkout
- Either<Resource, StorageOperationStatus> checkoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> checkoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkoutResponse.isLeft());
Resource checkoutResource = checkoutResponse.left().value();
@@ -271,8 +265,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(checkoutResource.getLastUpdaterUserId(), checkoutUser.getUserId());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkoutUser));
@@ -285,21 +278,19 @@ public class LifecycleOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void checkoutDefaultTest() {
- Resource resultResource = createTestResource(checkinUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Resource resultResource = createTestResource(checkinUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkout
- Either<Resource, StorageOperationStatus> checkoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> checkoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkoutResponse.isLeft());
Resource checkoutResource = checkoutResponse.left().value();
@@ -310,8 +301,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(checkoutResource.isHighestVersion(), true);
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkoutUser));
@@ -321,26 +311,23 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals("check resource created", true, getOrigResource.isLeft());
// assertEquals("assert original resource not changed", origResource,
// getOrigResource.left().value());
- assertEquals("assert original resource not highest version", false,
- getOrigResource.left().value().isHighestVersion());
+ assertEquals("assert original resource not highest version", false, getOrigResource.left().value().isHighestVersion());
}
@Test
+ @Ignore
public void checkoutFullResourceTest() {
- Resource origResource = createFullTestResource(checkinUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ Resource origResource = createFullTestResource(checkinUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
String origUniqueId = origResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkout
- Either<Resource, StorageOperationStatus> checkoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, origResource, checkoutUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> checkoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, origResource, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkoutResponse.isLeft());
Resource checkoutResource = checkoutResponse.left().value();
@@ -357,7 +344,7 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, InterfaceDefinition> interfaces = checkoutResource.getInterfaces();
assertTrue(interfaces.containsKey(INTERFACE_NAME));
InterfaceDefinition interfaceDef = interfaces.get(INTERFACE_NAME);
- Map<String, Operation> operations = interfaceDef.getOperations();
+ Map<String, Operation> operations = interfaceDef.getOperationsMap();
assertNotNull(operations);
assertFalse(operations.isEmpty());
assertTrue(operations.containsKey(INTERFACE_OPERATION_CREATE));
@@ -365,8 +352,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertNotNull(op.getImplementation());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkoutUser));
@@ -376,11 +362,11 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals("check resource created", true, getOrigResource.isLeft());
// assertEquals("assert original resource not changed", origResource,
// getOrigResource.left().value());
- assertEquals("assert original resource not highest version", false,
- getOrigResource.left().value().isHighestVersion());
+ assertEquals("assert original resource not highest version", false, getOrigResource.left().value().isHighestVersion());
}
@Test
+ @Ignore
public void getResourceOwnerResourceNotExistTest() {
// create resource metadata
@@ -393,8 +379,7 @@ public class LifecycleOperationTest extends ModelTestBase {
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner("my-resource.0.1",
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner("my-resource.0.1", NodeTypeEnum.Resource, false);
assertEquals("assert no owner", true, getOwnerResponse.isRight());
StorageOperationStatus status = getOwnerResponse.right().value();
@@ -404,6 +389,7 @@ public class LifecycleOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void checkoutResourceTwice() {
Resource resultResource = createTestResource(adminUser.getUserId(), "1.0", LifecycleStateEnum.CERTIFIED, null);
@@ -411,20 +397,17 @@ public class LifecycleOperationTest extends ModelTestBase {
Either<Resource, StorageOperationStatus> origResourceResult = resourceOperation.getResource(origUniqueId);
Resource origResource = origResourceResult.left().value();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// first checkout
- Either<Resource, StorageOperationStatus> checkoutResponse1 = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> checkoutResponse1 = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkoutResponse1.isLeft());
// second checkout
- Either<Resource, StorageOperationStatus> checkoutResponse2 = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, origResource, checkoutUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> checkoutResponse2 = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, origResource, checkoutUser, resourceOwner, false);
assertEquals("check checkout failed", true, checkoutResponse2.isRight());
assertEquals(StorageOperationStatus.ENTITY_ALREADY_EXISTS, checkoutResponse2.right().value());
@@ -434,19 +417,16 @@ public class LifecycleOperationTest extends ModelTestBase {
@Test
public void checkoutServiceDefaultTest() {
- Service resultResource = createTestService(checkinUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Service resultResource = createTestService(checkinUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkout
- Either<? extends Component, StorageOperationStatus> checkoutResponse = lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Service, resultResource, checkoutUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> checkoutResponse = lifecycleOperation.checkoutComponent(NodeTypeEnum.Service, resultResource, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkoutResponse.isLeft());
Component checkoutResource = checkoutResponse.left().value();
@@ -457,8 +437,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(checkoutResource.isHighestVersion(), true);
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkoutUser));
@@ -468,15 +447,14 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals("check resource created", true, getOrigResource.isLeft());
// assertEquals("assert original resource not changed", origResource,
// getOrigResource.left().value());
- assertEquals("assert original resource not highest version", false,
- getOrigResource.left().value().isHighestVersion());
+ assertEquals("assert original resource not highest version", false, getOrigResource.left().value().isHighestVersion());
}
@Test
+ @Ignore
public void checkoutFullServiceTest() {
- Service origService = createTestService(checkinUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Service origService = createTestService(checkinUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
String origUniqueId = origService.getUniqueId();
// add artifacts
@@ -485,12 +463,10 @@ public class LifecycleOperationTest extends ModelTestBase {
// add resource instances
ResourceInstanceOperationTest riTest = new ResourceInstanceOperationTest();
- riTest.setOperations(titanGenericDao, capabilityTypeOperation, requirementOperation, capabilityOperation,
- resourceOperation, propertyOperation, resourceInstanceOperation);
+ riTest.setOperations(titanGenericDao, capabilityTypeOperation, requirementOperation, capabilityOperation, resourceOperation, propertyOperation, resourceInstanceOperation);
riTest.addResourceInstancesAndRelation(origService.getUniqueId());
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -500,8 +476,7 @@ public class LifecycleOperationTest extends ModelTestBase {
origService = serviceBeforeCheckout.left().value();
// checkout
- Either<? extends Component, StorageOperationStatus> checkoutResponse = lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Service, origService, checkoutUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> checkoutResponse = lifecycleOperation.checkoutComponent(NodeTypeEnum.Service, origService, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkoutResponse.isLeft());
Service checkoutResource = (Service) checkoutResponse.left().value();
@@ -519,8 +494,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertFalse(checkoutResource.getComponentInstancesRelations().isEmpty());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(checkoutResource.getUniqueId(), NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkoutUser));
@@ -530,11 +504,11 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals("check service created", true, getOrigResource.isLeft());
// assertEquals("assert original resource not changed", origResource,
// getOrigResource.left().value());
- assertEquals("assert original service not highest version", false,
- getOrigResource.left().value().isHighestVersion());
+ assertEquals("assert original service not highest version", false, getOrigResource.left().value().isHighestVersion());
}
@Test
+ @Ignore
public void checkoutServiceTwice() {
Service resultResource = createTestService(adminUser.getUserId(), "1.0", LifecycleStateEnum.CERTIFIED, null);
@@ -542,20 +516,17 @@ public class LifecycleOperationTest extends ModelTestBase {
Either<Service, StorageOperationStatus> origResourceResult = serviceOperation.getService(origUniqueId);
Service origResource = origResourceResult.left().value();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// first checkout
- Either<? extends Component, StorageOperationStatus> checkoutResponse1 = lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Service, resultResource, checkoutUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> checkoutResponse1 = lifecycleOperation.checkoutComponent(NodeTypeEnum.Service, resultResource, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkoutResponse1.isLeft());
// second checkout
- Either<? extends Component, StorageOperationStatus> checkoutResponse2 = lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Service, origResource, checkoutUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> checkoutResponse2 = lifecycleOperation.checkoutComponent(NodeTypeEnum.Service, origResource, checkoutUser, resourceOwner, false);
assertEquals("check checkout failed", true, checkoutResponse2.isRight());
assertEquals(StorageOperationStatus.ENTITY_ALREADY_EXISTS, checkoutResponse2.right().value());
@@ -564,21 +535,19 @@ public class LifecycleOperationTest extends ModelTestBase {
/**************************** CHECKIN ********************************************************************/
@Test
+ @Ignore
public void checkinDefaultTest() {
- Resource resultResource = createTestResource(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
+ Resource resultResource = createTestResource(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkin
- Either<Resource, StorageOperationStatus> checkinResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkinComponent(NodeTypeEnum.Resource, resultResource, checkinUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> checkinResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkinComponent(NodeTypeEnum.Resource, resultResource, checkinUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkinResponse.isLeft());
Resource checkinResource = checkinResponse.left().value();
@@ -588,8 +557,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(checkinResource.getLastUpdaterUserId(), checkinUser.getUserId());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(checkinResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(checkinResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkinUser));
@@ -597,32 +565,27 @@ public class LifecycleOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void checkinFromRfcTest() {
- Resource resultResource = createTestResource(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
+ Resource resultResource = createTestResource(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkin
- Either<Resource, StorageOperationStatus> checkinResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkinComponent(NodeTypeEnum.Resource, resultResource, checkinUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> checkinResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkinComponent(NodeTypeEnum.Resource, resultResource, checkinUser, resourceOwner, false);
assertEquals("check resource object is returned", true, checkinResponse.isLeft());
// rfc
- Either<Resource, StorageOperationStatus> rfcResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Resource, checkinResponse.left().value(), rfcUser,
- checkinUser, false);
+ Either<Resource, StorageOperationStatus> rfcResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Resource, checkinResponse.left().value(), rfcUser, checkinUser, false);
assertEquals("check resource object is returned", true, checkinResponse.isLeft());
// checkin (cancel rfc)
- checkinResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkinComponent(NodeTypeEnum.Resource, rfcResponse.left().value(), checkinUser, rfcUser, false);
+ checkinResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkinComponent(NodeTypeEnum.Resource, rfcResponse.left().value(), checkinUser, rfcUser, false);
assertEquals("check resource object is returned", true, checkinResponse.isLeft());
resultResource = checkinResponse.left().value();
@@ -632,8 +595,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(resultResource.getLastUpdaterUserId(), checkinUser.getUserId());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkinUser));
@@ -644,13 +606,11 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
@@ -658,21 +618,19 @@ public class LifecycleOperationTest extends ModelTestBase {
/*** SERVICE */
@Test
+ @Ignore
public void checkinServiceDefaultTest() {
- Service resultService = createTestService(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
+ Service resultService = createTestService(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
String origUniqueId = resultService.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkin
- Either<? extends Component, StorageOperationStatus> checkinResponse = lifecycleOperation
- .checkinComponent(NodeTypeEnum.Service, resultService, checkinUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> checkinResponse = lifecycleOperation.checkinComponent(NodeTypeEnum.Service, resultService, checkinUser, resourceOwner, false);
assertEquals("check service object is returned", true, checkinResponse.isLeft());
Service checkinResource = (Service) checkinResponse.left().value();
@@ -682,8 +640,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(checkinResource.getLastUpdaterUserId(), checkinUser.getUserId());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(checkinResource.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(checkinResource.getUniqueId(), NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkinUser));
@@ -691,32 +648,27 @@ public class LifecycleOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void checkinServiceFromRfcTest() {
- Service resultResource = createTestService(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
+ Service resultResource = createTestService(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkin
- Either<? extends Component, StorageOperationStatus> checkinResponse = lifecycleOperation
- .checkinComponent(NodeTypeEnum.Service, resultResource, checkinUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> checkinResponse = lifecycleOperation.checkinComponent(NodeTypeEnum.Service, resultResource, checkinUser, resourceOwner, false);
assertEquals("check service object is returned", true, checkinResponse.isLeft());
// rfc
- Either<? extends Component, StorageOperationStatus> rfcResponse = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, checkinResponse.left().value(), rfcUser,
- checkinUser, false);
+ Either<? extends Component, StorageOperationStatus> rfcResponse = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, checkinResponse.left().value(), rfcUser, checkinUser, false);
assertEquals("check service object is returned", true, checkinResponse.isLeft());
// checkin (cancel rfc)
- checkinResponse = lifecycleOperation.checkinComponent(NodeTypeEnum.Service, rfcResponse.left().value(),
- checkinUser, rfcUser, false);
+ checkinResponse = lifecycleOperation.checkinComponent(NodeTypeEnum.Service, rfcResponse.left().value(), checkinUser, rfcUser, false);
assertEquals("check resource object is returned", true, checkinResponse.isLeft());
resultResource = (Service) checkinResponse.left().value();
@@ -726,8 +678,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(resultResource.getLastUpdaterUserId(), checkinUser.getUserId());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(checkinUser));
@@ -739,13 +690,11 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
@@ -756,14 +705,13 @@ public class LifecycleOperationTest extends ModelTestBase {
********************************************************************/
@Test
+ @Ignore
public void undoCheckoutNewResourceTest() {
- Resource resultResource = createTestResource(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
+ Resource resultResource = createTestResource(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -771,94 +719,81 @@ public class LifecycleOperationTest extends ModelTestBase {
//
// undo checkout
- Either<Resource, StorageOperationStatus> undoCheckoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .undoCheckout(NodeTypeEnum.Resource, resultResource, adminUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> undoCheckoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.undoCheckout(NodeTypeEnum.Resource, resultResource, adminUser, resourceOwner, false);
assertEquals("check resource object is returned", true, undoCheckoutResponse.isLeft());
Either<Resource, StorageOperationStatus> origResourceResult = resourceOperation.getResource(origUniqueId);
assertTrue(origResourceResult.isRight());
/*
- * assertTrue(origResourceResult.isLeft());
- * assertTrue(origResourceResult.left().value().getIsDeleted() == true);
+ * assertTrue(origResourceResult.isLeft()); assertTrue(origResourceResult.left().value().getIsDeleted() == true);
*/
}
@Test
+ @Ignore
public void undoCheckoutNewFullResourceTest() {
- Resource resultResource = createFullTestResource(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ Resource resultResource = createFullTestResource(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// undo checkout
- Either<Resource, StorageOperationStatus> undoCheckoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .undoCheckout(NodeTypeEnum.Resource, resultResource, adminUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> undoCheckoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.undoCheckout(NodeTypeEnum.Resource, resultResource, adminUser, resourceOwner, false);
assertEquals("check resource object is returned", true, undoCheckoutResponse.isLeft());
Either<Resource, StorageOperationStatus> origResourceResult = resourceOperation.getResource(origUniqueId);
/*
- * assertTrue(origResourceResult.isLeft());
- * assertTrue(origResourceResult.left().value().getIsDeleted() == true);
+ * assertTrue(origResourceResult.isLeft()); assertTrue(origResourceResult.left().value().getIsDeleted() == true);
*/ assertTrue(origResourceResult.isRight());
String interfaceId = origUniqueId + "." + INTERFACE_NAME;
- Either<InterfaceData, TitanOperationStatus> node = titanGenericDao
- .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Interface), interfaceId, InterfaceData.class);
+ Either<InterfaceData, TitanOperationStatus> node = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Interface), interfaceId, InterfaceData.class);
assertTrue(node.isRight());
String operationId = interfaceId + "." + INTERFACE_OPERATION_CREATE;
- Either<OperationData, TitanOperationStatus> op = titanGenericDao.getNode(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.InterfaceOperation), operationId, OperationData.class);
+ Either<OperationData, TitanOperationStatus> op = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.InterfaceOperation), operationId, OperationData.class);
assertTrue(op.isRight());
String capabilityId = "capability." + origUniqueId + "." + CAPABILITY_NAME;
- Either<CapabilityData, TitanOperationStatus> capability = titanGenericDao
- .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Capability), capabilityId, CapabilityData.class);
+ Either<CapabilityData, TitanOperationStatus> capability = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Capability), capabilityId, CapabilityData.class);
assertTrue(capability.isRight());
String requirementId = origUniqueId + "." + REQUIREMENT_NAME;
- Either<RequirementData, TitanOperationStatus> req = titanGenericDao.getNode(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Requirement), requirementId, RequirementData.class);
+ Either<RequirementData, TitanOperationStatus> req = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Requirement), requirementId, RequirementData.class);
assertTrue(req.isRight());
}
@Test
+ @Ignore
public void undoCheckoutExistingResourceTest() {
- Resource resultResource = createTestResource(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Resource resultResource = createTestResource(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
String prevResourceId = resultResource.getUniqueId();
- Either<Resource, StorageOperationStatus> result2 = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> result2 = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, resultResource, checkoutUser, resourceOwner, false);
assertEquals("check resource created", true, result2.isLeft());
Resource resultResource2 = result2.left().value();
// get resource owner
- getOwnerResponse = lifecycleOperation.getComponentOwner(resultResource2.getUniqueId(), NodeTypeEnum.Resource,
- false);
+ getOwnerResponse = lifecycleOperation.getComponentOwner(resultResource2.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
resourceOwner = getOwnerResponse.left().value();
assertEquals(resourceOwner, checkoutUser);
// undo checkout
- Either<Resource, StorageOperationStatus> undoCheckoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .undoCheckout(NodeTypeEnum.Resource, resultResource2, checkoutUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> undoCheckoutResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.undoCheckout(NodeTypeEnum.Resource, resultResource2, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, undoCheckoutResponse.isLeft());
// get previous resource
@@ -871,25 +806,22 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals("0.1", actualResource.getVersion());
assertEquals(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, actualResource.getLifecycleState());
- Either<Resource, StorageOperationStatus> origResourceResult = resourceOperation
- .getResource(resultResource2.getUniqueId());
+ Either<Resource, StorageOperationStatus> origResourceResult = resourceOperation.getResource(resultResource2.getUniqueId());
/*
- * assertTrue(origResourceResult.isLeft());
- * assertTrue(origResourceResult.left().value().getIsDeleted() == true);
+ * assertTrue(origResourceResult.isLeft()); assertTrue(origResourceResult.left().value().getIsDeleted() == true);
*/ assertTrue(origResourceResult.isRight());
}
/**** SERVICE ***/
@Test
+ @Ignore
public void undoCheckoutNewServiceTest() {
- Service resultResource = createTestService(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
+ Service resultResource = createTestService(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -897,23 +829,21 @@ public class LifecycleOperationTest extends ModelTestBase {
//
// undo checkout
- Either<? extends Component, StorageOperationStatus> undoCheckoutResponse = lifecycleOperation
- .undoCheckout(NodeTypeEnum.Service, resultResource, adminUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> undoCheckoutResponse = lifecycleOperation.undoCheckout(NodeTypeEnum.Service, resultResource, adminUser, resourceOwner, false);
assertEquals("check resource object is returned", true, undoCheckoutResponse.isLeft());
Either<Service, StorageOperationStatus> origResourceResult = serviceOperation.getService(origUniqueId);
/*
- * assertTrue(origResourceResult.isLeft());
- * assertTrue(origResourceResult.left().value().getIsDeleted() == true);
+ * assertTrue(origResourceResult.isLeft()); assertTrue(origResourceResult.left().value().getIsDeleted() == true);
*/ assertTrue(origResourceResult.isRight());
}
@Test
+ @Ignore
public void undoCheckoutNewFullServiceTest() {
- Service origService = createTestService(checkinUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Service origService = createTestService(checkinUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
String origUniqueId = origService.getUniqueId();
// add artifacts
@@ -922,12 +852,10 @@ public class LifecycleOperationTest extends ModelTestBase {
// add resource instances
ResourceInstanceOperationTest riTest = new ResourceInstanceOperationTest();
- riTest.setOperations(titanGenericDao, capabilityTypeOperation, requirementOperation, capabilityOperation,
- resourceOperation, propertyOperation, resourceInstanceOperation);
+ riTest.setOperations(titanGenericDao, capabilityTypeOperation, requirementOperation, capabilityOperation, resourceOperation, propertyOperation, resourceInstanceOperation);
riTest.addResourceInstancesAndRelation(origService.getUniqueId());
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -939,56 +867,48 @@ public class LifecycleOperationTest extends ModelTestBase {
List<ComponentInstance> resourceInstances = resultResource.getComponentInstances();
// undo checkout
- Either<? extends Component, StorageOperationStatus> undoCheckoutResponse = lifecycleOperation
- .undoCheckout(NodeTypeEnum.Service, resultResource, adminUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> undoCheckoutResponse = lifecycleOperation.undoCheckout(NodeTypeEnum.Service, resultResource, adminUser, resourceOwner, false);
assertEquals("check resource object is returned", true, undoCheckoutResponse.isLeft());
Either<Service, StorageOperationStatus> origResourceResult = serviceOperation.getService(origUniqueId);
/*
- * assertTrue(origResourceResult.isLeft());
- * assertTrue(origResourceResult.left().value().getIsDeleted() == true);
+ * assertTrue(origResourceResult.isLeft()); assertTrue(origResourceResult.left().value().getIsDeleted() == true);
*/ assertTrue(origResourceResult.isRight());
for (ComponentInstance ri : resourceInstances) {
- Either<ComponentInstanceData, TitanOperationStatus> node = titanGenericDao.getNode(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), ri.getUniqueId(),
- ComponentInstanceData.class);
+ Either<ComponentInstanceData, TitanOperationStatus> node = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), ri.getUniqueId(), ComponentInstanceData.class);
assertTrue(node.isRight());
}
}
@Test
+ @Ignore
public void undoCheckoutExistingServiceTest() {
- Service resultResource = createTestService(adminUser.getUserId(), "0.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Service resultResource = createTestService(adminUser.getUserId(), "0.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(resultResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
String prevResourceId = resultResource.getUniqueId();
- Either<? extends Component, StorageOperationStatus> result2 = lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Service, resultResource, checkoutUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> result2 = lifecycleOperation.checkoutComponent(NodeTypeEnum.Service, resultResource, checkoutUser, resourceOwner, false);
assertEquals("check resource created", true, result2.isLeft());
Component resultResource2 = result2.left().value();
String result2Uid = resultResource.getUniqueId();
// get resource owner
- getOwnerResponse = lifecycleOperation.getComponentOwner(resultResource2.getUniqueId(), NodeTypeEnum.Resource,
- false);
+ getOwnerResponse = lifecycleOperation.getComponentOwner(resultResource2.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
resourceOwner = getOwnerResponse.left().value();
assertEquals(resourceOwner, checkoutUser);
// undo checkout
- Either<? extends Component, StorageOperationStatus> undoCheckoutResponse = lifecycleOperation
- .undoCheckout(NodeTypeEnum.Service, resultResource2, checkoutUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> undoCheckoutResponse = lifecycleOperation.undoCheckout(NodeTypeEnum.Service, resultResource2, checkoutUser, resourceOwner, false);
assertEquals("check resource object is returned", true, undoCheckoutResponse.isLeft());
// get previous resource
@@ -1003,8 +923,7 @@ public class LifecycleOperationTest extends ModelTestBase {
Either<Service, StorageOperationStatus> origResourceResult = serviceOperation.getService(result2Uid);
/*
- * assertTrue(origResourceResult.isLeft());
- * assertTrue(origResourceResult.left().value().getIsDeleted() == true);
+ * assertTrue(origResourceResult.isLeft()); assertTrue(origResourceResult.left().value().getIsDeleted() == true);
*/ assertTrue(origResourceResult.isRight());
}
@@ -1014,6 +933,7 @@ public class LifecycleOperationTest extends ModelTestBase {
********************************************************************/
@Test
+ @Ignore
public void certReqDefaultTest() {
Resource actualResource = testCertificationRequest(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
@@ -1023,20 +943,19 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(adminUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@Test
+ @Ignore
public void atomicCheckinCertReqTest() {
Resource actualResource = testCertificationRequest(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
@@ -1046,14 +965,12 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@@ -1063,15 +980,13 @@ public class LifecycleOperationTest extends ModelTestBase {
Resource resultResource = createTestResource(adminUser.getUserId(), "0.1", preState, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkin
- Either<Resource, StorageOperationStatus> certReqResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, resourceOwner, false);
+ Either<Resource, StorageOperationStatus> certReqResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, resourceOwner, false);
assertEquals("check resource object is returned", true, certReqResponse.isLeft());
Resource resourceAfterChange = certReqResponse.left().value();
@@ -1081,8 +996,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(resourceAfterChange.getLastUpdaterUserId(), rfcUser.getUserId());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(resourceAfterChange.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(resourceAfterChange.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(rfcUser));
@@ -1092,6 +1006,7 @@ public class LifecycleOperationTest extends ModelTestBase {
/** SERVICE **/
@Test
+ @Ignore
public void certServiceReqDefaultTest() {
Service actualResource = testServiceCertificationRequest(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
@@ -1102,20 +1017,19 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(adminUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@Test
+ @Ignore
public void atomicServiceCheckinCertReqTest() {
Service actualResource = testServiceCertificationRequest(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
@@ -1126,14 +1040,12 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@@ -1143,15 +1055,13 @@ public class LifecycleOperationTest extends ModelTestBase {
Service resultResource = createTestService(adminUser.getUserId(), "0.1", preState, null);
String origUniqueId = resultResource.getUniqueId();
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId,
- NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(origUniqueId, NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
// checkin
- Either<? extends Component, StorageOperationStatus> certReqResponse = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultResource, rfcUser, resourceOwner, false);
+ Either<? extends Component, StorageOperationStatus> certReqResponse = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultResource, rfcUser, resourceOwner, false);
assertEquals("check resource object is returned", true, certReqResponse.isLeft());
Service resourceAfterChange = (Service) certReqResponse.left().value();
@@ -1161,8 +1071,7 @@ public class LifecycleOperationTest extends ModelTestBase {
assertEquals(resourceAfterChange.getLastUpdaterUserId(), rfcUser.getUserId());
// assert owner changed
- Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation
- .getComponentOwner(resourceAfterChange.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerCheckoutResponse = lifecycleOperation.getComponentOwner(resourceAfterChange.getUniqueId(), NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerCheckoutResponse.isLeft());
resourceOwner = getOwnerCheckoutResponse.left().value();
assertTrue(resourceOwner.equals(rfcUser));
@@ -1175,26 +1084,23 @@ public class LifecycleOperationTest extends ModelTestBase {
********************************************************************/
@Test
+ @Ignore
public void startCertificationTest() {
- Resource resultResource = createTestResource(checkinUser.getUserId(), "0.2",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Resource resultResource = createTestResource(checkinUser.getUserId(), "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// certification request
- Either<Resource, StorageOperationStatus> requestCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, checkinUser, false);
+ Either<Resource, StorageOperationStatus> requestCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, checkinUser, false);
assertTrue(requestCertificationResult.isLeft());
// start certification
- Either<Resource, StorageOperationStatus> startCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Resource, resultResource, testerUser, rfcUser, false);
+ Either<Resource, StorageOperationStatus> startCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation.startComponentCertification(NodeTypeEnum.Resource, resultResource, testerUser, rfcUser, false);
assertEquals(true, startCertificationResult.isLeft());
Resource actualResource = startCertificationResult.left().value();
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -1211,46 +1117,40 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(testerUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
/** SERVICE */
@Test
+ @Ignore
public void startServiceCertificationTest() {
- Service resultResource = createTestService(checkinUser.getUserId(), "0.2",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Service resultResource = createTestService(checkinUser.getUserId(), "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// certification request
- Either<? extends Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultResource, rfcUser, checkinUser, false);
+ Either<? extends Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultResource, rfcUser, checkinUser, false);
assertTrue(requestCertificationResult.isLeft());
// start certification
- Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultResource, testerUser, rfcUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultResource, testerUser, rfcUser, false);
assertEquals(true, startCertificationResult.isLeft());
Service actualResource = (Service) startCertificationResult.left().value();
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -1268,20 +1168,17 @@ public class LifecycleOperationTest extends ModelTestBase {
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(testerUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(serviceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@@ -1291,6 +1188,7 @@ public class LifecycleOperationTest extends ModelTestBase {
********************************************************************/
@Test
+ @Ignore
public void failCertificationTest() {
Resource actualResource = certificationStatusChange(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, checkinUser);
@@ -1302,19 +1200,16 @@ public class LifecycleOperationTest extends ModelTestBase {
// old edges removed
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
// new state is checkin
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@@ -1322,30 +1217,27 @@ public class LifecycleOperationTest extends ModelTestBase {
/*** SERVICE **/
@Test
+ @Ignore
public void failCertificationServiceTest() {
Service actualService = certificationStatusChangeService(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, checkinUser);
// assert relations
- ServiceMetadataData resourceData = new ServiceMetadataData((ServiceMetadataDataDefinition) actualService
- .getComponentMetadataDefinition().getMetadataDataDefinition());
+ ServiceMetadataData resourceData = new ServiceMetadataData((ServiceMetadataDataDefinition) actualService.getComponentMetadataDefinition().getMetadataDataDefinition());
Map<String, Object> props = new HashMap<String, Object>();
// old edges removed
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
// new state is checkin
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@@ -1355,6 +1247,7 @@ public class LifecycleOperationTest extends ModelTestBase {
********************************************************************/
@Test
+ @Ignore
public void cancelCertificationTest() {
Resource actualResource = certificationStatusChange(LifecycleStateEnum.READY_FOR_CERTIFICATION, rfcUser);
@@ -1366,26 +1259,24 @@ public class LifecycleOperationTest extends ModelTestBase {
// old edges removed
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
// new state is rfc
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
/** SERVICE **/
@Test
+ @Ignore
public void cancelCertificationServiceTest() {
Service actualService = certificationStatusChangeService(LifecycleStateEnum.READY_FOR_CERTIFICATION, rfcUser);
@@ -1397,20 +1288,17 @@ public class LifecycleOperationTest extends ModelTestBase {
// old edges removed
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(ServiceNode, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(ServiceNode, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(ServiceNode,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(ServiceNode, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(checkinUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
// new state is rfc
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(ServiceNode, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(ServiceNode, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@@ -1418,32 +1306,28 @@ public class LifecycleOperationTest extends ModelTestBase {
/**************************** CERTIFY ********************************************************************/
@Test
+ @Ignore
public void certifyTest() {
- Resource resultResource = createTestResource(checkinUser.getUserId(), "0.2",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Resource resultResource = createTestResource(checkinUser.getUserId(), "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// certification request
- Either<Resource, StorageOperationStatus> requestCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, checkinUser, false);
+ Either<Resource, StorageOperationStatus> requestCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, checkinUser, false);
assertTrue(requestCertificationResult.isLeft());
// start certification
- Either<Resource, StorageOperationStatus> startCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Resource, resultResource, testerUser, rfcUser, false);
+ Either<Resource, StorageOperationStatus> startCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation.startComponentCertification(NodeTypeEnum.Resource, resultResource, testerUser, rfcUser, false);
assertEquals(true, startCertificationResult.isLeft());
Resource actualResource = startCertificationResult.left().value();
// cancel certification
- Either<? extends Component, StorageOperationStatus> CertificationResult = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Resource, actualResource, testerUser, testerUser, false);
+ Either<? extends Component, StorageOperationStatus> CertificationResult = lifecycleOperation.certifyComponent(NodeTypeEnum.Resource, actualResource, testerUser, testerUser, false);
assertEquals(true, CertificationResult.isLeft());
actualResource = (Resource) CertificationResult.left().value();
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -1461,25 +1345,21 @@ public class LifecycleOperationTest extends ModelTestBase {
// old edges removed
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
// new state is certified
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFIED);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(testerUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
@@ -1488,32 +1368,28 @@ public class LifecycleOperationTest extends ModelTestBase {
/******** SERVICE **/
@Test
+ @Ignore
public void certifyServiceTest() {
- Service resultService = createTestService(checkinUser.getUserId(), "0.2",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Service resultService = createTestService(checkinUser.getUserId(), "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// certification request
- Either<? extends Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService, rfcUser, checkinUser, false);
+ Either<? extends Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService, rfcUser, checkinUser, false);
assertTrue(requestCertificationResult.isLeft());
// start certification
- Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService, testerUser, rfcUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService, testerUser, rfcUser, false);
assertEquals(true, startCertificationResult.isLeft());
Service actualService = (Service) startCertificationResult.left().value();
// cancel certification
- Either<? extends Component, StorageOperationStatus> CertificationResult = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Service, actualService, testerUser, testerUser, false);
+ Either<? extends Component, StorageOperationStatus> CertificationResult = lifecycleOperation.certifyComponent(NodeTypeEnum.Service, actualService, testerUser, testerUser, false);
assertEquals(true, CertificationResult.isLeft());
actualService = (Service) CertificationResult.left().value();
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(actualService.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(actualService.getUniqueId(), NodeTypeEnum.Service, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -1531,52 +1407,42 @@ public class LifecycleOperationTest extends ModelTestBase {
// old edges removed
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao
- .getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
+ Either<GraphRelation, TitanOperationStatus> incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isRight());
// new state is certified
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFIED);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE,
- props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(testerUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
props.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
- incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData,
- GraphEdgeLabels.LAST_STATE, props);
+ incomingRelationByCriteria = titanGenericDao.getIncomingRelationByCriteria(resourceData, GraphEdgeLabels.LAST_STATE, props);
assertTrue(incomingRelationByCriteria.isLeft());
assertEquals(rfcUser.getUserId(), incomingRelationByCriteria.left().value().getFrom().getIdValue());
}
@Test
+ @Ignore
public void testDeleteOldVersionsResource() {
// simulate
createTestResource(checkinUser.getUserId(), "1.0", LifecycleStateEnum.CERTIFIED, null);
- Resource resourceNewVersion = createTestResource(checkinUser.getUserId(), "1.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
- createTestResource(checkinUser.getUserId(), "1.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN,
- resourceNewVersion.getUUID());
- createTestResource(checkinUser.getUserId(), "1.3", LifecycleStateEnum.CERTIFICATION_IN_PROGRESS,
- resourceNewVersion.getUUID());
- Resource certifiedResource = createTestResource(checkinUser.getUserId(), "2.0", LifecycleStateEnum.CERTIFIED,
- resourceNewVersion.getUUID());
-
- Either<Boolean, StorageOperationStatus> deleteOldComponentVersions = lifecycleOperation
- .deleteOldComponentVersions(NodeTypeEnum.Resource, certifiedResource.getName(),
- certifiedResource.getUUID(), false);
+ Resource resourceNewVersion = createTestResource(checkinUser.getUserId(), "1.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ createTestResource(checkinUser.getUserId(), "1.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, resourceNewVersion.getUUID());
+ createTestResource(checkinUser.getUserId(), "1.3", LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, resourceNewVersion.getUUID());
+ Resource certifiedResource = createTestResource(checkinUser.getUserId(), "2.0", LifecycleStateEnum.CERTIFIED, resourceNewVersion.getUUID());
+
+ Either<Boolean, StorageOperationStatus> deleteOldComponentVersions = lifecycleOperation.deleteOldComponentVersions(NodeTypeEnum.Resource, certifiedResource.getName(), certifiedResource.getUUID(), false);
assertTrue(deleteOldComponentVersions.isLeft());
String resourceName = certifiedResource.getName();
- Either<List<Resource>, StorageOperationStatus> resource = resourceOperation
- .getResourceByNameAndVersion(resourceName, "1.0", false);
+ Either<List<Resource>, StorageOperationStatus> resource = resourceOperation.getResourceByNameAndVersion(resourceName, "1.0", false);
assertTrue(resource.isLeft());
resource = resourceOperation.getResourceByNameAndVersion(resourceName, "2.0", false);
@@ -1608,29 +1474,179 @@ public class LifecycleOperationTest extends ModelTestBase {
deleted = resource.left().value().get(0);
assertTrue(deleted.getIsDeleted());
}
-
+
+ // @Test
+ // public void testDeleteOldVersionsResourceWithArtifacts(){
+ // // simulate
+ // Resource resource = createFullTestResource(checkinUser.getUserId(),
+ // "1.0", LifecycleStateEnum.CERTIFIED);
+ //
+ // // checkout
+ // Either<Resource, StorageOperationStatus> checkoutResource =
+ // lifecycleOperation.checkoutResource(resource, checkinUser, checkinUser,
+ // false);
+ // assertTrue(checkoutResource.isLeft());
+ // Either<Resource, StorageOperationStatus> getResource =
+ // resourceOperation.getResourceByNameAndVersion(resource.getResourceName(),
+ // "1.1", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // // rfc
+ // resource = getResource.left().value();
+ // Either<Resource, StorageOperationStatus> requestCertification =
+ // lifecycleOperation.requestCertification(resource, rfcUser, checkinUser,
+ // false);
+ // assertTrue(requestCertification.isLeft());
+ // getResource =
+ // resourceOperation.getResourceByNameAndVersion(resource.getResourceName(),
+ // "1.1", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // // start cert
+ // resource = getResource.left().value();
+ // Either<Resource, StorageOperationStatus> startCertification =
+ // lifecycleOperation.startCertificationResource(resource, testerUser,
+ // rfcUser, false);
+ // assertTrue(startCertification.isLeft());
+ // getResource =
+ // resourceOperation.getResourceByNameAndVersion(resource.getResourceName(),
+ // "1.1", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // // certify
+ // resource = getResource.left().value();
+ // Either<Resource, StorageOperationStatus> certify =
+ // lifecycleOperation.certifyResource(resource, testerUser, testerUser,
+ // false);
+ // assertTrue(certify.isLeft());
+ // getResource =
+ // resourceOperation.getResourceByNameAndVersion(resource.getResourceName(),
+ // "1.1", false);
+ // assertTrue(getResource.isLeft());
+ // resource = getResource.left().value();
+ //
+ //
+ // Either<List<ArtifactDefinition>, StorageOperationStatus>
+ // deleteOldComponentVersions = lifecycleOperation
+ // .deleteOldComponentVersions(NodeTypeEnum.Resource,
+ // resource.getResourceName(), resource.getUUID(), false);
+ //
+ // assertTrue(deleteOldComponentVersions.isLeft());
+ // assertEquals(2, deleteOldComponentVersions.left().value().size());
+ //
+ // String resourceName = resource.getResourceName();
+ // getResource = resourceOperation.getResourceByNameAndVersion(resourceName,
+ // "1.0", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // getResource = resourceOperation.getResourceByNameAndVersion(resourceName,
+ // "2.0", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // getResource = resourceOperation.getResourceByNameAndVersion(resourceName,
+ // "1.1", false);
+ // assertTrue(getResource.isRight());
+ // assertEquals(StorageOperationStatus.NOT_FOUND,
+ // getResource.right().value());
+ //
+ // }
+
+ // @Test
+ // public void testDeleteOldVersionsResourceWithArtifactsDerived(){
+ // // simulate
+ // Resource resourceRoot = createFullTestResource(checkinUser.getUserId(),
+ // "1.0", LifecycleStateEnum.CERTIFIED);
+ // Resource resource = buildResourceMetadata(checkinUser.getUserId(),
+ // CATEGORY_NAME);
+ // resource.setResourceName("myDerivedResource");
+ // resource.setResourceVersion("0.1");
+ // resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ // List<String> derived = new ArrayList<>();
+ // derived.add(resourceRoot.getResourceName());
+ // resource.setDerivedFrom(derived);
+ //
+ // Either<Resource, StorageOperationStatus> result =
+ // resourceOperation.createResource(resource);
+ // assertEquals("check resource created", true, result.isLeft());
+ // resource = result.left().value();
+ //
+ // // resource inherits the artifacts from parent
+ // assertNotNull(resource.getInterfaces().get(INTERFACE_NAME).getOperations().get(INTERFACE_OPERATION_CREATE).getImplementation());
+ //
+ // // rfc
+ // Either<Resource, StorageOperationStatus> requestCertification =
+ // lifecycleOperation.requestCertification(resource, rfcUser, checkinUser,
+ // false);
+ // assertTrue(requestCertification.isLeft());
+ // Either<Resource, StorageOperationStatus> getResource =
+ // resourceOperation.getResourceByNameAndVersion(resource.getResourceName(),
+ // "0.1", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // // start cert
+ // resource = getResource.left().value();
+ // Either<Resource, StorageOperationStatus> startCertification =
+ // lifecycleOperation.startCertificationResource(resource, testerUser,
+ // rfcUser, false);
+ // assertTrue(startCertification.isLeft());
+ // getResource =
+ // resourceOperation.getResourceByNameAndVersion(resource.getResourceName(),
+ // "0.1", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // // certify
+ // resource = getResource.left().value();
+ // Either<Resource, StorageOperationStatus> certify =
+ // lifecycleOperation.certifyResource(resource, testerUser, testerUser,
+ // false);
+ // assertTrue(certify.isLeft());
+ // getResource =
+ // resourceOperation.getResourceByNameAndVersion(resource.getResourceName(),
+ // "0.1", false);
+ // assertTrue(getResource.isLeft());
+ // resource = getResource.left().value();
+ //
+ //
+ // Either<List<ArtifactDefinition>, StorageOperationStatus>
+ // deleteOldComponentVersions = lifecycleOperation
+ // .deleteOldComponentVersions(NodeTypeEnum.Resource,
+ // resource.getResourceName(), resource.getUUID(), false);
+ //
+ // assertTrue(deleteOldComponentVersions.isLeft());
+ //
+ // // resource artifacts are not really the resource's, they are the
+ // parent's artifacts
+ // assertTrue(deleteOldComponentVersions.left().value().isEmpty());
+ //
+ // String resourceName = resource.getResourceName();
+ // getResource = resourceOperation.getResourceByNameAndVersion(resourceName,
+ // "1.0", false);
+ // assertTrue(getResource.isLeft());
+ //
+ // getResource = resourceOperation.getResourceByNameAndVersion(resourceName,
+ // "0.1", false);
+ // assertTrue(getResource.isRight());
+ // assertEquals(StorageOperationStatus.NOT_FOUND,
+ // getResource.right().value());
+ //
+ // }
+
@Test
+ @Ignore
public void testDeleteOldVersionsService() {
// simulate
createTestService(checkinUser.getUserId(), "1.0", LifecycleStateEnum.CERTIFIED, null);
- Service serviceNewUUid = createTestService(checkinUser.getUserId(), "1.1",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
- createTestService(checkinUser.getUserId(), "1.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN,
- serviceNewUUid.getUUID());
- createTestService(checkinUser.getUserId(), "1.3", LifecycleStateEnum.CERTIFICATION_IN_PROGRESS,
- serviceNewUUid.getUUID());
- Service certifiedService = createTestService(checkinUser.getUserId(), "2.0", LifecycleStateEnum.CERTIFIED,
- serviceNewUUid.getUUID());
-
- Either<Boolean, StorageOperationStatus> deleteOldComponentVersions = lifecycleOperation
- .deleteOldComponentVersions(NodeTypeEnum.Service, certifiedService.getName(),
- certifiedService.getUUID(), false);
+ Service serviceNewUUid = createTestService(checkinUser.getUserId(), "1.1", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ createTestService(checkinUser.getUserId(), "1.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, serviceNewUUid.getUUID());
+ createTestService(checkinUser.getUserId(), "1.3", LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, serviceNewUUid.getUUID());
+ Service certifiedService = createTestService(checkinUser.getUserId(), "2.0", LifecycleStateEnum.CERTIFIED, serviceNewUUid.getUUID());
+
+ Either<Boolean, StorageOperationStatus> deleteOldComponentVersions = lifecycleOperation.deleteOldComponentVersions(NodeTypeEnum.Service, certifiedService.getName(), certifiedService.getUUID(), false);
assertTrue(deleteOldComponentVersions.isLeft());
String resourceName = certifiedService.getName();
- Either<Service, StorageOperationStatus> service = serviceOperation.getServiceByNameAndVersion(resourceName,
- "1.0", null, false);
+ Either<Service, StorageOperationStatus> service = serviceOperation.getServiceByNameAndVersion(resourceName, "1.0", null, false);
assertTrue(service.isLeft());
service = serviceOperation.getServiceByNameAndVersion(resourceName, "2.0", null, false);
@@ -1638,9 +1654,7 @@ public class LifecycleOperationTest extends ModelTestBase {
service = serviceOperation.getServiceByNameAndVersion(resourceName, "1.1", null, false);
/*
- * assertTrue(resource.isRight());
- * assertEquals(StorageOperationStatus.NOT_FOUND,
- * resource.right().value());
+ * assertTrue(resource.isRight()); assertEquals(StorageOperationStatus.NOT_FOUND, resource.right().value());
*/
assertTrue(service.isLeft());
assertTrue(service.left().value().getIsDeleted());
@@ -1649,18 +1663,14 @@ public class LifecycleOperationTest extends ModelTestBase {
service = serviceOperation.getServiceByNameAndVersion(resourceName, "1.3", null, false);
/*
- * assertTrue(service.isRight());
- * assertEquals(StorageOperationStatus.NOT_FOUND,
- * service.right().value());
+ * assertTrue(service.isRight()); assertEquals(StorageOperationStatus.NOT_FOUND, service.right().value());
*/
assertTrue(service.isLeft());
assertTrue(service.left().value().getIsDeleted());
service = serviceOperation.getServiceByNameAndVersion(resourceName, "1.3", null, false);
/*
- * assertTrue(service.isRight());
- * assertEquals(StorageOperationStatus.NOT_FOUND,
- * service.right().value());
+ * assertTrue(service.isRight()); assertEquals(StorageOperationStatus.NOT_FOUND, service.right().value());
*/
assertTrue(service.isLeft());
assertTrue(service.left().value().getIsDeleted());
@@ -1668,31 +1678,25 @@ public class LifecycleOperationTest extends ModelTestBase {
}
private Resource certificationStatusChange(LifecycleStateEnum nextState, User expectedOwner) {
- Resource resultResource = createTestResource(checkinUser.getUserId(), "0.2",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Resource resultResource = createTestResource(checkinUser.getUserId(), "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// certification request
- Either<Resource, StorageOperationStatus> requestCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, checkinUser, false);
+ Either<Resource, StorageOperationStatus> requestCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Resource, resultResource, rfcUser, checkinUser, false);
assertTrue(requestCertificationResult.isLeft());
// start certification
- Either<Resource, StorageOperationStatus> startCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Resource, resultResource, testerUser, rfcUser, false);
+ Either<Resource, StorageOperationStatus> startCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation.startComponentCertification(NodeTypeEnum.Resource, resultResource, testerUser, rfcUser, false);
assertEquals(true, startCertificationResult.isLeft());
Resource actualResource = startCertificationResult.left().value();
// cancel certification
- Either<Resource, StorageOperationStatus> failCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .cancelOrFailCertification(NodeTypeEnum.Resource, actualResource, testerUser, testerUser, nextState,
- false);
+ Either<Resource, StorageOperationStatus> failCertificationResult = (Either<Resource, StorageOperationStatus>) lifecycleOperation.cancelOrFailCertification(NodeTypeEnum.Resource, actualResource, testerUser, testerUser, nextState, false);
assertEquals(true, failCertificationResult.isLeft());
actualResource = failCertificationResult.left().value();
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(actualResource.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -1706,31 +1710,25 @@ public class LifecycleOperationTest extends ModelTestBase {
}
private Service certificationStatusChangeService(LifecycleStateEnum nextState, User expectedOwner) {
- Service resultService = createTestService(checkinUser.getUserId(), "0.2",
- LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
+ Service resultService = createTestService(checkinUser.getUserId(), "0.2", LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, null);
// certification request
- Either<? extends Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService, rfcUser, checkinUser, false);
+ Either<? extends Component, StorageOperationStatus> requestCertificationResult = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService, rfcUser, checkinUser, false);
assertTrue(requestCertificationResult.isLeft());
// start certification
- Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService, testerUser, rfcUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService, testerUser, rfcUser, false);
assertEquals(true, startCertificationResult.isLeft());
Service actualService = (Service) startCertificationResult.left().value();
// cancel certification
- Either<? extends Component, StorageOperationStatus> failCertificationResult = lifecycleOperation
- .cancelOrFailCertification(NodeTypeEnum.Service, actualService, testerUser, testerUser, nextState,
- false);
+ Either<? extends Component, StorageOperationStatus> failCertificationResult = lifecycleOperation.cancelOrFailCertification(NodeTypeEnum.Service, actualService, testerUser, testerUser, nextState, false);
assertEquals(true, failCertificationResult.isLeft());
actualService = (Service) failCertificationResult.left().value();
// get resource owner
- Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation
- .getComponentOwner(actualService.getUniqueId(), NodeTypeEnum.Resource, false);
+ Either<User, StorageOperationStatus> getOwnerResponse = lifecycleOperation.getComponentOwner(actualService.getUniqueId(), NodeTypeEnum.Resource, false);
assertEquals("check user object is returned", true, getOwnerResponse.isLeft());
User resourceOwner = getOwnerResponse.left().value();
@@ -1789,13 +1787,14 @@ public class LifecycleOperationTest extends ModelTestBase {
}
private Resource createFullTestResource(String userId, String version, LifecycleStateEnum state) {
-
Resource resource2 = buildResourceMetadata(userId, CATEGORY_NAME);
resource2.setVersion(version);
;
resource2.setLifecycleState(state);
InterfaceDefinition inter = new InterfaceDefinition(INTERFACE_NAME, "interface description", null);
+ // inter.setUniqueId(UniqueIdBuilder.buildResourceUniqueId(resource2.getResourceName(),
+ // resource2.getResourceVersion())+"."+INTERFACE_NAME);
Operation operation = new Operation();
operation.setDescription("op description");
@@ -1815,7 +1814,7 @@ public class LifecycleOperationTest extends ModelTestBase {
operation.setCreationDate(System.currentTimeMillis());
Map<String, Operation> ops = new HashMap<>();
ops.put(INTERFACE_OPERATION_CREATE, operation);
- inter.setOperations(ops);
+ inter.setOperationsMap(ops);
Map<String, InterfaceDefinition> interfaces = new HashMap<>();
interfaces.put(INTERFACE_NAME, inter);
@@ -1870,8 +1869,7 @@ public class LifecycleOperationTest extends ModelTestBase {
// artifacts.put("myArtifact", artifactDef);
// resource2.setArtifacts(artifacts);
- Either<ArtifactDefinition, StorageOperationStatus> addArifactToResource = artifactOperation
- .addArifactToComponent(artifactDef, resultResource.getUniqueId(), NodeTypeEnum.Resource, false, true);
+ Either<ArtifactDefinition, StorageOperationStatus> addArifactToResource = artifactOperation.addArifactToComponent(artifactDef, resultResource.getUniqueId(), NodeTypeEnum.Resource, false, true);
assertTrue(addArifactToResource.isLeft());
Either<Resource, StorageOperationStatus> resource = resourceOperation.getResource(resultResource.getUniqueId());
@@ -1894,8 +1892,7 @@ public class LifecycleOperationTest extends ModelTestBase {
properties.put(propName1, property1);
capabilityTypeDefinition.setProperties(properties);
- Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation
- .addCapabilityType(capabilityTypeDefinition);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition);
assertTrue(addCapabilityType1.isLeft());
}
@@ -1945,12 +1942,18 @@ public class LifecycleOperationTest extends ModelTestBase {
return userData;
}
-
+
+ /*
+ * public void deleteAndCreateCategory(String category) { CategoryData categoryData = new CategoryData(); categoryData.setName(category);
+ *
+ * Either<CategoryData, TitanOperationStatus> node = titanGenericDao.getNode(categoryData.getUniqueIdKey(), categoryData, CategoryData.class); if (node.isRight()){ //titanGenericDao.deleteNode(categoryData, CategoryData.class);
+ * Either<CategoryData, TitanOperationStatus> createNode = titanGenericDao .createNode(categoryData, CategoryData.class); System.out.println("after creating caetgory " + createNode); }
+ */
+
private PropertyDefinition buildProperty1() {
PropertyDefinition property1 = new PropertyDefinition();
property1.setDefaultValue("10");
- property1.setDescription(
- "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
+ property1.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
property1.setType(ToscaType.INTEGER.name().toLowerCase());
List<PropertyConstraint> constraints = new ArrayList<PropertyConstraint>();
GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0");
@@ -1982,8 +1985,7 @@ public class LifecycleOperationTest extends ModelTestBase {
artifactInfo.setArtifactLabel(artifactName);
artifactInfo.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(serviceId, artifactInfo.getArtifactLabel()));
- Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation
- .addArifactToComponent(artifactInfo, serviceId, NodeTypeEnum.Service, true, true);
+ Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation.addArifactToComponent(artifactInfo, serviceId, NodeTypeEnum.Service, true, true);
assertTrue(artifact.isLeft());
return artifactInfo;
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
index 5bd6c831a5..ee129c6529 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
@@ -84,8 +84,7 @@ public class PolicyTypeOperationTest extends ModelTestBase {
PolicyTypeDefinition policyTypePreCreate = createPolicyTypeDef();
assertTrue(StringUtils.isEmpty(policyTypePreCreate.getUniqueId()));
- Either<PolicyTypeDefinition, StorageOperationStatus> addPolicyType = policyTypeOperation
- .addPolicyType(policyTypePreCreate);
+ Either<PolicyTypeDefinition, StorageOperationStatus> addPolicyType = policyTypeOperation.addPolicyType(policyTypePreCreate);
assertTrue(addPolicyType.isLeft());
PolicyTypeDefinition policyTypePostCreate = addPolicyType.left().value();
assertEquals(policyTypePostCreate.getType(), policyTypePreCreate.getType());
@@ -96,10 +95,8 @@ public class PolicyTypeOperationTest extends ModelTestBase {
@Test
public void testGetLatestPolicyTypeByType() {
- PolicyTypeDefinition policyTypeCreated = policyTypeOperation.addPolicyType(createPolicyTypeDef()).left()
- .value();
- Either<PolicyTypeDefinition, StorageOperationStatus> eitherPolicyTypeFetched = policyTypeOperation
- .getLatestPolicyTypeByType(policyTypeCreated.getType());
+ PolicyTypeDefinition policyTypeCreated = policyTypeOperation.addPolicyType(createPolicyTypeDef()).left().value();
+ Either<PolicyTypeDefinition, StorageOperationStatus> eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyTypeCreated.getType());
assertTrue(eitherPolicyTypeFetched.isLeft());
PolicyTypeDefinition policyTypeFetched = eitherPolicyTypeFetched.left().value();
assertEquals(policyTypeFetched.toString(), policyTypeCreated.toString());
@@ -108,8 +105,7 @@ public class PolicyTypeOperationTest extends ModelTestBase {
private PolicyTypeDefinition createPolicyTypeDef() {
PolicyTypeDataDefinition policyTypeDataDefinition = new PolicyTypeDataDefinition();
- policyTypeDataDefinition
- .setDescription("description: The TOSCA Policy Type all other TOSCA Policy Types derive from");
+ policyTypeDataDefinition.setDescription("description: The TOSCA Policy Type all other TOSCA Policy Types derive from");
policyTypeDataDefinition.setType("tosca.policies.Root");
PolicyTypeDefinition policyTypeDefinition = new PolicyTypeDefinition(policyTypeDataDefinition);
policyTypeDefinition.setHighestVersion(true);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
index 6caa3044ad..71d2b32a6f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
@@ -61,9 +61,9 @@ import fj.data.Either;
public class PropertyOperationTest extends ModelTestBase {
- PropertyOperation propertyOperation = new PropertyOperation();
-
TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class);
+
+ PropertyOperation propertyOperation = new PropertyOperation(titanGenericDao);
@Before
public void setup() {
@@ -74,46 +74,28 @@ public class PropertyOperationTest extends ModelTestBase {
/*
* @Test public void addPropertyToResourceTest() {
*
- * String propName = "myProp"; PropertyDefinition property =
- * buildPropertyDefinition(); List<PropertyConstraint> constraints =
- * buildConstraints(); property.setConstraints(constraints);
+ * String propName = "myProp"; PropertyDefinition property = buildPropertyDefinition(); List<PropertyConstraint> constraints = buildConstraints(); property.setConstraints(constraints);
*
- * PropertyData propertyData = new PropertyData(property,
- * propertyOperation.convertConstraintsToString(constraints));
+ * PropertyData propertyData = new PropertyData(property, propertyOperation.convertConstraintsToString(constraints));
*
- * Either<PropertyData, TitanOperationStatus> either =
- * Either.left(propertyData);
- * //when(propertyDao.create((GraphNeighbourTable)anyObject(),
- * eq(PropertyData.class), eq(NodeTypeEnum.Property))).thenReturn(either);
- * GraphRelation graphRelation = new GraphRelation(); Either<GraphRelation,
- * TitanOperationStatus> relationResult = Either.left(graphRelation);
+ * Either<PropertyData, TitanOperationStatus> either = Either.left(propertyData); //when(propertyDao.create((GraphNeighbourTable)anyObject(), eq(PropertyData.class), eq(NodeTypeEnum.Property))).thenReturn(either); GraphRelation graphRelation =
+ * new GraphRelation(); Either<GraphRelation, TitanOperationStatus> relationResult = Either.left(graphRelation);
*
- * when(titanGenericDao.createNode((PropertyData)anyObject(),
- * eq(PropertyData.class))).thenReturn(either);
- * when(titanGenericDao.createRelation((GraphNode)anyObject(),
- * (GraphNode)anyObject(), eq(GraphEdgeLabels.PROPERTY),
+ * when(titanGenericDao.createNode((PropertyData)anyObject(), eq(PropertyData.class))).thenReturn(either); when(titanGenericDao.createRelation((GraphNode)anyObject(), (GraphNode)anyObject(), eq(GraphEdgeLabels.PROPERTY),
* anyMap())).thenReturn(relationResult);
*
- * Either<PropertyDefinition, StorageOperationStatus> result =
- * propertyOperation.addPropertyToResource(propName, property,
- * NodeTypeEnum.Resource, "my-resource.1.0");
+ * Either<PropertyDefinition, StorageOperationStatus> result = propertyOperation.addPropertyToResource(propName, property, NodeTypeEnum.Resource, "my-resource.1.0");
*
- * assertTrue(result.isLeft()); System.out.println(result.left().value());
- * PropertyDefinition propertyDefinition = result.left().value();
+ * assertTrue(result.isLeft()); System.out.println(result.left().value()); PropertyDefinition propertyDefinition = result.left().value();
*
- * List<PropertyConstraint> originalConstraints = property.getConstraints();
- * List<PropertyConstraint> propertyConstraintsResult =
- * propertyDefinition.getConstraints();
- * assertEquals(propertyConstraintsResult.size(),
- * originalConstraints.size());
+ * List<PropertyConstraint> originalConstraints = property.getConstraints(); List<PropertyConstraint> propertyConstraintsResult = propertyDefinition.getConstraints(); assertEquals(propertyConstraintsResult.size(), originalConstraints.size());
*
* }
*/
private PropertyDefinition buildPropertyDefinition() {
PropertyDefinition property = new PropertyDefinition();
property.setDefaultValue("10");
- property.setDescription(
- "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
+ property.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
property.setType(ToscaType.INTEGER.name().toLowerCase());
return property;
}
@@ -179,8 +161,7 @@ public class PropertyOperationTest extends ModelTestBase {
List<String> convertedStringConstraints = propertyOperation.convertConstraintsToString(constraints);
assertEquals("constraints size", constraints.size(), convertedStringConstraints.size());
- List<PropertyConstraint> convertedConstraints = propertyOperation
- .convertConstraints(convertedStringConstraints);
+ List<PropertyConstraint> convertedConstraints = propertyOperation.convertConstraints(convertedStringConstraints);
assertEquals("check size of constraints", constraints.size(), convertedConstraints.size());
Set<String> constraintsClasses = new HashSet<String>();
@@ -189,8 +170,7 @@ public class PropertyOperationTest extends ModelTestBase {
}
for (PropertyConstraint propertyConstraint : convertedConstraints) {
- assertTrue("check all classes generated",
- constraintsClasses.contains(propertyConstraint.getClass().getName()));
+ assertTrue("check all classes generated", constraintsClasses.contains(propertyConstraint.getClass().getName()));
}
}
@@ -322,8 +302,7 @@ public class PropertyOperationTest extends ModelTestBase {
assertEquals("check value", "v1node1", instanceProperty.getValue());
assertEquals("check default value", "v1node3", instanceProperty.getDefaultValue());
- assertEquals("check valid unique id", instanceProperty1.getValueUniqueUid(),
- instanceProperty.getValueUniqueUid());
+ assertEquals("check valid unique id", instanceProperty1.getValueUniqueUid(), instanceProperty.getValueUniqueUid());
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RequirementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RequirementOperationTest.java
index fe4b501148..62e6adab7f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RequirementOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RequirementOperationTest.java
@@ -21,46 +21,26 @@
package org.openecomp.sdc.be.model.operations.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.openecomp.sdc.be.config.Configuration;
-import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.CapabiltyInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.ModelTestBase;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.RequirementImplDef;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.CapabilityOperation;
-import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.model.operations.impl.RequirementOperation;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
-import org.openecomp.sdc.be.model.operations.impl.util.PrintGraph;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
import org.openecomp.sdc.be.resources.data.UserData;
-import org.openecomp.sdc.common.api.ConfigurationListener;
-import org.openecomp.sdc.common.api.ConfigurationSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
@@ -77,11 +57,9 @@ public class RequirementOperationTest extends ModelTestBase {
private static Logger log = LoggerFactory.getLogger(RequirementOperationTest.class.getName());
private Gson prettyGson = new GsonBuilder().setPrettyPrinting().create();
- private static String USER_ID = "muserId";
+ private static String USER_ID = "muUserId";
private static String CATEGORY_NAME = "category/mycategory";
- private static ConfigurationManager configurationManager;
-
@javax.annotation.Resource(name = "titan-generic-dao")
private TitanGenericDao titanDao;
@@ -147,11 +125,9 @@ public class RequirementOperationTest extends ModelTestBase {
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", "0.1", null,
- true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", "0.1", null, true, true);
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation
- .addRequirementToResource(reqName, reqDefinition, resource.getUniqueId());
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation.addRequirementToResource(reqName, reqDefinition, resource.getUniqueId());
assertEquals("check error", StorageOperationStatus.INVALID_ID, addRequirementToResource.right().value());
}
@@ -175,8 +151,17 @@ public class RequirementOperationTest extends ModelTestBase {
return userData;
}
-
+
+ /*
+ * private void deleteAndCreateCategory(String category) { CategoryData categoryData = new CategoryData(); categoryData.setName(category);
+ *
+ * titanDao.deleteNode(categoryData, CategoryData.class); Either<CategoryData, TitanOperationStatus> createNode = titanDao .createNode(categoryData, CategoryData.class); System.out.println("after creating caetgory " + createNode);
+ *
+ * }
+ */
+
@Test
+ @Ignore
public void testAddRequirementWithCapability() {
String capabilityTypeName = "tosca.nodes.Container";
@@ -195,11 +180,9 @@ public class RequirementOperationTest extends ModelTestBase {
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", "2.0", null,
- true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", "2.0", null, true, true);
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation
- .addRequirementToResource(reqName, reqDefinition, resource.getUniqueId());
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation.addRequirementToResource(reqName, reqDefinition, resource.getUniqueId());
assertEquals("check requirement was added", true, addRequirementToResource.isLeft());
@@ -207,9 +190,8 @@ public class RequirementOperationTest extends ModelTestBase {
String json = prettyGson.toJson(resource2);
log.debug(json);
}
-
- private void compareProperties(Map<String, PropertyDefinition> capabilityProperties,
- CapabiltyInstance capabiltyInstance, Map<String, String> actual) {
+
+ private void compareProperties(Map<String, PropertyDefinition> capabilityProperties, CapabiltyInstance capabiltyInstance, Map<String, String> actual) {
Map<String, String> properties = capabiltyInstance.getProperties();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceInstanceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceInstanceOperationTest.java
index bef51f415c..4f9488c239 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceInstanceOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceInstanceOperationTest.java
@@ -95,7 +95,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
private static Logger log = LoggerFactory.getLogger(ResourceInstanceOperationTest.class.getName());
private Gson prettyGson = new GsonBuilder().setPrettyPrinting().create();
- private static String USER_ID = "muserId";
+ private static String USER_ID = "muUserId";
private static String CATEGORY_NAME = "category/mycategory";
@javax.annotation.Resource(name = "titan-generic-dao")
@@ -172,10 +172,8 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ModelTestBase.init();
}
- public void setOperations(TitanGenericDao titanDao, CapabilityTypeOperation capabilityTypeOperation,
- RequirementOperation requirementOperation, CapabilityOperation capabilityOperation,
- ResourceOperation resourceOperation, PropertyOperation propertyOperation,
- ComponentInstanceOperation resourceInstanceOperation2) {
+ public void setOperations(TitanGenericDao titanDao, CapabilityTypeOperation capabilityTypeOperation, RequirementOperation requirementOperation, CapabilityOperation capabilityOperation, ResourceOperation resourceOperation,
+ PropertyOperation propertyOperation, ComponentInstanceOperation resourceInstanceOperation2) {
this.titanDao = titanDao;
this.capabilityTypeOperation = capabilityTypeOperation;
this.capabilityOperation = capabilityOperation;
@@ -198,12 +196,9 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
try {
ComponentInstance instance = buildResourceInstance("tosca.nodes.Apache.2.0", "1", "tosca.nodes.Apache");
- Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation
- .addComponentInstanceToContainerComponent("service1", NodeTypeEnum.Service, "1", true, instance,
- NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation.addComponentInstanceToContainerComponent("service1", NodeTypeEnum.Service, "1", true, instance, NodeTypeEnum.Resource, false);
assertEquals("check failed status - service is not in graph", true, status.isRight());
- assertEquals("check failed status value - service is not in graph", TitanOperationStatus.INVALID_ID,
- status.right().value());
+ assertEquals("check failed status value - service is not in graph", TitanOperationStatus.INVALID_ID, status.right().value());
} finally {
titanDao.rollback();
}
@@ -218,13 +213,10 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ComponentInstance instance = buildResourceInstance("tosca.nodes.Apache.2.0", "1", "tosca.nodes.Apache");
- Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation
- .addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service,
- "1", true, instance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation.addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service, "1", true, instance, NodeTypeEnum.Resource, false);
assertEquals("check failed status - service is not in graph", true, status.isRight());
- assertEquals("check failed status value - service is not in graph", TitanOperationStatus.INVALID_ID,
- status.right().value());
+ assertEquals("check failed status value - service is not in graph", TitanOperationStatus.INVALID_ID, status.right().value());
} finally {
titanDao.rollback();
@@ -240,12 +232,9 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ServiceMetadataData serviceData1 = createService(serviceName);
ResourceMetadataData resourceData = createResource(resourceName);
- ComponentInstance instance = buildResourceInstance(resourceData.getMetadataDataDefinition().getUniqueId(),
- "1", "tosca.nodes.Apache");
+ ComponentInstance instance = buildResourceInstance(resourceData.getMetadataDataDefinition().getUniqueId(), "1", "tosca.nodes.Apache");
- Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation
- .addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service,
- "1", true, instance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation.addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service, "1", true, instance, NodeTypeEnum.Resource, false);
assertEquals("check success status - service is not in graph", true, status.isLeft());
@@ -268,12 +257,9 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ServiceMetadataData serviceData1 = createService(serviceName);
ResourceMetadataData resourceData = createResource(resourceName);
- ComponentInstance instance = buildResourceInstance(resourceData.getMetadataDataDefinition().getUniqueId(),
- "1", "tosca.nodes.Apache");
+ ComponentInstance instance = buildResourceInstance(resourceData.getMetadataDataDefinition().getUniqueId(), "1", "tosca.nodes.Apache");
- Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation
- .addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service,
- "1", true, instance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation.addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service, "1", true, instance, NodeTypeEnum.Resource, false);
ComponentInstance resourceInstance = status.left().value();
Long creationTime = resourceInstance.getCreationTime();
@@ -283,9 +269,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ComponentInstance value = status.left().value();
assertEquals("check name exists", "tosca.nodes.Apache 1", value.getName());
- Either<ComponentInstance, StorageOperationStatus> u1Res = resourceInstanceOperation.updateResourceInstance(
- (String) serviceData1.getUniqueId(), NodeTypeEnum.Service, resourceInstance.getUniqueId(), value,
- true);
+ Either<ComponentInstance, StorageOperationStatus> u1Res = resourceInstanceOperation.updateResourceInstance((String) serviceData1.getUniqueId(), NodeTypeEnum.Service, resourceInstance.getUniqueId(), value, true);
assertTrue("check update succeed", u1Res.isLeft());
Long lastModificationTimeNC = value.getModificationTime();
@@ -295,29 +279,23 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
String updatedName = "Shlokshlik";
value.setDescription(desc);
value.setPosX(posX);
- Either<ComponentInstance, StorageOperationStatus> u2Res = resourceInstanceOperation.updateResourceInstance(
- (String) serviceData1.getUniqueId(), NodeTypeEnum.Service, resourceInstance.getUniqueId(), value,
- true);
+ Either<ComponentInstance, StorageOperationStatus> u2Res = resourceInstanceOperation.updateResourceInstance((String) serviceData1.getUniqueId(), NodeTypeEnum.Service, resourceInstance.getUniqueId(), value, true);
assertTrue("check update succeed", u2Res.isLeft());
assertEquals("check resource instance updated", desc, u2Res.left().value().getDescription());
assertEquals("check resource instance updated", posX, u2Res.left().value().getPosX());
assertEquals("check resource instance updated", resourceInstance.getPosY(), u2Res.left().value().getPosY());
- assertEquals("check modification time was not updated since it was supplied",
- u2Res.left().value().getModificationTime(), lastModificationTimeNC);
+ assertEquals("check modification time was not updated since it was supplied", u2Res.left().value().getModificationTime(), lastModificationTimeNC);
Long lastModificationTime = value.getModificationTime();
value.setPosY(posY);
value.setModificationTime(null);
value.setName(updatedName);
- Either<ComponentInstance, StorageOperationStatus> u3Res = resourceInstanceOperation.updateResourceInstance(
- (String) serviceData1.getUniqueId(), NodeTypeEnum.Service, resourceInstance.getUniqueId(), value,
- true);
+ Either<ComponentInstance, StorageOperationStatus> u3Res = resourceInstanceOperation.updateResourceInstance((String) serviceData1.getUniqueId(), NodeTypeEnum.Service, resourceInstance.getUniqueId(), value, true);
assertTrue("check update succeed", u3Res.isLeft());
assertEquals("check resource instance updated", desc, u3Res.left().value().getDescription());
assertEquals("check resource pos x updated", posX, u3Res.left().value().getPosX());
assertEquals("check resource pos y updated", posY, u3Res.left().value().getPosY());
- assertTrue("check modification time was updated",
- u3Res.left().value().getModificationTime() >= lastModificationTime);
+ assertTrue("check modification time was updated", u3Res.left().value().getModificationTime() >= lastModificationTime);
assertEquals("check creation time was not updated", creationTime, u3Res.left().value().getCreationTime());
assertEquals("check name was updated", updatedName, u3Res.left().value().getName());
@@ -337,20 +315,16 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ServiceMetadataData serviceData1 = createService(serviceName);
ResourceMetadataData resourceData = createResource(resourceName);
- ComponentInstance instance = buildResourceInstance(resourceData.getMetadataDataDefinition().getUniqueId(),
- "1", "tosca.nodes.Apache");
+ ComponentInstance instance = buildResourceInstance(resourceData.getMetadataDataDefinition().getUniqueId(), "1", "tosca.nodes.Apache");
- Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation
- .addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service,
- "1", true, instance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> status = resourceInstanceOperation.addComponentInstanceToContainerComponent((String) serviceData1.getUniqueId(), NodeTypeEnum.Service, "1", true, instance, NodeTypeEnum.Resource, false);
assertEquals("check success status - service is not in graph", true, status.isLeft());
ComponentInstance value = status.left().value();
assertEquals("check name exists", "tosca.nodes.Apache 1", value.getName());
- Either<ComponentInstance, TitanOperationStatus> status1 = resourceInstanceOperation
- .removeComponentInstanceFromComponent(NodeTypeEnum.Service, serviceName, value.getUniqueId());
+ Either<ComponentInstance, TitanOperationStatus> status1 = resourceInstanceOperation.removeComponentInstanceFromComponent(NodeTypeEnum.Service, serviceName, value.getUniqueId());
assertTrue("check resource service was deleted.", status1.isLeft());
assertEquals("check resource instance returned.", "tosca.nodes.Apache 1", status1.left().value().getName());
@@ -369,8 +343,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
String serviceName = "myservice1.1.0";
ServiceMetadataData serviceData1 = createService(serviceName);
- Either<ComponentInstance, TitanOperationStatus> status1 = resourceInstanceOperation
- .removeComponentInstanceFromComponent(NodeTypeEnum.Service, serviceName, "stam");
+ Either<ComponentInstance, TitanOperationStatus> status1 = resourceInstanceOperation.removeComponentInstanceFromComponent(NodeTypeEnum.Service, serviceName, "stam");
assertTrue("check resource service was not deleted.", status1.isRight());
assertEquals("check NOT_FOUND returned.", TitanOperationStatus.NOT_FOUND, status1.right().value());
@@ -386,8 +359,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ServiceMetadataData serviceData1 = new ServiceMetadataData();
serviceData1.getMetadataDataDefinition().setUniqueId(serviceName);
- Either<ServiceMetadataData, TitanOperationStatus> createNode = titanDao.createNode(serviceData1,
- ServiceMetadataData.class);
+ Either<ServiceMetadataData, TitanOperationStatus> createNode = titanDao.createNode(serviceData1, ServiceMetadataData.class);
assertTrue("check service created", createNode.isLeft());
return createNode.left().value();
@@ -397,8 +369,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ServiceMetadataData serviceData1 = new ServiceMetadataData();
serviceData1.getMetadataDataDefinition().setUniqueId(serviceName);
- Either<ServiceMetadataData, TitanOperationStatus> createNode = titanDao.deleteNode(serviceData1,
- ServiceMetadataData.class);
+ Either<ServiceMetadataData, TitanOperationStatus> createNode = titanDao.deleteNode(serviceData1, ServiceMetadataData.class);
assertTrue("check service deleted", createNode.isLeft());
return createNode.left().value();
}
@@ -407,8 +378,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ResourceMetadataData serviceData1 = new ResourceMetadataData();
serviceData1.getMetadataDataDefinition().setUniqueId(resourceName);
- Either<ResourceMetadataData, TitanOperationStatus> createNode = titanDao.createNode(serviceData1,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> createNode = titanDao.createNode(serviceData1, ResourceMetadataData.class);
assertTrue("check service created", createNode.isLeft());
return createNode.left().value();
@@ -418,8 +388,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ResourceMetadataData serviceData1 = new ResourceMetadataData();
serviceData1.getMetadataDataDefinition().setUniqueId(resourceName);
- Either<ResourceMetadataData, TitanOperationStatus> createNode = titanDao.deleteNode(serviceData1,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> createNode = titanDao.deleteNode(serviceData1, ResourceMetadataData.class);
assertTrue("check service created", createNode.isLeft());
return createNode.left().value();
@@ -478,6 +447,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void testConenctResourceInstancesJson() {
RequirementCapabilityRelDef addRelationship = addRelationship("apache_1", "compute_100");
String json = prettyGson.toJson(addRelationship);
@@ -530,13 +500,9 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
OperationTestsUtil.deleteAndCreateServiceCategory(category, titanDao);
/*
- * CategoryData categoryData = new CategoryData();
- * categoryData.setName(category);
+ * CategoryData categoryData = new CategoryData(); categoryData.setName(category);
*
- * titanDao.deleteNode(categoryData, CategoryData.class);
- * Either<CategoryData, TitanOperationStatus> createNode = titanDao
- * .createNode(categoryData, CategoryData.class);
- * System.out.println("after creating caetgory " + createNode);
+ * titanDao.deleteNode(categoryData, CategoryData.class); Either<CategoryData, TitanOperationStatus> createNode = titanDao .createNode(categoryData, CategoryData.class); System.out.println("after creating caetgory " + createNode);
*/
}
@@ -560,30 +526,25 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest
- .createCapability(capabilityTypeName);
+ CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest.createCapability(capabilityTypeName);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -591,55 +552,32 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
// rollbackAndPrint();
// Add capabilities to Compute Resource
CapabilityDefinition addCapability = addCapabilityToResource(capabilityTypeName, "host", computeComponent);
- // CapabilityDefinition capabilityDefinition = new
- // CapabilityDefinition();
- // capabilityDefinition.setDescription("my capability");
- // capabilityDefinition.setType(capabilityTypeName);
- // List<String> validSourceTypes = new ArrayList<String>();
- // validSourceTypes.add("tosca.nodes.SC");
- // capabilityDefinition.setValidSourceTypes(validSourceTypes);
- // Either<CapabilityDefinition, StorageOperationStatus>
- // addCapability = capabilityOperation
- // .addCapability(computeComponent.getUniqueId(), "host",
- // capabilityDefinition, true);
- // //logger.debug("addCapability result " + addCapability);
- // assertTrue("check capability created ", addCapability.isLeft());
- //
- // =============================================
-
// create requirement definition
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(
- capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
String parentReqUniqId = addRequirementToResource.left().value().getUniqueId();
// create my resource derived from software component
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource",
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", myResourceVersion, softwareComponent.getName(), true, true);
String serviceName = "myservice.1.0";
- List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource,
- computeComponent, "host", false, addCapability.getUniqueId(),
- addRequirementToResource.left().value().getUniqueId());
+ List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource, computeComponent, "host", false, addCapability.getUniqueId(), addRequirementToResource.left().value().getUniqueId());
PrintGraph printGraph = new PrintGraph();
String webGraph = printGraph.buildGraphForWebgraphWiz(titanDao.getGraph().left().value());
log.debug(webGraph);
- Either<Resource, StorageOperationStatus> resourceFull = resourceOperation
- .getResource(resource.getUniqueId());
+ Either<Resource, StorageOperationStatus> resourceFull = resourceOperation.getResource(resource.getUniqueId());
assertTrue(resourceFull.isLeft());
- List<RequirementCapabilityRelDef> componentInstancesRelations = resourceFull.left().value()
- .getComponentInstancesRelations();
+ List<RequirementCapabilityRelDef> componentInstancesRelations = resourceFull.left().value().getComponentInstancesRelations();
RequirementCapabilityRelDef capabilityRelDef = componentInstancesRelations.get(0);
capabilityRelDef.getRelationships().get(0).setRequirement("host");
@@ -678,34 +616,28 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef1 = capabilityTypeOperationTest
- .createCapability(capabilityTypeName1);
- CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest
- .createCapability(capabilityTypeName2);
+ CapabilityTypeDefinition createCapabilityDef1 = capabilityTypeOperationTest.createCapability(capabilityTypeName1);
+ CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest.createCapability(capabilityTypeName2);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -713,8 +645,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
// Add capabilities to Compute Resource
CapabilityDefinition capabilty1 = addCapabilityToResource(capabilityTypeName1, reqName1, computeComponent);
@@ -724,19 +655,16 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// create requirement definition
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(
- capabilityTypeName1, reqName1, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(capabilityTypeName1, reqName1, reqNodeName, reqRelationship, softwareComponent);
String requirementId = addRequirementToResource.left().value().getUniqueId();
String parentReqUniqId = requirementId;
// create my resource derived from software component
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource",
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", myResourceVersion, softwareComponent.getName(), true, true);
String serviceName = "myservice.1.0";
- List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource,
- computeComponent, reqName1, false, capabilty1.getUniqueId(), requirementId);
+ List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource, computeComponent, reqName1, false, capabilty1.getUniqueId(), requirementId);
PrintGraph printGraph = new PrintGraph();
String webGraph = printGraph.buildGraphForWebgraphWiz(titanDao.getGraph().left().value());
@@ -748,17 +676,13 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relationPair.setCapabilityUid(capabilty1.getUniqueId());
relationPair.setRequirementUid(requirementId);
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService1 = resourceInstanceOperation
- .connectResourcesInService(serviceName, NodeTypeEnum.Service, resInstances.get(0).getUniqueId(),
- resInstances.get(1).getUniqueId(), relationPair);
- assertEquals("check cannot associate resource instances", TitanOperationStatus.ILLEGAL_ARGUMENT,
- connectResourcesInService1.right().value());
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService1 = resourceInstanceOperation.connectResourcesInService(serviceName, NodeTypeEnum.Service, resInstances.get(0).getUniqueId(), resInstances.get(1).getUniqueId(),
+ relationPair);
+ assertEquals("check cannot associate resource instances", TitanOperationStatus.ILLEGAL_ARGUMENT, connectResourcesInService1.right().value());
relationPair.setRequirement(reqName1);
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService2 = resourceInstanceOperation
- .connectResourcesInService(serviceName, NodeTypeEnum.Service, resInstances.get(0).getUniqueId(),
- resInstances.get(1).getUniqueId(), relationPair);
- assertEquals("check cannot associate resource instances", TitanOperationStatus.TITAN_SCHEMA_VIOLATION,
- connectResourcesInService2.right().value());
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService2 = resourceInstanceOperation.connectResourcesInService(serviceName, NodeTypeEnum.Service, resInstances.get(0).getUniqueId(), resInstances.get(1).getUniqueId(),
+ relationPair);
+ assertEquals("check cannot associate resource instances", TitanOperationStatus.TITAN_SCHEMA_VIOLATION, connectResourcesInService2.right().value());
relationPair.setRequirement(reqName1);
@@ -791,6 +715,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void testConnectResourceInstances2Requirement2Capabilities() {
PrintGraph printGraph1 = new PrintGraph();
@@ -812,26 +737,21 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef1 = capabilityTypeOperationTest
- .createCapability(capabilityTypeName1);
- CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest
- .createCapability(capabilityTypeName2);
+ CapabilityTypeDefinition createCapabilityDef1 = capabilityTypeOperationTest.createCapability(capabilityTypeName1);
+ CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest.createCapability(capabilityTypeName2);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
@@ -840,8 +760,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// OKKKKKKK
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -849,8 +768,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
// rollbackAndPrint();
// OKKKKKKKKKK
@@ -863,22 +781,18 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// create requirement definition
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource1 = addRequirementToResource(
- capabilityTypeName1, reqName1, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource1 = addRequirementToResource(capabilityTypeName1, reqName1, reqNodeName, reqRelationship, softwareComponent);
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource2 = addRequirementToResource(
- capabilityTypeName2, reqName2, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource2 = addRequirementToResource(capabilityTypeName2, reqName2, reqNodeName, reqRelationship, softwareComponent);
// create my resource derived from software component
String MY_RESOURCE = "my-resource";
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, MY_RESOURCE,
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, MY_RESOURCE, myResourceVersion, softwareComponent.getName(), true, true);
String serviceName = "myservice.1.0";
String requirementId1 = addRequirementToResource1.left().value().getUniqueId();
String requirementId2 = addRequirementToResource2.left().value().getUniqueId();
- List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource,
- computeComponent, reqName1, false, capabilty1.getUniqueId(), requirementId1);
+ List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource, computeComponent, reqName1, false, capabilty1.getUniqueId(), requirementId1);
RequirementAndRelationshipPair relationPair = new RequirementAndRelationshipPair();
relationPair.setRequirement(reqName2);
@@ -886,9 +800,8 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relationPair.setRequirementUid(requirementId2);
relationPair.setCapabilityOwnerId(resInstances.get(1).getUniqueId());
relationPair.setRequirementOwnerId(resInstances.get(0).getUniqueId());
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService1 = resourceInstanceOperation
- .connectResourcesInService(serviceName, NodeTypeEnum.Service, resInstances.get(0).getUniqueId(),
- resInstances.get(1).getUniqueId(), relationPair);
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService1 = resourceInstanceOperation.connectResourcesInService(serviceName, NodeTypeEnum.Service, resInstances.get(0).getUniqueId(), resInstances.get(1).getUniqueId(),
+ relationPair);
assertTrue("check associate resource instances succeed " + reqName2, connectResourcesInService1.isLeft());
// rollbackAndPrint();
@@ -950,10 +863,8 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relationships.add(immutablePair2);
relation.setRelationships(relationships);
- Either<RequirementCapabilityRelDef, StorageOperationStatus> associateResourceInstances = resourceInstanceOperation
- .associateResourceInstances(serviceName, NodeTypeEnum.Service, relation, true);
- assertTrue("check return code after associating 2 requirements in one request",
- associateResourceInstances.isLeft());
+ Either<RequirementCapabilityRelDef, StorageOperationStatus> associateResourceInstances = resourceInstanceOperation.associateResourceInstances(serviceName, NodeTypeEnum.Service, relation, true, false);
+ assertTrue("check return code after associating 2 requirements in one request", associateResourceInstances.isLeft());
RequirementCapabilityRelDef capabilityRelDef = associateResourceInstances.left().value();
String fromNode = capabilityRelDef.getFromNode();
assertEquals("check from node", resInstances.get(0).getUniqueId(), fromNode);
@@ -979,25 +890,19 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
verifyGetAllResourceInstanceFromService(reqName1, reqName2, serviceName, fromResUid, toResUid);
List<ResourceMetadataData> resourcesPathList = new ArrayList<ResourceMetadataData>();
- TitanOperationStatus findResourcesPathRecursively = resourceOperation
- .findResourcesPathRecursively(resource.getUniqueId(), resourcesPathList);
+ TitanOperationStatus findResourcesPathRecursively = resourceOperation.findResourcesPathRecursively(resource.getUniqueId(), resourcesPathList);
assertEquals("check returned status", TitanOperationStatus.OK, findResourcesPathRecursively);
assertEquals("check list size", 3, resourcesPathList.size());
- TitanOperationStatus validateTheTargetResourceInstance = resourceInstanceOperation
- .validateTheTargetResourceInstance(MY_RESOURCE, resource.getUniqueId());
+ TitanOperationStatus validateTheTargetResourceInstance = resourceInstanceOperation.validateTheTargetResourceInstance(MY_RESOURCE, resource.getUniqueId());
assertEquals("check resource name in the path", TitanOperationStatus.OK, validateTheTargetResourceInstance);
- validateTheTargetResourceInstance = resourceInstanceOperation
- .validateTheTargetResourceInstance(softwareCompName, resource.getUniqueId());
+ validateTheTargetResourceInstance = resourceInstanceOperation.validateTheTargetResourceInstance(softwareCompName, resource.getUniqueId());
assertEquals("check resource name in the path", TitanOperationStatus.OK, validateTheTargetResourceInstance);
- validateTheTargetResourceInstance = resourceInstanceOperation
- .validateTheTargetResourceInstance(softwareCompName + "STAM", resource.getUniqueId());
- assertEquals("check resource name not in the path", TitanOperationStatus.MATCH_NOT_FOUND,
- validateTheTargetResourceInstance);
+ validateTheTargetResourceInstance = resourceInstanceOperation.validateTheTargetResourceInstance(softwareCompName + "STAM", resource.getUniqueId());
+ assertEquals("check resource name not in the path", TitanOperationStatus.MATCH_NOT_FOUND, validateTheTargetResourceInstance);
- Either<ComponentInstance, StorageOperationStatus> deleteResourceInstance = resourceInstanceOperation
- .deleteComponentInstance(NodeTypeEnum.Service, serviceName, toResUid, true);
+ Either<ComponentInstance, StorageOperationStatus> deleteResourceInstance = resourceInstanceOperation.deleteComponentInstance(NodeTypeEnum.Service, serviceName, toResUid, true);
assertTrue("check resource instance was deleted.", deleteResourceInstance.isLeft());
} finally {
@@ -1007,15 +912,13 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
- private void verifyGetAllResourceInstanceFromService(String reqName1, String reqName2, String serviceName,
- String fromResUid, String toResUid) {
+ private void verifyGetAllResourceInstanceFromService(String reqName1, String reqName2, String serviceName, String fromResUid, String toResUid) {
- Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, StorageOperationStatus> allResourceInstances = resourceInstanceOperation
- .getAllComponentInstances(serviceName, NodeTypeEnum.Service, NodeTypeEnum.Resource, true);
+ Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, StorageOperationStatus> allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceName, NodeTypeEnum.Service, NodeTypeEnum.Resource,
+ true);
// assertTrue("check return code after get all resource instances",
// associateResourceInstances.isLeft());
- ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>> immutablePair = allResourceInstances
- .left().value();
+ ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>> immutablePair = allResourceInstances.left().value();
List<ComponentInstance> nodes = immutablePair.getKey();
List<RequirementCapabilityRelDef> edges = immutablePair.getValue();
assertEquals("check 2 nodes returned", 2, nodes.size());
@@ -1043,34 +946,31 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
log.debug(edgesStr);
}
- private Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource(String capabilityTypeName1,
- String reqName1, String reqNodeName, String reqRelationship, Resource softwareComponent) {
+ private Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource(String capabilityTypeName1, String reqName1, String reqNodeName, String reqRelationship, Resource softwareComponent) {
RequirementDefinition reqDefinition1 = new RequirementDefinition();
reqDefinition1.setNode(reqNodeName);
reqDefinition1.setRelationship(reqRelationship);
reqDefinition1.setCapability(capabilityTypeName1);
// add requirement to software component
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation
- .addRequirementToResource(reqName1, reqDefinition1, softwareComponent.getUniqueId(), true);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation.addRequirementToResource(reqName1, reqDefinition1, softwareComponent.getUniqueId(), true);
assertEquals("check requirement was added", true, addRequirementToResource.isLeft());
return addRequirementToResource;
}
- private CapabilityDefinition addCapabilityToResource(String capabilityTypeName1, String reqName1,
- Resource computeComponent) {
+ private CapabilityDefinition addCapabilityToResource(String capabilityTypeName1, String reqName1, Resource computeComponent) {
CapabilityDefinition capabilityDefinition1 = new CapabilityDefinition();
capabilityDefinition1.setDescription("my capability");
capabilityDefinition1.setType(capabilityTypeName1);
List<String> validSourceTypes = new ArrayList<String>();
validSourceTypes.add("tosca.nodes.SC");
capabilityDefinition1.setValidSourceTypes(validSourceTypes);
- Either<CapabilityDefinition, StorageOperationStatus> addCapability = capabilityOperation
- .addCapability(computeComponent.getUniqueId(), reqName1, capabilityDefinition1, true);
+ Either<CapabilityDefinition, StorageOperationStatus> addCapability = capabilityOperation.addCapability(computeComponent.getUniqueId(), reqName1, capabilityDefinition1, true);
assertTrue("check capability created ", addCapability.isLeft());
return addCapability.left().value();
}
@Test
+ @Ignore
public void testConnectResourceInstancesCapabilityNameDiffFromReqName() {
PrintGraph printGraph1 = new PrintGraph();
@@ -1092,31 +992,26 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest
- .createCapability(capabilityTypeName);
+ CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest.createCapability(capabilityTypeName);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -1124,31 +1019,24 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
- CapabilityDefinition capabilty = addCapabilityToResource(capabilityTypeName, DIFFERENT_CAPABILITY,
- computeComponent);
+ CapabilityDefinition capabilty = addCapabilityToResource(capabilityTypeName, DIFFERENT_CAPABILITY, computeComponent);
// create requirement definition
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(
- capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
String parentReqUniqId = addRequirementToResource.left().value().getUniqueId();
// create my resource derived from software component
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource",
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", myResourceVersion, softwareComponent.getName(), true, true);
String serviceName = "myservice.1.0";
- List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource,
- computeComponent, "host", false, capabilty.getUniqueId(), parentReqUniqId);
+ List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstances(serviceName, resource, computeComponent, "host", false, capabilty.getUniqueId(), parentReqUniqId);
PrintGraph printGraph = new PrintGraph();
- String webGraph = printGraph.buildGraphForWebgraphWiz(titanDao.getGraph().left().value());
- // log.debug(webGraph);
-
+ String webGraph = printGraph.buildGraphForWebgraphWiz(titanDao.getGraph().left().value());
} finally {
rollbackAndPrint();
@@ -1158,6 +1046,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void testConnectResourceInstancesInvalidCapability() {
PrintGraph printGraph1 = new PrintGraph();
@@ -1181,34 +1070,28 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest
- .createCapability(capabilityTypeName);
+ CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest.createCapability(capabilityTypeName);
- CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest
- .createCapability(capabilityTypeNameOther);
+ CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest.createCapability(capabilityTypeNameOther);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -1216,25 +1099,21 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
addCapabilityToResource(capabilityTypeName, DIFFERENT_CAPABILITY, computeComponent);
// create requirement definition
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(
- capabilityTypeNameOther, reqName, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(capabilityTypeNameOther, reqName, reqNodeName, reqRelationship, softwareComponent);
String parentReqUniqId = addRequirementToResource.left().value().getUniqueId();
// create my resource derived from software component
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource",
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", myResourceVersion, softwareComponent.getName(), true, true);
String serviceName = "myservice.1.0";
- List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstancesWithError(serviceName,
- resource, computeComponent, "host", false, TitanOperationStatus.ILLEGAL_ARGUMENT);
+ List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstancesWithError(serviceName, resource, computeComponent, "host", false, TitanOperationStatus.ILLEGAL_ARGUMENT);
PrintGraph printGraph = new PrintGraph();
String webGraph = printGraph.buildGraphForWebgraphWiz(titanDao.getGraph().left().value());
@@ -1264,12 +1143,11 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
PrintGraph printGraph2 = new PrintGraph();
int numberOfVerticesCurr = printGraph2.getNumberOfVertices(titanDao.getGraph().left().value());
- assertEquals(
- "check all data deleted from graph " + printGraph2.getVerticesSet(titanDao.getGraph().left().value()),
- numberOfVertices, numberOfVerticesCurr);
+ assertEquals("check all data deleted from graph " + printGraph2.getVerticesSet(titanDao.getGraph().left().value()), numberOfVertices, numberOfVerticesCurr);
}
@Test
+ @Ignore
public void testConnectResourceInstancesRequirementNotFound() {
PrintGraph printGraph1 = new PrintGraph();
@@ -1290,31 +1168,26 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest
- .createCapability(capabilityTypeName);
+ CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest.createCapability(capabilityTypeName);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -1322,8 +1195,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
addCapabilityToResource(capabilityTypeName, reqName, computeComponent);
@@ -1334,20 +1206,16 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
reqDefinition.setRelationship(reqRelationship);
reqDefinition.setCapability(capabilityTypeName);
// add requirement to software component
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation
- .addRequirementToResource(reqName + "ssssssss", reqDefinition, softwareComponent.getUniqueId(),
- true);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = requirementOperation.addRequirementToResource(reqName + "ssssssss", reqDefinition, softwareComponent.getUniqueId(), true);
assertEquals("check requirement was added", true, addRequirementToResource.isLeft());
String parentReqUniqId = addRequirementToResource.left().value().getUniqueId();
// create my resource derived from software component
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource",
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", myResourceVersion, softwareComponent.getName(), true, true);
String serviceName = "myservice.1.0";
- List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstancesWithError(serviceName,
- resource, computeComponent, "host", false, TitanOperationStatus.ILLEGAL_ARGUMENT);
+ List<ComponentInstance> resInstances = buildServiceAndConnectBetweenResourceInstancesWithError(serviceName, resource, computeComponent, "host", false, TitanOperationStatus.ILLEGAL_ARGUMENT);
PrintGraph printGraph = new PrintGraph();
String webGraph = printGraph.buildGraphForWebgraphWiz(titanDao.getGraph().left().value());
@@ -1363,19 +1231,15 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
private void disconnectResourcesInService(String serviceName, RequirementCapabilityRelDef reqCapDef) {
- Either<List<RelationshipInstData>, TitanOperationStatus> disconnectResourcesInService = resourceInstanceOperation
- .disconnectResourcesInService(serviceName, NodeTypeEnum.Service, reqCapDef);
+ Either<List<RelationshipInstData>, TitanOperationStatus> disconnectResourcesInService = resourceInstanceOperation.disconnectResourcesInService(serviceName, NodeTypeEnum.Service, reqCapDef);
assertTrue("check relatioship instance was deleted", disconnectResourcesInService.isLeft());
- disconnectResourcesInService = resourceInstanceOperation.disconnectResourcesInService(serviceName,
- NodeTypeEnum.Service, reqCapDef);
+ disconnectResourcesInService = resourceInstanceOperation.disconnectResourcesInService(serviceName, NodeTypeEnum.Service, reqCapDef);
assertTrue("check relatioship instance already was deleted", disconnectResourcesInService.isRight());
- assertEquals("check relatioship instance already was deleted. status NOT_FOUND", TitanOperationStatus.NOT_FOUND,
- disconnectResourcesInService.right().value());
+ assertEquals("check relatioship instance already was deleted. status NOT_FOUND", TitanOperationStatus.NOT_FOUND, disconnectResourcesInService.right().value());
}
- private List<ComponentInstance> buildServiceAndConnectBetweenResourceInstancesWithError(String serviceName,
- Resource resource, Resource computeComponent, String requirement, boolean ignoreCreatingService,
+ private List<ComponentInstance> buildServiceAndConnectBetweenResourceInstancesWithError(String serviceName, Resource resource, Resource computeComponent, String requirement, boolean ignoreCreatingService,
TitanOperationStatus titanOperationStatus) {
String serviceId = "myservice.1.0";
@@ -1385,30 +1249,22 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
ComponentInstance myresourceInstance = buildResourceInstance(resource.getUniqueId(), "1", resource.getName());
- ComponentInstance computeInstance = buildResourceInstance(computeComponent.getUniqueId(), "2",
- computeComponent.getName());
+ ComponentInstance computeInstance = buildResourceInstance(computeComponent.getUniqueId(), "2", computeComponent.getName());
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", myinstanceRes.isLeft());
ComponentInstance value1 = myinstanceRes.left().value();
- Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance,
- NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", computeInstTes.isLeft());
ComponentInstance value2 = computeInstTes.left().value();
RequirementAndRelationshipPair relationPair = new RequirementAndRelationshipPair();
relationPair.setRequirement(requirement);
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation
- .connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(), value2.getUniqueId(),
- relationPair);
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation.connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(), value2.getUniqueId(), relationPair);
assertTrue("check relation was not created", connectResourcesInService.isRight());
- assertEquals("check error code after connect resource instances failed", titanOperationStatus,
- connectResourcesInService.right().value());
+ assertEquals("check error code after connect resource instances failed", titanOperationStatus, connectResourcesInService.right().value());
List<ComponentInstance> resInstances = new ArrayList<ComponentInstance>();
resInstances.add(value1);
@@ -1417,9 +1273,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
- private List<ComponentInstance> buildServiceAndConnectBetweenResourceInstances(String serviceName,
- Resource resource, Resource computeComponent, String requirement, boolean ignoreCreatingService,
- String capabilityId, String requirementId) {
+ private List<ComponentInstance> buildServiceAndConnectBetweenResourceInstances(String serviceName, Resource resource, Resource computeComponent, String requirement, boolean ignoreCreatingService, String capabilityId, String requirementId) {
String serviceId = "myservice.1.0";
@@ -1428,17 +1282,12 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
ComponentInstance myresourceInstance = buildResourceInstance(resource.getUniqueId(), "1", resource.getName());
- ComponentInstance computeInstance = buildResourceInstance(computeComponent.getUniqueId(), "2",
- computeComponent.getName());
+ ComponentInstance computeInstance = buildResourceInstance(computeComponent.getUniqueId(), "2", computeComponent.getName());
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", myinstanceRes.isLeft());
ComponentInstance value1 = myinstanceRes.left().value();
- Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance,
- NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", computeInstTes.isLeft());
ComponentInstance value2 = computeInstTes.left().value();
RequirementAndRelationshipPair relationPair = new RequirementAndRelationshipPair();
@@ -1449,9 +1298,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relationPair.setRequirementOwnerId(value1.getUniqueId());
relationPair.setCapabilityOwnerId(value2.getUniqueId());
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation
- .connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(), value2.getUniqueId(),
- relationPair);
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation.connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(), value2.getUniqueId(), relationPair);
assertTrue("check relation created", connectResourcesInService.isLeft());
@@ -1464,6 +1311,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void getAllResourceInstancesThree() {
PrintGraph printGraph1 = new PrintGraph();
@@ -1484,31 +1332,26 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest
- .createCapability(capabilityTypeName);
+ CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest.createCapability(capabilityTypeName);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -1516,8 +1359,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
// rollbackAndPrint();
@@ -1526,56 +1368,45 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// create requirement definition
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(
- capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
String parentReqUniqId = addRequirementToResource.left().value().getUniqueId();
// create my resource derived from software component
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource",
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", myResourceVersion, softwareComponent.getName(), true, true);
String serviceId = "myservice.1.0";
ServiceMetadataData createService = createService(serviceId);
- Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, StorageOperationStatus> allResourceInstances = resourceInstanceOperation
- .getAllComponentInstances(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource, true);
+ Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, StorageOperationStatus> allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource,
+ true);
assertTrue("check NOT_FOUND is returned", allResourceInstances.isRight());
- assertEquals("check NOT_FOUND is returned", allResourceInstances.right().value(),
- StorageOperationStatus.NOT_FOUND);
+ assertEquals("check NOT_FOUND is returned", allResourceInstances.right().value(), StorageOperationStatus.NOT_FOUND);
ComponentInstance myresourceInstance = buildResourceInstance(resource.getUniqueId(), "1", "my-resource");
myresourceInstance.setName("my-resource");
- ComponentInstance computeInstance1 = buildResourceInstance(computeComponent.getUniqueId(), "2",
- "tosca.nodes.Compute2");
+ ComponentInstance computeInstance1 = buildResourceInstance(computeComponent.getUniqueId(), "2", "tosca.nodes.Compute2");
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", myinstanceRes.isLeft());
ComponentInstance value1 = myinstanceRes.left().value();
- allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service,
- NodeTypeEnum.Resource, true);
+ allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource, true);
assertTrue("check resource instances found", allResourceInstances.isLeft());
- ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>> immutablePair = allResourceInstances
- .left().value();
+ ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>> immutablePair = allResourceInstances.left().value();
List<ComponentInstance> nodes = immutablePair.getKey();
List<RequirementCapabilityRelDef> edges = immutablePair.getValue();
assertEquals("check resource instances size", 1, nodes.size());
assertEquals("check resource instances size", 0, edges.size());
- Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true,
- computeInstance1, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance1, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", computeInstTes.isLeft());
ComponentInstance value2 = computeInstTes.left().value();
- allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service,
- NodeTypeEnum.Resource, true);
+ allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource, true);
assertTrue("check resource instances found", allResourceInstances.isLeft());
immutablePair = allResourceInstances.left().value();
nodes = immutablePair.getKey();
@@ -1592,14 +1423,11 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relationPair.setRequirementOwnerId(value1.getUniqueId());
relationPair.setCapabilityOwnerId(value2.getUniqueId());
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation
- .connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(),
- value2.getUniqueId(), relationPair);
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation.connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(), value2.getUniqueId(), relationPair);
assertTrue("check relation created", connectResourcesInService.isLeft());
- allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service,
- NodeTypeEnum.Resource, true);
+ allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource, true);
assertTrue("check resource instances found", allResourceInstances.isLeft());
immutablePair = allResourceInstances.left().value();
nodes = immutablePair.getKey();
@@ -1614,22 +1442,18 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ComponentInstance myresourceInstance2 = buildResourceInstance(resource.getUniqueId(), "1", "myresource2");
- Either<ComponentInstance, TitanOperationStatus> newResource = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "3", true,
- myresourceInstance2, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> newResource = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "3", true, myresourceInstance2, NodeTypeEnum.Resource, false);
assertTrue("added resource instance successfully", newResource.isLeft());
relationPair.setRequirement(requirement);
relationPair.setRequirementOwnerId(newResource.left().value().getUniqueId());
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService2 = resourceInstanceOperation
- .connectResourcesInService(serviceId, NodeTypeEnum.Service,
- newResource.left().value().getUniqueId(), value2.getUniqueId(), relationPair);
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService2 = resourceInstanceOperation.connectResourcesInService(serviceId, NodeTypeEnum.Service, newResource.left().value().getUniqueId(), value2.getUniqueId(),
+ relationPair);
assertTrue("check resource instance was added to service", connectResourcesInService2.isLeft());
- allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service,
- NodeTypeEnum.Resource, true);
+ allResourceInstances = resourceInstanceOperation.getAllComponentInstances(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource, true);
assertTrue("check resource instances found", allResourceInstances.isLeft());
immutablePair = allResourceInstances.left().value();
nodes = immutablePair.getKey();
@@ -1638,32 +1462,24 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertEquals("check resource instances size", 3, nodes.size());
assertEquals("check resource instances size", 2, edges.size());
- Either<List<ComponentInstance>, TitanOperationStatus> deleteAllResourceInstancesOfService = resourceInstanceOperation
- .deleteAllComponentInstancesInternal(serviceId, NodeTypeEnum.Service);
+ Either<List<ComponentInstance>, TitanOperationStatus> deleteAllResourceInstancesOfService = resourceInstanceOperation.deleteAllComponentInstancesInternal(serviceId, NodeTypeEnum.Service);
assertTrue("check resource instances was deleted.", deleteAllResourceInstancesOfService.isLeft());
- assertEquals("check number of deleted resource instances.", 3,
- deleteAllResourceInstancesOfService.left().value().size());
+ assertEquals("check number of deleted resource instances.", 3, deleteAllResourceInstancesOfService.left().value().size());
- Either<List<RelationshipInstData>, TitanOperationStatus> allRelatinshipInst = titanDao
- .getAll(NodeTypeEnum.RelationshipInst, RelationshipInstData.class);
+ Either<List<RelationshipInstData>, TitanOperationStatus> allRelatinshipInst = titanDao.getAll(NodeTypeEnum.RelationshipInst, RelationshipInstData.class);
assertTrue("allRelatinshipInst is empty", allRelatinshipInst.isRight());
- assertEquals("allRelatinshipInst result is NOT_FOUND", TitanOperationStatus.NOT_FOUND,
- allRelatinshipInst.right().value());
+ assertEquals("allRelatinshipInst result is NOT_FOUND", TitanOperationStatus.NOT_FOUND, allRelatinshipInst.right().value());
- Either<Resource, StorageOperationStatus> deleteComputeResource = resourceOperation
- .deleteResource(computeComponent.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> deleteComputeResource = resourceOperation.deleteResource(computeComponent.getUniqueId(), true);
assertTrue("delete compute resource succeed", deleteComputeResource.isLeft());
- Either<Resource, StorageOperationStatus> deleteSCResource = resourceOperation
- .deleteResource(softwareComponent.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> deleteSCResource = resourceOperation.deleteResource(softwareComponent.getUniqueId(), true);
assertTrue("delete software component resource succeed", deleteSCResource.isLeft());
- Either<Resource, StorageOperationStatus> deleteMyResource = resourceOperation
- .deleteResource(resource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> deleteMyResource = resourceOperation.deleteResource(resource.getUniqueId(), true);
assertTrue("delete my resource succeed", deleteMyResource.isLeft());
- Either<Resource, StorageOperationStatus> rootResourceDeleted = resourceOperation
- .deleteResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> rootResourceDeleted = resourceOperation.deleteResource(rootResource.getUniqueId(), true);
assertTrue("delete root resource succeed", rootResourceDeleted.isLeft());
Set<String> vertexSetAfterDelete = printGraph1.getVerticesSet(titanDao.getGraph().left().value());
@@ -1699,8 +1515,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
resourceData1.getMetadataDataDefinition().setState(state);
resourceData1.getMetadataDataDefinition().setHighestVersion(true);
resourceData1.getMetadataDataDefinition().setContactId("contactId");
- Either<ResourceMetadataData, TitanOperationStatus> createNode1 = titanDao.createNode(resourceData1,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> createNode1 = titanDao.createNode(resourceData1, ResourceMetadataData.class);
log.debug("{}", createNode1);
@@ -1721,17 +1536,25 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
resourceData1.getMetadataDataDefinition().setState(state);
resourceData1.getMetadataDataDefinition().setHighestVersion(true);
resourceData1.getMetadataDataDefinition().setContactId("contactId");
- Either<ResourceMetadataData, TitanOperationStatus> createNode1 = titanDao.createNode(resourceData1,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> createNode1 = titanDao.createNode(resourceData1, ResourceMetadataData.class);
log.debug("{}", createNode1);
titanDao.commit();
+ // resourceData1.setUniqueId(name + "." + "2.0");
+ // resourceData1.setHighestVersion(true);
+ // resourceData1.setContactId("contactId");
+ //
+ // Either<ResourceData, TitanOperationStatus> createNode2 = titanDao
+ // .createNode(resourceData1, ResourceData.class);
+ // System.out.println(createNode2);
+ //
+ // titanDao.commit();
+
// resourceData1.setHighestVersion(false);
resourceData1.getMetadataDataDefinition().setContactId("222contactId222");
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData1,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData1, ResourceMetadataData.class);
titanDao.commit();
@@ -1765,8 +1588,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
propertiesToMatch.put(GraphPropertiesDictionary.CONTACT_ID.getProperty(), "contactId");
// propertiesToMatch.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(),
// true);
- Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao
- .getByCriteria(NodeTypeEnum.Resource, propertiesToMatch, ResourceMetadataData.class);
+ Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, propertiesToMatch, ResourceMetadataData.class);
return byCriteria;
}
@@ -1790,53 +1612,40 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- ComponentInstance myresourceInstance = buildResourceInstance(softwareComponent.getUniqueId(), "1",
- softwareCompName);
+ ComponentInstance myresourceInstance = buildResourceInstance(softwareComponent.getUniqueId(), "1", softwareCompName);
String serviceName = "myservice.1.0";
ServiceMetadataData createService = createService(serviceName);
- Either<ComponentInstance, StorageOperationStatus> myinstanceRes1 = resourceInstanceOperation
- .createComponentInstance(serviceName, NodeTypeEnum.Service, "1", myresourceInstance,
- NodeTypeEnum.Resource, true);
+ Either<ComponentInstance, StorageOperationStatus> myinstanceRes1 = resourceInstanceOperation.createComponentInstance(serviceName, NodeTypeEnum.Service, "1", myresourceInstance, NodeTypeEnum.Resource, true);
assertTrue("check resource instance was created", myinstanceRes1.isLeft());
- Either<ComponentInstance, StorageOperationStatus> myinstanceRes2 = resourceInstanceOperation
- .createComponentInstance(serviceName, NodeTypeEnum.Service, "1", myresourceInstance,
- NodeTypeEnum.Resource, true);
+ Either<ComponentInstance, StorageOperationStatus> myinstanceRes2 = resourceInstanceOperation.createComponentInstance(serviceName, NodeTypeEnum.Service, "1", myresourceInstance, NodeTypeEnum.Resource, true);
assertTrue("check resource instance was not created", myinstanceRes2.isRight());
assertEquals("check error code", StorageOperationStatus.SCHEMA_VIOLATION, myinstanceRes2.right().value());
- Either<ComponentInstance, StorageOperationStatus> deleteResourceInstance = resourceInstanceOperation
- .deleteComponentInstance(NodeTypeEnum.Service, serviceName,
- myinstanceRes1.left().value().getUniqueId(), true);
+ Either<ComponentInstance, StorageOperationStatus> deleteResourceInstance = resourceInstanceOperation.deleteComponentInstance(NodeTypeEnum.Service, serviceName, myinstanceRes1.left().value().getUniqueId(), true);
assertTrue("check resource instance was deleted", deleteResourceInstance.isLeft());
- deleteResourceInstance = resourceInstanceOperation.deleteComponentInstance(NodeTypeEnum.Service,
- serviceName, myinstanceRes1.left().value().getUniqueId(), true);
+ deleteResourceInstance = resourceInstanceOperation.deleteComponentInstance(NodeTypeEnum.Service, serviceName, myinstanceRes1.left().value().getUniqueId(), true);
assertTrue("check resource instance was not deleted", deleteResourceInstance.isRight());
- assertEquals("check resource instance was not deleted", StorageOperationStatus.NOT_FOUND,
- deleteResourceInstance.right().value());
+ assertEquals("check resource instance was not deleted", StorageOperationStatus.NOT_FOUND, deleteResourceInstance.right().value());
} finally {
rollbackAndPrint(false);
@@ -1846,6 +1655,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void testConnectResourceInstancesTwice() {
PrintGraph printGraph1 = new PrintGraph();
@@ -1867,34 +1677,28 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// Create Capability type
CapabilityTypeOperationTest capabilityTypeOperationTest = new CapabilityTypeOperationTest();
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
- CapabilityTypeDefinition createCapabilityDef1 = capabilityTypeOperationTest
- .createCapability(capabilityTypeName1);
- CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest
- .createCapability(capabilityTypeName2);
+ CapabilityTypeDefinition createCapabilityDef1 = capabilityTypeOperationTest.createCapability(capabilityTypeName1);
+ CapabilityTypeDefinition createCapabilityDef2 = capabilityTypeOperationTest.createCapability(capabilityTypeName2);
ResourceOperationTest resourceOperationTest = new ResourceOperationTest();
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
// create root resource
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null,
- true, true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
// create software component
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
@@ -1902,8 +1706,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue(updateNode.isLeft());
// create compute component
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName,
- "1.0", rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
// Add capabilities to Compute Resource
CapabilityDefinition capabilty1 = addCapabilityToResource(capabilityTypeName1, reqName1, computeComponent);
@@ -1913,31 +1716,24 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// create requirement definition
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(
- capabilityTypeName1, reqName1, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(capabilityTypeName1, reqName1, reqNodeName, reqRelationship, softwareComponent);
String parentReqUniqId = addRequirementToResource.left().value().getUniqueId();
// create my resource derived from software component
- Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource",
- myResourceVersion, softwareComponent.getName(), true, true);
+ Resource resource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, "my-resource", myResourceVersion, softwareComponent.getName(), true, true);
String serviceId = "myservice.1.0";
ServiceMetadataData createService = createService(serviceId);
ComponentInstance myresourceInstance = buildResourceInstance(resource.getUniqueId(), "1", "my-resource");
- ComponentInstance computeInstance = buildResourceInstance(computeComponent.getUniqueId(), "2",
- computeNodeName);
+ ComponentInstance computeInstance = buildResourceInstance(computeComponent.getUniqueId(), "2", computeNodeName);
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", myinstanceRes.isLeft());
ComponentInstance value1 = myinstanceRes.left().value();
- Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true,
- computeInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", computeInstTes.isLeft());
ComponentInstance value2 = computeInstTes.left().value();
@@ -1956,8 +1752,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relation.setRelationships(relationships);
- Either<RequirementCapabilityRelDef, StorageOperationStatus> connectResourcesInService = resourceInstanceOperation
- .associateResourceInstances(serviceId, NodeTypeEnum.Service, relation, true);
+ Either<RequirementCapabilityRelDef, StorageOperationStatus> connectResourcesInService = resourceInstanceOperation.associateResourceInstances(serviceId, NodeTypeEnum.Service, relation, true, false);
assertTrue("check association succeed", connectResourcesInService.isLeft());
relationships.clear();
@@ -1967,23 +1762,18 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relationships.add(immutablePair2);
RequirementCapabilityRelDef firstRelation = connectResourcesInService.left().value();
- connectResourcesInService = resourceInstanceOperation.associateResourceInstances(serviceId,
- NodeTypeEnum.Service, relation, true);
+ connectResourcesInService = resourceInstanceOperation.associateResourceInstances(serviceId, NodeTypeEnum.Service, relation, true, false);
assertTrue("check association succeed", connectResourcesInService.isRight());
- assertEquals("check association failed", StorageOperationStatus.MATCH_NOT_FOUND,
- connectResourcesInService.right().value());
+ assertEquals("check association failed", StorageOperationStatus.MATCH_NOT_FOUND, connectResourcesInService.right().value());
- Either<RequirementCapabilityRelDef, StorageOperationStatus> disconnectResourcesInService = resourceInstanceOperation
- .dissociateResourceInstances(serviceId, NodeTypeEnum.Service, firstRelation, true);
+ Either<RequirementCapabilityRelDef, StorageOperationStatus> disconnectResourcesInService = resourceInstanceOperation.dissociateResourceInstances(serviceId, NodeTypeEnum.Service, firstRelation, true);
assertTrue("check dissociation succeed", disconnectResourcesInService.isLeft());
- disconnectResourcesInService = resourceInstanceOperation.dissociateResourceInstances(serviceId,
- NodeTypeEnum.Service, relation, true);
+ disconnectResourcesInService = resourceInstanceOperation.dissociateResourceInstances(serviceId, NodeTypeEnum.Service, relation, true);
assertTrue("check dissociation failed", disconnectResourcesInService.isRight());
- assertEquals("check association failed", StorageOperationStatus.NOT_FOUND,
- disconnectResourcesInService.right().value());
+ assertEquals("check association failed", StorageOperationStatus.NOT_FOUND, disconnectResourcesInService.right().value());
} finally {
rollbackAndPrint();
compareGraphSize(numberOfVertices);
@@ -1991,16 +1781,14 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
- private Resource createComputeWithCapability(String capabilityTypeName, String computeNodeName,
- ResourceOperationTest resourceOperationTest, Resource rootResource) {
+ private Resource createComputeWithCapability(String capabilityTypeName, String computeNodeName, ResourceOperationTest resourceOperationTest, Resource rootResource) {
// create compute component
// String id = UniqueIdBuilder.buildResourceUniqueId(computeNodeName,
// "1.0");
// if (resourceOperation.getResource(id).isLeft()){
// resourceOperation.deleteResource(id);
// }
- Either<List<Resource>, StorageOperationStatus> oldResource = resourceOperation
- .getResourceByNameAndVersion(computeNodeName, "1.0", false);
+ Either<List<Resource>, StorageOperationStatus> oldResource = resourceOperation.getResourceByNameAndVersion(computeNodeName, "1.0", false);
if (oldResource.isLeft()) {
for (Resource old : oldResource.left().value()) {
if (old.getResourceType().equals(ResourceTypeEnum.VFC)) {
@@ -2010,8 +1798,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
- Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0",
- rootResource.getName(), true, true);
+ Resource computeComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, computeNodeName, "1.0", rootResource.getName(), true, true);
// rollbackAndPrint();
@@ -2020,9 +1807,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
return resourceOperation.getResource(computeComponent.getUniqueId()).left().value();
}
- private Resource createSoftwareComponentWithReq(String softwareCompName,
- ResourceOperationTest resourceOperationTest, Resource rootResource, String capabilityTypeName,
- String reqName, String reqRelationship, String reqNodeName) {
+ private Resource createSoftwareComponentWithReq(String softwareCompName, ResourceOperationTest resourceOperationTest, Resource rootResource, String capabilityTypeName, String reqName, String reqRelationship, String reqNodeName) {
Either<ResourceMetadataData, TitanOperationStatus> updateNode;
ResourceMetadataData resourceData = new ResourceMetadataData();
// create software component
@@ -2031,8 +1816,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// if (resourceOperation.getResource(id).isLeft()){
// resourceOperation.deleteResource(id);
// }
- Either<List<Resource>, StorageOperationStatus> oldResource = resourceOperation
- .getResourceByNameAndVersion(softwareCompName, "1.0", false);
+ Either<List<Resource>, StorageOperationStatus> oldResource = resourceOperation.getResourceByNameAndVersion(softwareCompName, "1.0", false);
if (oldResource.isLeft()) {
if (oldResource.isLeft()) {
for (Resource old : oldResource.left().value()) {
@@ -2044,16 +1828,14 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
}
- Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName,
- "1.0", rootResource.getName(), true, true);
+ Resource softwareComponent = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, softwareCompName, "1.0", rootResource.getName(), true, true);
resourceData.getMetadataDataDefinition().setUniqueId(softwareComponent.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(
- capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
+ Either<RequirementDefinition, StorageOperationStatus> addRequirementToResource = addRequirementToResource(capabilityTypeName, reqName, reqNodeName, reqRelationship, softwareComponent);
String parentReqUniqId = addRequirementToResource.left().value().getUniqueId();
@@ -2064,8 +1846,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
// create root resource
// String rootId = UniqueIdBuilder.buildResourceUniqueId(rootName,
// "1.0");
- Either<List<Resource>, StorageOperationStatus> oldResource = resourceOperation
- .getResourceByNameAndVersion(rootName, "1.0", false);
+ Either<List<Resource>, StorageOperationStatus> oldResource = resourceOperation.getResourceByNameAndVersion(rootName, "1.0", false);
if (oldResource.isLeft()) {
for (Resource old : oldResource.left().value()) {
if (old.getResourceType().equals(ResourceTypeEnum.VFC)) {
@@ -2074,17 +1855,14 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
}
- Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true,
- true);
+ Resource rootResource = resourceOperationTest.createResource(USER_ID, CATEGORY_NAME, rootName, "1.0", null, true, true);
ResourceMetadataData rootResourceData = new ResourceMetadataData();
rootResourceData.getMetadataDataDefinition().setUniqueId(rootResource.getUniqueId());
rootResourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(rootResourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(rootResourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
- Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation
- .getResource(rootResource.getUniqueId(), true);
+ Either<Resource, StorageOperationStatus> fetchRootResource = resourceOperation.getResource(rootResource.getUniqueId(), true);
String rootResourceJson = prettyGson.toJson(fetchRootResource.left().value());
log.debug(rootResourceJson);
@@ -2109,29 +1887,21 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
CapabilityTypeDefinition createCapabilityDef = capabilityTypeOperationTest.createCapability(capabilityTypeName);
- Resource softwareComponentResource = createSoftwareComponentWithReq(softwareCompName, resourceOperationTest,
- rootResource, capabilityTypeName, reqName, reqRelationship, computeNodeName);
- Resource compute = createComputeWithCapability(capabilityTypeName, computeNodeName, resourceOperationTest,
- rootResource);
+ Resource softwareComponentResource = createSoftwareComponentWithReq(softwareCompName, resourceOperationTest, rootResource, capabilityTypeName, reqName, reqRelationship, computeNodeName);
+ Resource compute = createComputeWithCapability(capabilityTypeName, computeNodeName, resourceOperationTest, rootResource);
// resource1
- ComponentInstance myresourceInstance = buildResourceInstance(softwareComponentResource.getUniqueId(), "1",
- "tosca.nodes.test.root");
+ ComponentInstance myresourceInstance = buildResourceInstance(softwareComponentResource.getUniqueId(), "1", "tosca.nodes.test.root");
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", myinstanceRes.isLeft());
// resource2
- ComponentInstance computeInstance = buildResourceInstance(compute.getUniqueId(), "2",
- "tosca.nodes.test.compute");
+ ComponentInstance computeInstance = buildResourceInstance(compute.getUniqueId(), "2", "tosca.nodes.test.compute");
ComponentInstance value1 = myinstanceRes.left().value();
- Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance,
- NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> computeInstTes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "2", true, computeInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", computeInstTes.isLeft());
ComponentInstance value2 = computeInstTes.left().value();
@@ -2155,15 +1925,14 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
relationPair.setCapabilityOwnerId(value2.getUniqueId());
relationPair.setCapabilityUid(capId);
- Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation
- .connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(), value2.getUniqueId(),
- relationPair);
+ Either<RelationshipInstData, TitanOperationStatus> connectResourcesInService = resourceInstanceOperation.connectResourcesInService(serviceId, NodeTypeEnum.Service, value1.getUniqueId(), value2.getUniqueId(), relationPair);
assertTrue("check relation created", connectResourcesInService.isLeft());
}
@Test
+ @Ignore
public void addResourceInstancesResourceDeleted() {
String rootName = "tosca.nodes.test.root";
@@ -2185,24 +1954,21 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
capabilityTypeOperationTest.setOperations(titanDao, capabilityTypeOperation);
capabilityTypeOperationTest.createCapability(capabilityTypeName);
- Resource softwareComponentResource = createSoftwareComponentWithReq(softwareCompName, resourceOperationTest,
- rootResource, capabilityTypeName, reqName, reqRelationship, computeNodeName);
+ Resource softwareComponentResource = createSoftwareComponentWithReq(softwareCompName, resourceOperationTest, rootResource, capabilityTypeName, reqName, reqRelationship, computeNodeName);
deleteResource(softwareComponentResource.getUniqueId());
// resource1
- ComponentInstance myresourceInstance = buildResourceInstance(softwareComponentResource.getUniqueId(), "1",
- "tosca.nodes.test.root");
+ ComponentInstance myresourceInstance = buildResourceInstance(softwareComponentResource.getUniqueId(), "1", "tosca.nodes.test.root");
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance not added to service", myinstanceRes.isRight());
}
@Test
+ @Ignore
public void testDeploymentArtifactsOnRI() {
String rootName = "tosca.nodes.test.root";
@@ -2214,20 +1980,17 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
Resource rootResource = createRootResource(rootName, resourceOperationTest);
- ArtifactDefinition addArtifactToResource = addArtifactToResource(USER_ID, rootResource.getUniqueId(),
- "myArtifact");
+ ArtifactDefinition addArtifactToResource = addArtifactToResource(USER_ID, rootResource.getUniqueId(), "myArtifact");
// resource1
ComponentInstance myresourceInstance = buildResourceInstance(rootResource.getUniqueId(), "1", rootName);
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
assertTrue("check instance added to service", myinstanceRes.isLeft());
- Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, TitanOperationStatus> resourceInstancesOfService = resourceInstanceOperation
- .getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource);
+ Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, TitanOperationStatus> resourceInstancesOfService = resourceInstanceOperation.getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service,
+ NodeTypeEnum.Resource);
assertTrue(resourceInstancesOfService.isLeft());
List<ComponentInstance> resourceInstanceList = resourceInstancesOfService.left().value().left;
assertTrue(resourceInstanceList.size() == 1);
@@ -2241,13 +2004,10 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
heatEnvArtifact.setArtifactLabel(addArtifactToResource.getArtifactLabel() + "env");
heatEnvArtifact.setUniqueId(null);
- Either<ArtifactDefinition, StorageOperationStatus> either = artifactOperation.addHeatEnvArtifact(
- heatEnvArtifact, addArtifactToResource, resourceInstance.getUniqueId(), NodeTypeEnum.ResourceInstance,
- false);
+ Either<ArtifactDefinition, StorageOperationStatus> either = artifactOperation.addHeatEnvArtifact(heatEnvArtifact, addArtifactToResource, resourceInstance.getUniqueId(), NodeTypeEnum.ResourceInstance, true);
assertTrue(either.isLeft());
- resourceInstancesOfService = resourceInstanceOperation.getComponentInstancesOfComponent(serviceId,
- NodeTypeEnum.Service, NodeTypeEnum.Resource);
+ resourceInstancesOfService = resourceInstanceOperation.getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource);
assertTrue(resourceInstancesOfService.isLeft());
resourceInstanceList = resourceInstancesOfService.left().value().left;
assertTrue(resourceInstanceList.size() == 1);
@@ -2259,12 +2019,11 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
ArtifactDefinition heatEnvFromRI = artifacts.get(addArtifactToResource.getArtifactLabel() + "env");
assertEquals(addArtifactToResource.getUniqueId(), heatEnvFromRI.getGeneratedFromId());
- List<HeatParameterDefinition> heatParameters = artifacts.get(addArtifactToResource.getArtifactLabel())
- .getHeatParameters();
+ List<HeatParameterDefinition> heatParameters = artifacts.get(addArtifactToResource.getArtifactLabel()).getListHeatParameters();
assertNotNull(heatParameters);
assertTrue(heatParameters.size() == 1);
- List<HeatParameterDefinition> heatEnvParameters = heatEnvFromRI.getHeatParameters();
+ List<HeatParameterDefinition> heatEnvParameters = heatEnvFromRI.getListHeatParameters();
assertNotNull(heatEnvParameters);
assertTrue(heatEnvParameters.size() == 1);
@@ -2273,6 +2032,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void deleteResourceInstanceWithArtifacts() {
String rootName = "tosca.nodes.test.root";
@@ -2283,15 +2043,12 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
Resource rootResource = createRootResource(rootName, resourceOperationTest);
- ArtifactDefinition addArtifactToResource = addArtifactToResource(USER_ID, rootResource.getUniqueId(),
- "myArtifact");
+ ArtifactDefinition addArtifactToResource = addArtifactToResource(USER_ID, rootResource.getUniqueId(), "myArtifact");
// resource1
ComponentInstance myresourceInstance = buildResourceInstance(rootResource.getUniqueId(), "1", rootName);
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
ArtifactDefinition heatEnvArtifact = new ArtifactDefinition(addArtifactToResource);
heatEnvArtifact.setArtifactType("HEAT_ENV");
@@ -2300,38 +2057,32 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue("check instance added to service", myinstanceRes.isLeft());
- Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, TitanOperationStatus> resourceInstancesOfService = resourceInstanceOperation
- .getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource);
+ Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, TitanOperationStatus> resourceInstancesOfService = resourceInstanceOperation.getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service,
+ NodeTypeEnum.Resource);
assertTrue(resourceInstancesOfService.isLeft());
List<ComponentInstance> resourceInstanceList = resourceInstancesOfService.left().value().left;
assertTrue(resourceInstanceList.size() == 1);
ComponentInstance resourceInstance = resourceInstanceList.get(0);
- Either<ArtifactDefinition, StorageOperationStatus> either = artifactOperation.addHeatEnvArtifact(
- heatEnvArtifact, addArtifactToResource, resourceInstance.getUniqueId(), NodeTypeEnum.ResourceInstance,
- false);
+ Either<ArtifactDefinition, StorageOperationStatus> either = artifactOperation.addHeatEnvArtifact(heatEnvArtifact, addArtifactToResource, resourceInstance.getUniqueId(), NodeTypeEnum.ResourceInstance, true);
assertTrue(either.isLeft());
ArtifactDefinition heatEnvDefinition = either.left().value();
// delete resource instance
- Either<ComponentInstance, StorageOperationStatus> deleteResourceInstance = resourceInstanceOperation
- .deleteComponentInstance(NodeTypeEnum.Service, serviceId, resourceInstance.getUniqueId());
+ Either<ComponentInstance, StorageOperationStatus> deleteResourceInstance = resourceInstanceOperation.deleteComponentInstance(NodeTypeEnum.Service, serviceId, resourceInstance.getUniqueId());
assertTrue(deleteResourceInstance.isLeft());
// check heat env deleted
ArtifactData artifactData = new ArtifactData();
- Either<ArtifactData, TitanOperationStatus> getDeletedArtifact = titanDao.getNode(artifactData.getUniqueIdKey(),
- heatEnvDefinition.getUniqueId(), ArtifactData.class);
+ Either<ArtifactData, TitanOperationStatus> getDeletedArtifact = titanDao.getNode(artifactData.getUniqueIdKey(), heatEnvDefinition.getUniqueId(), ArtifactData.class);
assertTrue(getDeletedArtifact.isRight());
// check heat is not deleted
- getDeletedArtifact = titanDao.getNode(artifactData.getUniqueIdKey(), addArtifactToResource.getUniqueId(),
- ArtifactData.class);
+ getDeletedArtifact = titanDao.getNode(artifactData.getUniqueIdKey(), addArtifactToResource.getUniqueId(), ArtifactData.class);
assertTrue(getDeletedArtifact.isLeft());
HeatParameterData heatParamData = new HeatParameterData();
- Either<HeatParameterData, TitanOperationStatus> heatParamNode = titanDao.getNode(heatParamData.getUniqueIdKey(),
- addArtifactToResource.getHeatParameters().get(0).getUniqueId(), HeatParameterData.class);
+ Either<HeatParameterData, TitanOperationStatus> heatParamNode = titanDao.getNode(heatParamData.getUniqueIdKey(), addArtifactToResource.getHeatParameters().get(0).getUniqueId(), HeatParameterData.class);
assertTrue(heatParamNode.isLeft());
resourceOperation.deleteResource(rootResource.getUniqueId());
@@ -2339,6 +2090,7 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
}
@Test
+ @Ignore
public void getHeatEnvParams() {
String rootName = "tosca.nodes.test.root";
@@ -2349,15 +2101,12 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
resourceOperationTest.setOperations(titanDao, resourceOperation, propertyOperation);
Resource rootResource = createRootResource(rootName, resourceOperationTest);
- ArtifactDefinition addArtifactToResource = addArtifactToResource(USER_ID, rootResource.getUniqueId(),
- "myArtifact");
+ ArtifactDefinition addArtifactToResource = addArtifactToResource(USER_ID, rootResource.getUniqueId(), "myArtifact");
// resource1
ComponentInstance myresourceInstance = buildResourceInstance(rootResource.getUniqueId(), "1", rootName);
- Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation
- .addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true,
- myresourceInstance, NodeTypeEnum.Resource, false);
+ Either<ComponentInstance, TitanOperationStatus> myinstanceRes = resourceInstanceOperation.addComponentInstanceToContainerComponent(serviceId, NodeTypeEnum.Service, "1", true, myresourceInstance, NodeTypeEnum.Resource, false);
ArtifactDefinition heatEnvArtifact = new ArtifactDefinition(addArtifactToResource);
heatEnvArtifact.setArtifactType("HEAT_ENV");
@@ -2366,28 +2115,24 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertTrue("check instance added to service", myinstanceRes.isLeft());
- Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, TitanOperationStatus> resourceInstancesOfService = resourceInstanceOperation
- .getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource);
+ Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, TitanOperationStatus> resourceInstancesOfService = resourceInstanceOperation.getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service,
+ NodeTypeEnum.Resource);
assertTrue(resourceInstancesOfService.isLeft());
List<ComponentInstance> resourceInstanceList = resourceInstancesOfService.left().value().left;
assertTrue(resourceInstanceList.size() == 1);
ComponentInstance resourceInstance = resourceInstanceList.get(0);
- Either<ArtifactDefinition, StorageOperationStatus> either = artifactOperation.addHeatEnvArtifact(
- heatEnvArtifact, addArtifactToResource, resourceInstance.getUniqueId(), NodeTypeEnum.ResourceInstance,
- false);
+ Either<ArtifactDefinition, StorageOperationStatus> either = artifactOperation.addHeatEnvArtifact(heatEnvArtifact, addArtifactToResource, resourceInstance.getUniqueId(), NodeTypeEnum.ResourceInstance, true);
assertTrue(either.isLeft());
ArtifactDefinition heatEnvDefinition = either.left().value();
// update value
String newHeatValue = "123";
- addHeatValueToEnv(heatEnvDefinition.getUniqueId(), addArtifactToResource.getHeatParameters().get(0),
- newHeatValue);
+ addHeatValueToEnv(heatEnvDefinition.getUniqueId(), addArtifactToResource.getListHeatParameters().get(0), newHeatValue);
// check values received
- resourceInstancesOfService = resourceInstanceOperation.getComponentInstancesOfComponent(serviceId,
- NodeTypeEnum.Service, NodeTypeEnum.Resource);
+ resourceInstancesOfService = resourceInstanceOperation.getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource);
assertTrue(resourceInstancesOfService.isLeft());
resourceInstanceList = resourceInstancesOfService.left().value().left;
assertTrue(resourceInstanceList.size() == 1);
@@ -2397,14 +2142,12 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
assertNotNull(artifacts.get(addArtifactToResource.getArtifactLabel()));
assertNotNull(artifacts.get(addArtifactToResource.getArtifactLabel() + "env"));
- List<HeatParameterDefinition> heatParameters = artifacts.get(addArtifactToResource.getArtifactLabel())
- .getHeatParameters();
+ List<HeatParameterDefinition> heatParameters = artifacts.get(addArtifactToResource.getArtifactLabel()).getListHeatParameters();
assertNotNull(heatParameters);
assertTrue(heatParameters.size() == 1);
HeatParameterDefinition heatParameterTemplate = heatParameters.get(0);
- List<HeatParameterDefinition> heatEnvParameters = artifacts
- .get(addArtifactToResource.getArtifactLabel() + "env").getHeatParameters();
+ List<HeatParameterDefinition> heatEnvParameters = artifacts.get(addArtifactToResource.getArtifactLabel() + "env").getListHeatParameters();
assertNotNull(heatEnvParameters);
assertTrue(heatEnvParameters.size() == 1);
HeatParameterDefinition heatParameterEnv = heatEnvParameters.get(0);
@@ -2421,18 +2164,15 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
HeatParameterValueData heatValueData = new HeatParameterValueData();
heatValueData.setValue(value);
heatValueData.setUniqueId(artifactId + "." + heatDefinition.getName());
- Either<HeatParameterValueData, TitanOperationStatus> createValue = titanDao.createNode(heatValueData,
- HeatParameterValueData.class);
+ Either<HeatParameterValueData, TitanOperationStatus> createValue = titanDao.createNode(heatValueData, HeatParameterValueData.class);
assertTrue(createValue.isLeft());
HeatParameterValueData value2 = createValue.left().value();
HeatParameterData heatParamData = new HeatParameterData(heatDefinition);
- Either<GraphRelation, TitanOperationStatus> createRelation = titanDao.createRelation(value2, heatParamData,
- GraphEdgeLabels.PROPERTY_IMPL, null);
+ Either<GraphRelation, TitanOperationStatus> createRelation = titanDao.createRelation(value2, heatParamData, GraphEdgeLabels.PROPERTY_IMPL, null);
assertTrue(createRelation.isLeft());
Map<String, Object> props = new HashMap<String, Object>();
props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), heatDefinition.getName());
- Either<GraphRelation, TitanOperationStatus> createRelation2 = titanDao.createRelation(
- new UniqueIdData(NodeTypeEnum.ArtifactRef, artifactId), value2, GraphEdgeLabels.PARAMETER_VALUE, props);
+ Either<GraphRelation, TitanOperationStatus> createRelation2 = titanDao.createRelation(new UniqueIdData(NodeTypeEnum.ArtifactRef, artifactId), value2, GraphEdgeLabels.PARAMETER_VALUE, props);
assertTrue(createRelation2.isLeft());
titanDao.commit();
@@ -2501,10 +2241,9 @@ public class ResourceInstanceOperationTest extends ModelTestBase {
heatParam.setName("myParam");
heatParam.setType("number");
heatParams.add(heatParam);
- artifactInfo.setHeatParameters(heatParams);
+ artifactInfo.setListHeatParameters(heatParams);
- Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation
- .addArifactToComponent(artifactInfo, resourceId, NodeTypeEnum.Resource, true, true);
+ Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation.addArifactToComponent(artifactInfo, resourceId, NodeTypeEnum.Resource, true, true);
assertTrue(artifact.isLeft());
return artifact.left().value();
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperationTest.java
index f977509f6b..efd55d58fb 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperationTest.java
@@ -24,24 +24,34 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.Set;
+import java.util.UUID;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mockito;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
@@ -53,13 +63,8 @@ import org.openecomp.sdc.be.model.PropertyConstraint;
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.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.CapabilityOperation;
-import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.LifecycleOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint;
@@ -68,6 +73,9 @@ import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint;
import org.openecomp.sdc.be.resources.data.PropertyData;
import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
import org.openecomp.sdc.be.resources.data.UserData;
+import org.openecomp.sdc.be.resources.data.category.CategoryData;
+import org.openecomp.sdc.be.resources.data.category.SubCategoryData;
+import org.openecomp.sdc.be.unittests.utils.FactoryUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
@@ -75,6 +83,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanGraphQuery;
+import com.thinkaurelius.titan.core.TitanVertex;
+import com.thinkaurelius.titan.graphdb.query.graph.GraphCentricQueryBuilder;
import fj.data.Either;
@@ -100,7 +112,7 @@ public class ResourceOperationTest extends ModelTestBase {
@javax.annotation.Resource(name = "capability-type-operation")
private CapabilityTypeOperation capabilityTypeOperation;
-
+
private static String CATEGORY_NAME = "category/mycategory";
private static String CATEGORY_NAME_UPDATED = "category1/updatedcategory";
@@ -110,8 +122,7 @@ public class ResourceOperationTest extends ModelTestBase {
ModelTestBase.init();
}
- public void setOperations(TitanGenericDao titanGenericDao, ResourceOperation resourceOperation,
- PropertyOperation propertyOperation) {
+ public void setOperations(TitanGenericDao titanGenericDao, ResourceOperation resourceOperation, PropertyOperation propertyOperation) {
this.titanDao = titanGenericDao;
this.resourceOperation = resourceOperation;
this.propertyOperation = propertyOperation;
@@ -122,8 +133,7 @@ public class ResourceOperationTest extends ModelTestBase {
}
- private Resource buildResourceMetadata(String userId, String category, String resourceName,
- String resourceVersion) {
+ private Resource buildResourceMetadata(String userId, String category, String resourceName, String resourceVersion) {
Resource resource = new Resource();
resource.setName(resourceName);
@@ -164,8 +174,7 @@ public class ResourceOperationTest extends ModelTestBase {
OperationTestsUtil.deleteAndCreateResourceCategory(names[0], names[1], titanDao);
}
- public Resource createResource(String userId, String category, String resourceName, String resourceVersion,
- String parentResourceName, boolean isAbstract, boolean isHighestVersion) {
+ public Resource createResource(String userId, String category, String resourceName, String resourceVersion, String parentResourceName, boolean isAbstract, boolean isHighestVersion) {
String propName1 = "disk_size";
String propName2 = "num_cpus";
@@ -183,8 +192,7 @@ public class ResourceOperationTest extends ModelTestBase {
PropertyDefinition property1 = new PropertyDefinition();
property1.setDefaultValue("10");
- property1.setDescription(
- "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
+ property1.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
property1.setType(ToscaType.INTEGER.name().toLowerCase());
List<PropertyConstraint> constraints = new ArrayList<PropertyConstraint>();
GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0");
@@ -226,16 +234,14 @@ public class ResourceOperationTest extends ModelTestBase {
// assertEquals("check resource unique id",
// UniqueIdBuilder.buildResourceUniqueId(resourceName,
// resourceVersion), resultResource.getUniqueId());
- assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT,
- resultResource.getLifecycleState());
+ assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultResource.getLifecycleState());
// retrieve property from graph
String resourceId = resultResource.getUniqueId();
// String resourceId = UniqueIdBuilder.buildResourceUniqueId(
// resource.getResourceName(), resource.getResourceVersion());
- Either<PropertyDefinition, StorageOperationStatus> either = propertyOperation.getPropertyOfResource(propName1,
- resourceId);
+ Either<PropertyDefinition, StorageOperationStatus> either = propertyOperation.getPropertyOfResource(propName1, resourceId);
assertTrue(either.isLeft());
PropertyDefinition propertyDefinition = either.left().value();
@@ -243,12 +249,68 @@ public class ResourceOperationTest extends ModelTestBase {
assertEquals("check property description", property1.getDescription(), propertyDefinition.getDescription());
assertEquals("check property type", property1.getType(), propertyDefinition.getType());
assertEquals("check property unique id", property1.getUniqueId(), propertyDefinition.getUniqueId());
- assertEquals("check property consitraints size", property1.getConstraints().size(),
- propertyDefinition.getConstraints().size());
+ assertEquals("check property consitraints size", property1.getConstraints().size(), propertyDefinition.getConstraints().size());
return resultResource;
}
+
+ public Resource createResourceOverrideProperty(String userId, String category, String resourceName, String resourceVersion, String parentResourceName, boolean isAbstract, boolean isHighestVersion) {
+
+ String propName1 = "disk_size";
+
+ List<String> derivedFrom = new ArrayList<String>();
+ if (parentResourceName != null) {
+ derivedFrom.add(parentResourceName);
+ }
+
+ Map<String, PropertyDefinition> properties = new HashMap<String, PropertyDefinition>();
+ PropertyDefinition property1 = new PropertyDefinition();
+ property1.setDefaultValue("9");
+ property1.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
+ property1.setType(ToscaType.INTEGER.name().toLowerCase());
+ List<PropertyConstraint> constraints = new ArrayList<PropertyConstraint>();
+ GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0");
+ log.debug("{}", propertyConstraint1);
+ constraints.add(propertyConstraint1);
+ LessOrEqualConstraint propertyConstraint2 = new LessOrEqualConstraint("10");
+ constraints.add(propertyConstraint2);
+ property1.setConstraints(constraints);
+ properties.put(propName1, property1);
+
+ Resource resource = buildResourceMetadata(userId, category, resourceName, resourceVersion);
+ resource.setAbstract(isAbstract);
+ resource.setHighestVersion(isHighestVersion);
+ resource.setDerivedFrom(derivedFrom);
+ resource.setProperties(convertMapToList(properties));
+
+ Either<Resource, StorageOperationStatus> result = resourceOperation.createResource(resource, true);
+
+ assertTrue(result.isLeft());
+ Resource resultResource = result.left().value();
+
+ // assertEquals("check resource unique id",
+ // UniqueIdBuilder.buildResourceUniqueId(resourceName,
+ // resourceVersion), resultResource.getUniqueId());
+ assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultResource.getLifecycleState());
+
+ // retrieve property from graph
+ String resourceId = resultResource.getUniqueId();
+ // String resourceId = UniqueIdBuilder.buildResourceUniqueId(
+ // resource.getResourceName(), resource.getResourceVersion());
+
+ Either<PropertyDefinition, StorageOperationStatus> either = propertyOperation.getPropertyOfResource(propName1, resourceId);
+
+ assertTrue(either.isLeft());
+ PropertyDefinition propertyDefinition = either.left().value();
+ assertEquals("check property default value", property1.getDefaultValue(), propertyDefinition.getDefaultValue());
+ assertEquals("check property description", property1.getDescription(), propertyDefinition.getDescription());
+ assertEquals("check property type", property1.getType(), propertyDefinition.getType());
+ assertEquals("check property unique id", property1.getUniqueId(), propertyDefinition.getUniqueId());
+ assertEquals("check property consitraints size", property1.getConstraints().size(), propertyDefinition.getConstraints().size());
+
+ return resultResource;
+ }
public static List<PropertyDefinition> convertMapToList(Map<String, PropertyDefinition> properties) {
if (properties == null) {
@@ -285,8 +347,7 @@ public class ResourceOperationTest extends ModelTestBase {
Set<LifecycleStateEnum> lastStateStates = new HashSet<LifecycleStateEnum>();
lastStateStates.add(LifecycleStateEnum.CERTIFIED);
- Either<List<Resource>, StorageOperationStatus> followed = resourceOperation.getFollowed(userId, lifecycleStates,
- lastStateStates, false);
+ Either<List<Resource>, StorageOperationStatus> followed = resourceOperation.getFollowed(userId, lifecycleStates, lastStateStates, false);
assertTrue(followed.isLeft());
List<Resource> list = followed.left().value();
@@ -352,8 +413,7 @@ public class ResourceOperationTest extends ModelTestBase {
propertyDefinition.setName("myProperty");
rootResource.getProperties().add(propertyDefinition);
- Either<Resource, StorageOperationStatus> overrideResource = resourceOperation.overrideResource(rootResource,
- rootResource, false);
+ Either<Resource, StorageOperationStatus> overrideResource = resourceOperation.overrideResource(rootResource, rootResource, false);
assertTrue(overrideResource.isLeft());
Resource resourceAfter = overrideResource.left().value();
@@ -399,8 +459,7 @@ public class ResourceOperationTest extends ModelTestBase {
props.put(delaultProperty2.getName(), delaultProperty2);
capabilityTypeDefinition.setProperties(props);
- Either<CapabilityTypeDefinition, StorageOperationStatus> addTypeRes = capabilityTypeOperation
- .addCapabilityType(capabilityTypeDefinition);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> addTypeRes = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition);
assertTrue(addTypeRes.isLeft());
CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
@@ -423,8 +482,7 @@ public class ResourceOperationTest extends ModelTestBase {
capabilityDefinition.setProperties(properties);
- Either<CapabilityDefinition, StorageOperationStatus> addCapabilityRes = capabilityOperation
- .addCapability(rootResource.getUniqueId(), capabilityDefinition.getName(), capabilityDefinition);
+ Either<CapabilityDefinition, StorageOperationStatus> addCapabilityRes = capabilityOperation.addCapability(rootResource.getUniqueId(), capabilityDefinition.getName(), capabilityDefinition);
assertTrue(addCapabilityRes.isLeft());
List<PropertyDefinition> newProperties = new ArrayList<PropertyDefinition>();
@@ -442,8 +500,7 @@ public class ResourceOperationTest extends ModelTestBase {
CapabilityDefinition addedCap = addCapabilityRes.left().value();
- Either<Map<String, PropertyData>, StorageOperationStatus> updatePropertiesRes = capabilityOperation
- .updatePropertiesOfCapability(addedCap.getUniqueId(), addedCap.getType(), newProperties);
+ Either<Map<String, PropertyData>, StorageOperationStatus> updatePropertiesRes = capabilityOperation.updatePropertiesOfCapability(addedCap.getUniqueId(), addedCap.getType(), newProperties);
assertTrue(updatePropertiesRes.isLeft());
PropertyDefinition invalidProperty = new PropertyDefinition();
@@ -452,25 +509,20 @@ public class ResourceOperationTest extends ModelTestBase {
invalidProperty.setDefaultValue("666");
newProperties.add(invalidProperty);
- Either<Map<String, PropertyData>, StorageOperationStatus> updatePropertiesInvalidRes = capabilityOperation
- .updatePropertiesOfCapability(addedCap.getUniqueId(), addedCap.getType(), newProperties);
+ Either<Map<String, PropertyData>, StorageOperationStatus> updatePropertiesInvalidRes = capabilityOperation.updatePropertiesOfCapability(addedCap.getUniqueId(), addedCap.getType(), newProperties);
assertTrue(updatePropertiesInvalidRes.isRight());
- Either<CapabilityDefinition, StorageOperationStatus> getCapabilityRes = capabilityOperation
- .getCapability(addedCap.getUniqueId());
+ Either<CapabilityDefinition, StorageOperationStatus> getCapabilityRes = capabilityOperation.getCapability(addedCap.getUniqueId());
assertTrue(getCapabilityRes.isLeft());
- Either<List<ImmutablePair<PropertyData, GraphEdge>>, TitanOperationStatus> deletePropertiesOfCapabilityRes = capabilityOperation
- .deletePropertiesOfCapability(addedCap.getUniqueId());
+ Either<List<ImmutablePair<PropertyData, GraphEdge>>, TitanOperationStatus> deletePropertiesOfCapabilityRes = capabilityOperation.deletePropertiesOfCapability(addedCap.getUniqueId());
assertTrue(deletePropertiesOfCapabilityRes.isLeft());
- StorageOperationStatus deleteCapabilityRes = capabilityOperation
- .deleteCapabilityFromGraph(addedCap.getUniqueId());
+ StorageOperationStatus deleteCapabilityRes = capabilityOperation.deleteCapabilityFromGraph(addedCap.getUniqueId());
assertTrue(deleteCapabilityRes.equals(StorageOperationStatus.OK));
getCapabilityRes = capabilityOperation.getCapability(addedCap.getUniqueId());
- assertTrue(getCapabilityRes.isRight()
- && getCapabilityRes.right().value().equals(StorageOperationStatus.NOT_FOUND));
+ assertTrue(getCapabilityRes.isRight() && getCapabilityRes.right().value().equals(StorageOperationStatus.NOT_FOUND));
resourceOperation.deleteResource(rootResource.getUniqueId());
}
@@ -503,8 +555,7 @@ public class ResourceOperationTest extends ModelTestBase {
Resource rootResource = buildResourceMetadata(userId, category, rootName, "1.1");
rootResource.setUniqueId(UniqueIdBuilder.buildResourceUniqueId());
- Either<Resource, StorageOperationStatus> overrideResource = resourceOperation.overrideResource(rootResource,
- rootResource, false);
+ Either<Resource, StorageOperationStatus> overrideResource = resourceOperation.overrideResource(rootResource, rootResource, false);
assertTrue(overrideResource.isRight());
@@ -524,8 +575,7 @@ public class ResourceOperationTest extends ModelTestBase {
Map<String, Object> propertiesToMatch = new HashMap<>();
propertiesToMatch.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFIED.name());
- Either<Set<Resource>, StorageOperationStatus> catalog = resourceOperation.getCatalogData(propertiesToMatch,
- false);
+ Either<Set<Resource>, StorageOperationStatus> catalog = resourceOperation.getCatalogData(propertiesToMatch, false);
assertTrue(catalog.isLeft());
Set<Resource> catalogSet = catalog.left().value();
Set<String> idSet = new HashSet<>();
@@ -566,22 +616,19 @@ public class ResourceOperationTest extends ModelTestBase {
String resourceId3 = resultResource3.getUniqueId();
// update 1 resource to READY_FOR_CERTIFICATION
- Either<Resource, StorageOperationStatus> certReqResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Resource, resultResource, adminUser, adminUser, false);
+ Either<Resource, StorageOperationStatus> certReqResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Resource, resultResource, adminUser, adminUser, false);
Resource RFCResource = certReqResponse.left().value();
assertEquals(RFCResource.getLifecycleState(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
// update 1 resource to CERTIFICATION_IN_PROGRESS
- Either<Resource, StorageOperationStatus> startCertificationResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Resource, resultResource2, testerUser, adminUser, false);
+ Either<Resource, StorageOperationStatus> startCertificationResponse = (Either<Resource, StorageOperationStatus>) lifecycleOperation.startComponentCertification(NodeTypeEnum.Resource, resultResource2, testerUser, adminUser, false);
Resource IPResource = startCertificationResponse.left().value();
assertEquals(IPResource.getLifecycleState(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
Set<LifecycleStateEnum> lifecycleStates = new HashSet<LifecycleStateEnum>();
lifecycleStates.add(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<List<Resource>, StorageOperationStatus> resources = resourceOperation.getTesterFollowed(testerUserId,
- lifecycleStates, false);
+ Either<List<Resource>, StorageOperationStatus> resources = resourceOperation.getTesterFollowed(testerUserId, lifecycleStates, false);
assertTrue(resources.isLeft());
List<Resource> result = resources.left().value();
@@ -610,8 +657,7 @@ public class ResourceOperationTest extends ModelTestBase {
String resourceId1 = newResource.getUniqueId();
User admin = new User("j", "h", userId, null, "ADMIN", System.currentTimeMillis());
- Either<Resource, StorageOperationStatus> checkoutResource = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, newResource, admin, admin, false);
+ Either<Resource, StorageOperationStatus> checkoutResource = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, newResource, admin, admin, false);
assertTrue(checkoutResource.isLeft());
Resource newResource2 = checkoutResource.left().value();
String resourceId2 = newResource2.getUniqueId();
@@ -619,9 +665,7 @@ public class ResourceOperationTest extends ModelTestBase {
Resource newResource3 = createResource(userId, category, resName, "0.1", null, false, true);
String resourceId3 = newResource3.getUniqueId();
- Either<Map<String, String>, TitanOperationStatus> versionList = resourceOperation.getVersionList(
- NodeTypeEnum.Resource, "0.2", newResource2.getUUID(), newResource2.getSystemName(),
- ResourceMetadataData.class);
+ Either<Map<String, String>, TitanOperationStatus> versionList = resourceOperation.getVersionList(NodeTypeEnum.Resource, "0.2", newResource2.getUUID(), newResource2.getSystemName(), ResourceMetadataData.class);
assertTrue(versionList.isLeft());
Map<String, String> versionMap = versionList.left().value();
@@ -650,21 +694,17 @@ public class ResourceOperationTest extends ModelTestBase {
String resourceId1 = newResource.getUniqueId();
User admin = new User("j", "h", userId, null, "ADMIN", System.currentTimeMillis());
- Either<Resource, StorageOperationStatus> checkoutResource = (Either<Resource, StorageOperationStatus>) lifecycleOperation
- .checkoutComponent(NodeTypeEnum.Resource, newResource, admin, admin, false);
+ Either<Resource, StorageOperationStatus> checkoutResource = (Either<Resource, StorageOperationStatus>) lifecycleOperation.checkoutComponent(NodeTypeEnum.Resource, newResource, admin, admin, false);
assertTrue(checkoutResource.isLeft());
Resource newResource2 = checkoutResource.left().value();
String resourceId2 = newResource2.getUniqueId();
Either<Resource, StorageOperationStatus> resource = resourceOperation.getResource(resourceId1, false);
assertTrue(resource.isLeft());
- Either<Component, StorageOperationStatus> markResourceToDelete = resourceOperation
- .markComponentToDelete(resource.left().value(), false);
+ Either<Component, StorageOperationStatus> markResourceToDelete = resourceOperation.markComponentToDelete(resource.left().value(), false);
assertTrue(markResourceToDelete.isLeft());
- Either<Map<String, String>, TitanOperationStatus> versionList = resourceOperation.getVersionList(
- NodeTypeEnum.Resource, "0.2", newResource2.getUUID(), newResource2.getSystemName(),
- ResourceMetadataData.class);
+ Either<Map<String, String>, TitanOperationStatus> versionList = resourceOperation.getVersionList(NodeTypeEnum.Resource, "0.2", newResource2.getUUID(), newResource2.getSystemName(), ResourceMetadataData.class);
assertTrue(versionList.isLeft());
Map<String, String> versionMap = versionList.left().value();
@@ -678,8 +718,63 @@ public class ResourceOperationTest extends ModelTestBase {
deleteResource = resourceOperation.deleteResource(resourceId2);
assertTrue(deleteResource.isLeft());
}
-
- @Test
+
+ // @Test
+ // public void getVersionListAfterCertify(){
+ // String resName = "myResource";
+ // String category = CATEGORY_NAME;
+ // deleteAndCreateCategory(category);
+ //
+ // Resource newResource = createResource(userId, category, resName, "1.0",
+ // null, false, true);
+ // String resourceId1 = newResource.getUniqueId();
+ //
+ // User admin = new User("j", "h", userId, null, "ADMIN",
+ // System.currentTimeMillis());
+ // Either<Resource, StorageOperationStatus> checkoutResource =
+ // lifecycleOperation.checkoutResource(newResource, admin, admin, false);
+ // assertTrue(checkoutResource.isLeft());
+ // Resource resourceToDelete = checkoutResource.left().value();
+ // String deletedId = resourceToDelete.getUniqueId();
+ //
+ // Either<Resource, StorageOperationStatus> resource =
+ // resourceOperation.getResource(deletedId, false);
+ // assertTrue(resource.isLeft());
+ // Either<Resource, StorageOperationStatus> markResourceToDelete =
+ // resourceOperation.markResourceToDelete(resource.left().value(), false);
+ // assertTrue(markResourceToDelete.isLeft());
+ //
+ //
+ // Resource newResource2 = createResource(userId, category, resName, "2.0",
+ // null, false, true);
+ // String resourceId2 = newResource2.getUniqueId();
+ //
+ //
+ // Either<Map<String, String>, TitanOperationStatus> versionList =
+ // resourceOperation
+ // .getVersionList(NodeTypeEnum.Resource, "2.0",
+ // newResource2.getUUID(), newResource2.getSystemName(),
+ // ResourceData.class);
+ // assertTrue(versionList.isLeft());
+ // Map<String, String> versionMap = versionList.left().value();
+ //
+ // assertTrue(versionMap.size()==2);
+ // assertTrue(versionMap.containsValue(resourceId1));
+ // assertTrue(versionMap.containsValue(resourceId2));
+ //
+ // assertFalse(versionMap.containsValue(deletedId));
+ //
+ // Either<Resource, StorageOperationStatus> deleteResource =
+ // resourceOperation.deleteResource(resourceId1);
+ // assertTrue(deleteResource.isLeft());
+ // deleteResource = resourceOperation.deleteResource(resourceId2);
+ // assertTrue(deleteResource.isLeft());
+ // deleteResource = resourceOperation.deleteResource(deletedId);
+ // assertTrue(deleteResource.isLeft());
+ //
+ // }
+
+// @Test
public void testDerviedPropertiesInResource() {
try {
@@ -693,8 +788,7 @@ public class ResourceOperationTest extends ModelTestBase {
ResourceMetadataData resourceData = new ResourceMetadataData();
resourceData.getMetadataDataDefinition().setUniqueId(createResource1.getUniqueId());
resourceData.getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData,
- ResourceMetadataData.class);
+ Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceData, ResourceMetadataData.class);
assertTrue(updateNode.isLeft());
Gson gson = new GsonBuilder().setPrettyPrinting().create();
@@ -702,33 +796,158 @@ public class ResourceOperationTest extends ModelTestBase {
String json = gson.toJson(createResource1);
log.debug(json);
- Resource createResource2 = createResource(userId, category, "myResource2", "0.1", createResource1.getName(),
- true, false);
-
+ Resource createResource2 = createResourceOverrideProperty(userId, category, "myResource2", "0.1", createResource1.getName(), true, false);
+
json = gson.toJson(createResource2);
log.debug(json);
List<PropertyDefinition> propList1 = new ArrayList<>();
- TitanOperationStatus findAllResourcePropertiesRecursively1 = propertyOperation
- .findAllResourcePropertiesRecursively(createResource1.getUniqueId(), propList1);
- assertEquals("check search properties succeed", findAllResourcePropertiesRecursively1,
- TitanOperationStatus.OK);
+ TitanOperationStatus findAllResourcePropertiesRecursively1 = propertyOperation.findAllResourcePropertiesRecursively(createResource1.getUniqueId(), propList1);
+ assertEquals("check search properties succeed", findAllResourcePropertiesRecursively1, TitanOperationStatus.OK);
List<PropertyDefinition> propList2 = new ArrayList<>();
- TitanOperationStatus findAllResourcePropertiesRecursively2 = propertyOperation
- .findAllResourcePropertiesRecursively(createResource2.getUniqueId(), propList2);
- assertEquals("check search properties succeed", findAllResourcePropertiesRecursively2,
- TitanOperationStatus.OK);
-
- assertEquals("check number of properties", propList1.size() * 2, propList2.size());
-
+ TitanOperationStatus findAllResourcePropertiesRecursively2 = propertyOperation.findAllResourcePropertiesRecursively(createResource2.getUniqueId(), propList2);
+ assertEquals("check search properties succeed", findAllResourcePropertiesRecursively2, TitanOperationStatus.OK);
+ // checks that properties with the same names have been overrided properly
+ // the sizes of the property lists should be same (we have 2 properties "disk_size" and "num_cpus" only)
+ assertEquals("check number of properties", propList1.size(), propList2.size());
+ // checks that not overrided property default value in child's list equals to the same property of the parent
+ assertEquals("check values of properties are the same", propList1.stream().filter(prop->prop.getName().equals("num_cpus")).findAny().get().getDefaultValue()
+ , propList2.stream().filter(prop->prop.getName().equals("num_cpus")).findAny().get().getDefaultValue());
+ // checks that an overrided property default value in child's list doesn't equal to the same property of the parent
+ assertTrue(!propList1.stream().filter(prop->prop.getName().equals("disk_size")).findAny().get().getDefaultValue().equals(
+ propList2.stream().filter(prop->prop.getName().equals("disk_size")).findAny().get().getDefaultValue()));
+
resourceOperation.deleteResource(createResource1.getUniqueId());
resourceOperation.deleteResource(createResource2.getUniqueId());
} finally {
}
+
+ /*
+ * "properties": { "disk_size": { "constraints": [ { "greaterThan": "0" }, { "lessOrEqual": "10" } ], "uniqueId": "res_myresource1.0.1.disk_size", "type": "integer", "required": false, "defaultValue": "10", "description":
+ * "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node." , "isPassword": false }, "num_cpus": { "constraints": [ { "inRange": [ "1", "4" ] } ], "uniqueId": "res_myresource1.0.1.num_cpus", "type":
+ * "integer", "required": false, "defaultValue": "2", "description": "Number of (actual or virtual) CPUs associated with the Compute node." , "isPassword": false } },
+ */
+ }
+
+ @Test
+ public void getFilteredComponentsTest() {
+
+ TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class);
+ IElementOperation elementOperation = Mockito.mock(ElementOperation.class);
+ IElementOperation prevElementOperation = this.resourceOperation.getElementOperation();
+ this.resourceOperation.setElementOperation(elementOperation);
+ this.resourceOperation.setTitanGenericDao(titanGenericDao);
+
+ String subCategoryName = "Database";
+ String categoryName = "Generic";
+ String resourceTypeName = "VFC";
+
+ Map<FilterKeyEnum, String> filters = new HashMap<>();
+ filters.put(FilterKeyEnum.CATEGORY, categoryName);
+ filters.put(FilterKeyEnum.SUB_CATEGORY, subCategoryName);
+ filters.put(FilterKeyEnum.RESOURCE_TYPE, resourceTypeName);
+
+ prepareMocks(titanGenericDao, elementOperation, subCategoryName, categoryName, resourceTypeName);
+ try{
+ //search by category, subCategory and resourceType
+ Either<List<Resource>, StorageOperationStatus> getFilteredComponentsRes =
+ this.resourceOperation.getFilteredComponents(filters, false);
+ assertTrue(getFilteredComponentsRes.isLeft());
+
+ //search by category and resourceType
+ filters.remove(FilterKeyEnum.SUB_CATEGORY);
+ getFilteredComponentsRes =
+ this.resourceOperation.getFilteredComponents(filters, false);
+ assertTrue(getFilteredComponentsRes.isLeft());
+
+ //search by resourceType
+ filters.remove(FilterKeyEnum.CATEGORY);
+ getFilteredComponentsRes =
+ this.resourceOperation.getFilteredComponents(filters, false);
+ assertTrue(getFilteredComponentsRes.isLeft());
+ }finally{
+ this.resourceOperation.setTitanGenericDao(this.titanDao);
+ this.resourceOperation.setElementOperation(prevElementOperation);
+ }
+
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private void prepareMocks(TitanGenericDao titanGenericDao, IElementOperation elementOperation, String subCategoryName, String categoryName, String resourceTypeName) {
+ //prepare resource
+ ResourceMetadataData resourceMeta = FactoryUtils.createResourceByType(resourceTypeName);
+ ImmutablePair<ResourceMetadataData, GraphEdge> resourcePair = new ImmutablePair<ResourceMetadataData, GraphEdge>(resourceMeta, new GraphEdge());
+ List<ImmutablePair<ResourceMetadataData, GraphEdge>> resourcePairList = new ArrayList<>();
+ resourcePairList.add(resourcePair);
+ Either<List<ImmutablePair<ResourceMetadataData, GraphEdge>>, TitanOperationStatus> parentNodes = Either.left(resourcePairList);
+ Map<String, Object> resourceProps = new HashMap<String, Object>();
+ resourceProps.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), resourceTypeName);
+ resourceProps.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
+ List<ResourceMetadataData> resourceList = new ArrayList<>();
+ resourceList.add(resourceMeta);
+ Either<List<ResourceMetadataData>, TitanOperationStatus> getResources = Either.left(resourceList);
+
+ //prepare subcategory
+ SubCategoryData subCategoryData = new SubCategoryData(NodeTypeEnum.ResourceSubcategory);
+ subCategoryData.getSubCategoryDataDefinition().setName(subCategoryName);
+ subCategoryData.getSubCategoryDataDefinition().setUniqueId(UUID.randomUUID().toString());
+ GraphEdge graphEdge = new GraphEdge();
+ Optional<ImmutablePair<SubCategoryData, GraphEdge>> subCategory = Optional.of(new ImmutablePair<>(subCategoryData, graphEdge));
+ List<ImmutablePair<SubCategoryData, GraphEdge>> subcategoriesList = new ArrayList<>();
+ subcategoriesList.add(subCategory.get());
+ Either<List<ImmutablePair<SubCategoryData, GraphEdge>>, TitanOperationStatus> subcategories = Either.left(subcategoriesList);
+
+ //prepare category
+ CategoryData categoryData = new CategoryData(NodeTypeEnum.ResourceNewCategory);
+ categoryData.getCategoryDataDefinition().setUniqueId(UUID.randomUUID().toString());
+ categoryData.getCategoryDataDefinition().setName(categoryName);
+ Either<CategoryData, StorageOperationStatus> categoryResult = Either.left(categoryData);
+ List<CategoryData> categoryDataList = new ArrayList<>();
+ categoryDataList.add(categoryResult.left().value());
+ Either<ImmutablePair<CategoryData, GraphEdge>, TitanOperationStatus> categoryNode =
+ Either.left(new ImmutablePair<CategoryData, GraphEdge>(categoryData, new GraphEdge()));
+ Map<String, Object> categoryProps = new HashMap<>();
+ categoryProps.put(GraphPropertiesDictionary.NAME.getProperty(), categoryName);
+ //prepare graph
+ Either<TitanGraph, TitanOperationStatus> graphResult = Either.left(Mockito.mock(TitanGraph.class));
+ TitanGraph titanGraph = graphResult.left().value();
+ TitanVertex vertex = Mockito.mock(TitanVertex.class);
+ Iterator<Edge> iterCreator = Mockito.mock(Iterator.class);
+ Vertex vertexCreator = Mockito.mock(Vertex.class);
+ Edge edge = Mockito.mock(Edge.class);
+ List<TitanVertex> verteciesList= new ArrayList<>();
+ verteciesList.add(vertex);
+ Iterable<TitanVertex> vertecies = new ArrayList<>(verteciesList);
+ @SuppressWarnings("rawtypes")
+ TitanGraphQuery qBuilder = Mockito.mock(GraphCentricQueryBuilder.class);
+
+ when(titanGenericDao.getByCriteria(NodeTypeEnum.ResourceNewCategory, categoryProps, CategoryData.class)).thenReturn(Either.left(categoryDataList));
+ when(elementOperation.getNewCategoryData(categoryName, NodeTypeEnum.ResourceNewCategory, CategoryData.class)).thenReturn(categoryResult);
+ when(titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceNewCategory), categoryData.getCategoryDataDefinition().getUniqueId(),
+ GraphEdgeLabels.SUB_CATEGORY, NodeTypeEnum.ResourceSubcategory, SubCategoryData.class)).thenReturn(subcategories);
+ when(titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), null,
+ GraphEdgeLabels.CATEGORY, NodeTypeEnum.ResourceSubcategory, SubCategoryData.class)).thenReturn(subcategories);
+ when(titanGenericDao.getParentNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceSubcategory), (String) subCategoryData.getSubCategoryDataDefinition().getUniqueId(),
+ GraphEdgeLabels.SUB_CATEGORY, NodeTypeEnum.ResourceNewCategory, CategoryData.class)).thenReturn(categoryNode);
+ when(titanGenericDao.getParentNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceSubcategory), subCategoryData.getSubCategoryDataDefinition().getUniqueId(),
+ GraphEdgeLabels.CATEGORY, NodeTypeEnum.Resource, ResourceMetadataData.class)).thenReturn(parentNodes);
+ when(titanGenericDao.getGraph()).thenReturn(graphResult);
+ when(vertex.edges(Direction.IN, GraphEdgeLabels.CREATOR.name())).thenReturn(iterCreator);
+ when(vertex.edges(Direction.IN, GraphEdgeLabels.LAST_MODIFIER.name())).thenReturn(iterCreator);
+ when(iterCreator.hasNext()).thenReturn(true);
+ when(iterCreator.next()).thenReturn(edge);
+ when(edge.outVertex()).thenReturn(vertexCreator);
+ when(titanGenericDao.getProperties(vertex)).thenReturn(resourceProps);
+ when(titanGraph.query()).thenReturn(qBuilder);
+ when(qBuilder.has(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), resourceMeta.getUniqueId())).thenReturn(qBuilder);
+ when(qBuilder.vertices()).thenReturn(vertecies);
+ when(titanGenericDao.getByCriteria(NodeTypeEnum.Resource, resourceProps, ResourceMetadataData.class))
+ .thenReturn(getResources);
}
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ServiceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ServiceOperationTest.java
index 81a5a5ed1d..52686fbfa9 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ServiceOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ServiceOperationTest.java
@@ -106,7 +106,7 @@ public class ServiceOperationTest extends ModelTestBase {
private LifecycleOperation lifecycleOperation;
private static Logger log = LoggerFactory.getLogger(ServiceOperation.class.getName());
- private static String USER_ID = "muserId";
+ private static String USER_ID = "muUserId";
private static String CATEGORY_NAME = "category/mycategory";
@BeforeClass
@@ -184,8 +184,7 @@ public class ServiceOperationTest extends ModelTestBase {
log.debug(" *** delete **");
log.debug("{}", serviceDelete.left().value());
- Either<List<ArtifactData>, TitanOperationStatus> artifacts = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef,
- null, ArtifactData.class);
+ Either<List<ArtifactData>, TitanOperationStatus> artifacts = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef, null, ArtifactData.class);
assertTrue(artifacts.isRight());
assertEquals(TitanOperationStatus.NOT_FOUND, artifacts.right().value());
@@ -203,10 +202,7 @@ public class ServiceOperationTest extends ModelTestBase {
log.debug("{}", serviceAfterSave);
String uniqueId = serviceAfterSave.getUniqueId();
- boolean canWorkOnComponent = ComponentValidationUtils.canWorkOnComponent(uniqueId, serviceOperation, userId);
- assertTrue(canWorkOnComponent);
-
- canWorkOnComponent = ComponentValidationUtils.canWorkOnComponent(serviceAfterSave, userId);
+ boolean canWorkOnComponent = ComponentValidationUtils.canWorkOnComponent(serviceAfterSave, userId);
assertTrue(canWorkOnComponent);
StorageOperationStatus lockComponent = graphLockOperation.lockComponent(uniqueId, NodeTypeEnum.Service);
@@ -228,17 +224,14 @@ public class ServiceOperationTest extends ModelTestBase {
log.debug(" *** create **");
log.debug("{}", serviceAfterSave);
- Either<Integer, StorageOperationStatus> counter = serviceOperation
- .increaseAndGetComponentInstanceCounter(serviceAfterSave.getUniqueId(), NodeTypeEnum.Service, false);
+ Either<Integer, StorageOperationStatus> counter = serviceOperation.increaseAndGetComponentInstanceCounter(serviceAfterSave.getUniqueId(), NodeTypeEnum.Service, false);
assertTrue(counter.isLeft());
assertEquals(new Integer(1), (Integer) counter.left().value());
- counter = serviceOperation.increaseAndGetComponentInstanceCounter(serviceAfterSave.getUniqueId(),
- NodeTypeEnum.Service, false);
+ counter = serviceOperation.increaseAndGetComponentInstanceCounter(serviceAfterSave.getUniqueId(), NodeTypeEnum.Service, false);
assertTrue(counter.isLeft());
assertEquals(new Integer(2), (Integer) counter.left().value());
- Either<Service, StorageOperationStatus> serviceDelete = serviceOperation
- .deleteService(serviceAfterSave.getUniqueId());
+ Either<Service, StorageOperationStatus> serviceDelete = serviceOperation.deleteService(serviceAfterSave.getUniqueId());
}
@Test
@@ -288,8 +281,7 @@ public class ServiceOperationTest extends ModelTestBase {
Either<Service, StorageOperationStatus> serviceDelete = serviceOperation.deleteService(serviceId);
- Either<List<ArtifactData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef,
- null, ArtifactData.class);
+ Either<List<ArtifactData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef, null, ArtifactData.class);
assertTrue(byCriteria.isRight());
assertEquals(TitanOperationStatus.NOT_FOUND, byCriteria.right().value());
@@ -312,13 +304,11 @@ public class ServiceOperationTest extends ModelTestBase {
artifactInfo.setCreatorFullName(fullName);
artifactInfo.setCreationDate(time);
artifactInfo.setLastUpdateDate(time);
-
artifactInfo.setUserIdLastUpdater(userId);
artifactInfo.setArtifactLabel(artifactName);
artifactInfo.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(serviceId, artifactInfo.getArtifactLabel()));
- Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation
- .addArifactToComponent(artifactInfo, serviceId, NodeTypeEnum.Service, true, true);
+ Either<ArtifactDefinition, StorageOperationStatus> artifact = artifactOperation.addArifactToComponent(artifactInfo, serviceId, NodeTypeEnum.Service, true, true);
assertTrue(artifact.isLeft());
return artifactInfo;
}
@@ -338,8 +328,7 @@ public class ServiceOperationTest extends ModelTestBase {
Set<LifecycleStateEnum> lastStateStates = new HashSet<LifecycleStateEnum>();
lastStateStates.add(LifecycleStateEnum.CERTIFIED);
- Either<List<Service>, StorageOperationStatus> followed = serviceOperation.getFollowed(userId, lifecycleStates,
- lastStateStates, false);
+ Either<List<Service>, StorageOperationStatus> followed = serviceOperation.getFollowed(userId, lifecycleStates, lastStateStates, false);
assertTrue(followed.isLeft());
List<Service> list = followed.left().value();
assertEquals(1, list.size());
@@ -369,8 +358,7 @@ public class ServiceOperationTest extends ModelTestBase {
}
- public Service createService(String userId, String category, String serviceName, String serviceVersion,
- boolean isHighestVersion) {
+ public Service createService(String userId, String category, String serviceName, String serviceVersion, boolean isHighestVersion) {
Service service = buildServiceMetadata(userId, category, serviceName, serviceVersion);
@@ -385,8 +373,7 @@ public class ServiceOperationTest extends ModelTestBase {
// assertEquals("check resource unique id",
// UniqueIdBuilder.buildServiceUniqueId(serviceName, serviceVersion),
// resultService.getUniqueId());
- assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT,
- resultService.getLifecycleState());
+ assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultService.getLifecycleState());
return resultService;
}
@@ -395,11 +382,6 @@ public class ServiceOperationTest extends ModelTestBase {
public void testCloneFullService() {
// try{
String userId = USER_ID;
- // Either<Service, StorageOperationStatus> deleteService =
- // serviceOperation.deleteService(UniqueIdBuilder.buildServiceUniqueId("my-service",
- // "1.0"), false);
- // log.info("testCloneFullService - after delete service. result
- // is="+deleteService);
Service origService = createService(userId, CATEGORY_NAME, "my-service", "1.0", true);
// add artifacts
@@ -408,12 +390,10 @@ public class ServiceOperationTest extends ModelTestBase {
// add resource instances
ResourceInstanceOperationTest riTest = new ResourceInstanceOperationTest();
- riTest.setOperations(titanDao, capabilityTypeOperation, requirementOperation, capabilityOperation,
- resourceOperation, propertyOperation, resourceInstanceOperation);
+ riTest.setOperations(titanDao, capabilityTypeOperation, requirementOperation, capabilityOperation, resourceOperation, propertyOperation, resourceInstanceOperation);
riTest.addResourceInstancesAndRelation(origService.getUniqueId());
- Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(),
- false);
+ Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(), false);
assertTrue(service2.isLeft());
origService = service2.left().value();
@@ -423,16 +403,13 @@ public class ServiceOperationTest extends ModelTestBase {
Service fullService = origService;
- Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0",
- false);
+ Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0", false);
assertTrue(createService.isLeft());
- Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation
- .getServiceByNameAndVersion("my-service", "2.0", null, false);
+ Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation.getServiceByNameAndVersion("my-service", "2.0", null, false);
assertTrue(serviceAfterCreate.isLeft());
fullService = serviceAfterCreate.left().value();
- Either<Service, StorageOperationStatus> getOrigService = serviceOperation
- .getServiceByNameAndVersion("my-service", "1.0", null, false);
+ Either<Service, StorageOperationStatus> getOrigService = serviceOperation.getServiceByNameAndVersion("my-service", "1.0", null, false);
assertTrue(getOrigService.isLeft());
origService = getOrigService.left().value();
@@ -440,8 +417,7 @@ public class ServiceOperationTest extends ModelTestBase {
// fullService.getComponentMetadataDefinition());
assertEquals(origService.getArtifacts().size(), fullService.getArtifacts().size());
assertEquals(origService.getComponentInstances().size(), fullService.getComponentInstances().size());
- assertEquals(origService.getComponentInstancesRelations().size(),
- fullService.getComponentInstancesRelations().size());
+ assertEquals(origService.getComponentInstancesRelations().size(), fullService.getComponentInstancesRelations().size());
origService.setUniqueId(fullService.getUniqueId());
origService.setVersion(fullService.getVersion());
@@ -469,21 +445,14 @@ public class ServiceOperationTest extends ModelTestBase {
// @Test
public void testCloneServiceWithoutResourceInstances() {
- // try{
String userId = USER_ID;
- // Either<Service, StorageOperationStatus> deleteService =
- // serviceOperation.deleteService(UniqueIdBuilder.buildServiceUniqueId("my-service",
- // "1.0"), false);
- // log.info("testCloneServiceWithoutResourceInstances - after delete
- // service. result is="+deleteService);
Service origService = createService(userId, CATEGORY_NAME, "my-service", "1.0", true);
// add artifacts
addArtifactToService(userId, origService.getUniqueId(), "install_apache");
addArtifactToService(userId, origService.getUniqueId(), "start_apache");
- Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(),
- false);
+ Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(), false);
assertTrue(service2.isLeft());
origService = service2.left().value();
@@ -493,16 +462,13 @@ public class ServiceOperationTest extends ModelTestBase {
Service fullService = origService;
- Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0",
- false);
+ Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0", false);
assertTrue(createService.isLeft());
- Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation
- .getServiceByNameAndVersion("my-service", "2.0", null, false);
+ Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation.getServiceByNameAndVersion("my-service", "2.0", null, false);
assertTrue(serviceAfterCreate.isLeft());
fullService = serviceAfterCreate.left().value();
- Either<Service, StorageOperationStatus> getOrigService = serviceOperation
- .getServiceByNameAndVersion("my-service", "1.0", null, false);
+ Either<Service, StorageOperationStatus> getOrigService = serviceOperation.getServiceByNameAndVersion("my-service", "1.0", null, false);
assertTrue(getOrigService.isLeft());
origService = getOrigService.left().value();
@@ -528,20 +494,15 @@ public class ServiceOperationTest extends ModelTestBase {
// @Test
public void testCloneServiceWithoutArtifacts() {
- // try{
-
String userId = USER_ID;
-
Service origService = createService(userId, CATEGORY_NAME, "my-service", "1.0", true);
// add resource instances
ResourceInstanceOperationTest riTest = new ResourceInstanceOperationTest();
- riTest.setOperations(titanDao, capabilityTypeOperation, requirementOperation, capabilityOperation,
- resourceOperation, propertyOperation, resourceInstanceOperation);
+ riTest.setOperations(titanDao, capabilityTypeOperation, requirementOperation, capabilityOperation, resourceOperation, propertyOperation, resourceInstanceOperation);
riTest.addResourceInstancesAndRelation(origService.getUniqueId());
- Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(),
- false);
+ Either<Service, StorageOperationStatus> service2 = serviceOperation.getService(origService.getUniqueId(), false);
assertTrue(service2.isLeft());
origService = service2.left().value();
@@ -551,23 +512,19 @@ public class ServiceOperationTest extends ModelTestBase {
Service fullService = origService;
- Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0",
- false);
+ Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0", false);
assertTrue(createService.isLeft());
- Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation
- .getServiceByNameAndVersion("my-service", "2.0", null, false);
+ Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation.getServiceByNameAndVersion("my-service", "2.0", null, false);
assertTrue(serviceAfterCreate.isLeft());
fullService = serviceAfterCreate.left().value();
- Either<Service, StorageOperationStatus> getOrigService = serviceOperation
- .getServiceByNameAndVersion("my-service", "1.0", null, false);
+ Either<Service, StorageOperationStatus> getOrigService = serviceOperation.getServiceByNameAndVersion("my-service", "1.0", null, false);
assertTrue(getOrigService.isLeft());
origService = getOrigService.left().value();
assertEquals(origService.getArtifacts(), fullService.getArtifacts());
assertEquals(origService.getComponentInstances().size(), fullService.getComponentInstances().size());
- assertEquals(origService.getComponentInstancesRelations().size(),
- fullService.getComponentInstancesRelations().size());
+ assertEquals(origService.getComponentInstancesRelations().size(), fullService.getComponentInstancesRelations().size());
origService.setUniqueId(fullService.getUniqueId());
origService.setVersion(fullService.getVersion());
@@ -585,16 +542,9 @@ public class ServiceOperationTest extends ModelTestBase {
// @Test
public void testCloneServiceSimple() {
- // try{
String userId = USER_ID;
String serviceName = "serviceToClone";
- //
- // Either<Service, StorageOperationStatus> deleteService =
- // serviceOperation.deleteService(UniqueIdBuilder.buildServiceUniqueId(serviceName,
- // "1.0"));
- // log.info("testCloneServiceSimple - after delete service. result
- // is="+deleteService);
-
+
Service origService = createService(userId, CATEGORY_NAME, serviceName, "1.0", true);
Gson prettyGson = new GsonBuilder().setPrettyPrinting().create();
@@ -603,16 +553,13 @@ public class ServiceOperationTest extends ModelTestBase {
Service fullService = origService;
- Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0",
- false);
+ Either<Service, StorageOperationStatus> createService = serviceOperation.cloneService(fullService, "2.0", false);
assertTrue(createService.isLeft());
- Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation
- .getServiceByNameAndVersion(serviceName, "2.0", null, false);
+ Either<Service, StorageOperationStatus> serviceAfterCreate = serviceOperation.getServiceByNameAndVersion(serviceName, "2.0", null, false);
assertTrue(serviceAfterCreate.isLeft());
fullService = serviceAfterCreate.left().value();
- Either<Service, StorageOperationStatus> getOrigService = serviceOperation
- .getServiceByNameAndVersion(serviceName, "1.0", null, false);
+ Either<Service, StorageOperationStatus> getOrigService = serviceOperation.getServiceByNameAndVersion(serviceName, "1.0", null, false);
assertTrue(getOrigService.isLeft());
origService = getOrigService.left().value();
@@ -665,13 +612,9 @@ public class ServiceOperationTest extends ModelTestBase {
OperationTestsUtil.deleteAndCreateResourceCategory(names[0], names[1], titanDao);
/*
- * CategoryData categoryData = new CategoryData();
- * categoryData.setName(category);
+ * CategoryData categoryData = new CategoryData(); categoryData.setName(category);
*
- * titanDao.deleteNode(categoryData, CategoryData.class);
- * Either<CategoryData, TitanOperationStatus> createNode =
- * titanDao.createNode(categoryData, CategoryData.class);
- * System.out.println("after creating caetgory " + createNode);
+ * titanDao.deleteNode(categoryData, CategoryData.class); Either<CategoryData, TitanOperationStatus> createNode = titanDao.createNode(categoryData, CategoryData.class); System.out.println("after creating caetgory " + createNode);
*/
}
@@ -707,8 +650,7 @@ public class ServiceOperationTest extends ModelTestBase {
Map<String, Object> propertiesToMatch = new HashMap<>();
propertiesToMatch.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFIED.name());
- Either<Set<Service>, StorageOperationStatus> catalog = serviceOperation.getCatalogData(propertiesToMatch,
- false);
+ Either<Set<Service>, StorageOperationStatus> catalog = serviceOperation.getCatalogData(propertiesToMatch, false);
assertTrue(catalog.isLeft());
Set<Service> catalogSet = catalog.left().value();
Set<String> idSet = new HashSet<>();
@@ -770,22 +712,19 @@ public class ServiceOperationTest extends ModelTestBase {
String serviceId3 = resultService3.getUniqueId();
// update 1 service to READY_FOR_CERTIFICATION
- Either<? extends Component, StorageOperationStatus> certReqResponse = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> certReqResponse = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
Service RFCService = (Service) certReqResponse.left().value();
assertEquals(RFCService.getLifecycleState(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
// update 1 service to CERTIFICATION_IN_PROGRESS
- Either<? extends Component, StorageOperationStatus> startCertificationResponse = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService2, testerUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResponse = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService2, testerUser, adminUser, false);
Service IPService = (Service) startCertificationResponse.left().value();
assertEquals(IPService.getLifecycleState(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
Set<LifecycleStateEnum> lifecycleStates = new HashSet<LifecycleStateEnum>();
lifecycleStates.add(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
- Either<List<Service>, StorageOperationStatus> services = serviceOperation.getTesterFollowed(testerUserId,
- lifecycleStates, false);
+ Either<List<Service>, StorageOperationStatus> services = serviceOperation.getTesterFollowed(testerUserId, lifecycleStates, false);
assertTrue(services.isLeft());
List<Service> result = services.left().value();
@@ -830,42 +769,31 @@ public class ServiceOperationTest extends ModelTestBase {
String serviceId4 = resultService4.getUniqueId();
// update 1 service to CERTIFIED dist status DISTRIBUTED
- Either<? extends Component, StorageOperationStatus> reqCertificationResult = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
- Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> reqCertificationResult = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
Service actualService = (Service) startCertificationResult.left().value();
- Either<? extends Component, StorageOperationStatus> certResponse = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> certResponse = lifecycleOperation.certifyComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
Service certifiedService = (Service) certResponse.left().value();
serviceOperation.updateDestributionStatus(resultService, adminUser, DistributionStatusEnum.DISTRIBUTED);
// update 1 service to CERTIFIED dist status DISTRIBUTION_APPROVED
- Either<? extends Component, StorageOperationStatus> reqCertificationResult2 = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
- Either<? extends Component, StorageOperationStatus> startCertificationResult2 = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> reqCertificationResult2 = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult2 = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
Service actualService2 = (Service) startCertificationResult2.left().value();
- Either<? extends Component, StorageOperationStatus> certResponse2 = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> certResponse2 = lifecycleOperation.certifyComponent(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
Service certifiedService2 = (Service) certResponse2.left().value();
- serviceOperation.updateDestributionStatus(resultService2, adminUser,
- DistributionStatusEnum.DISTRIBUTION_APPROVED);
+ serviceOperation.updateDestributionStatus(resultService2, adminUser, DistributionStatusEnum.DISTRIBUTION_APPROVED);
// update 1 service to CERTIFIED dist status DISTRIBUTION_REJECTED
- Either<? extends Component, StorageOperationStatus> reqCertificationResult3 = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService3, adminUser, adminUser, false);
- Either<? extends Component, StorageOperationStatus> startCertificationResult3 = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService3, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> reqCertificationResult3 = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService3, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult3 = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService3, adminUser, adminUser, false);
Service actualService3 = (Service) startCertificationResult3.left().value();
- Either<? extends Component, StorageOperationStatus> certResponse3 = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Service, actualService3, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> certResponse3 = lifecycleOperation.certifyComponent(NodeTypeEnum.Service, actualService3, adminUser, adminUser, false);
Service certifiedService3 = (Service) certResponse3.left().value();
- serviceOperation.updateDestributionStatus(certifiedService3, adminUser,
- DistributionStatusEnum.DISTRIBUTION_REJECTED);
+ serviceOperation.updateDestributionStatus(certifiedService3, adminUser, DistributionStatusEnum.DISTRIBUTION_REJECTED);
Map<String, Object> propertiesToMatch = new HashMap<>();
propertiesToMatch.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFIED.name());
@@ -874,8 +802,7 @@ public class ServiceOperationTest extends ModelTestBase {
distStatus.add(DistributionStatusEnum.DISTRIBUTION_APPROVED);
distStatus.add(DistributionStatusEnum.DISTRIBUTED);
- Either<Set<Service>, StorageOperationStatus> services = serviceOperation
- .getCertifiedServicesWithDistStatus(propertiesToMatch, distStatus, false);
+ Either<Set<Service>, StorageOperationStatus> services = serviceOperation.getCertifiedServicesWithDistStatus(propertiesToMatch, distStatus, false);
assertTrue(services.isLeft());
Set<Service> result = services.left().value();
@@ -917,34 +844,27 @@ public class ServiceOperationTest extends ModelTestBase {
String serviceId3 = resultService3.getUniqueId();
// update 1 service to CERTIFIED + DISTRIBUTED
- Either<? extends Component, StorageOperationStatus> reqCertificationResult = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
- Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> reqCertificationResult = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService, adminUser, adminUser, false);
Service actualService = (Service) startCertificationResult.left().value();
- Either<? extends Component, StorageOperationStatus> certResponse = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Service, actualService, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> certResponse = lifecycleOperation.certifyComponent(NodeTypeEnum.Service, actualService, adminUser, adminUser, false);
Service certifiedService = (Service) certResponse.left().value();
serviceOperation.updateDestributionStatus(certifiedService, adminUser, DistributionStatusEnum.DISTRIBUTED);
// update 1 service to CERTIFIED dist status + DISTRIBUTION_REJECTED
- Either<? extends Component, StorageOperationStatus> reqCertificationResult2 = lifecycleOperation
- .requestCertificationComponent(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
- Either<? extends Component, StorageOperationStatus> startCertificationResult2 = lifecycleOperation
- .startComponentCertification(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> reqCertificationResult2 = lifecycleOperation.requestCertificationComponent(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> startCertificationResult2 = lifecycleOperation.startComponentCertification(NodeTypeEnum.Service, resultService2, adminUser, adminUser, false);
Service actualService2 = (Service) startCertificationResult2.left().value();
- Either<? extends Component, StorageOperationStatus> certResponse2 = lifecycleOperation
- .certifyComponent(NodeTypeEnum.Service, actualService2, adminUser, adminUser, false);
+ Either<? extends Component, StorageOperationStatus> certResponse2 = lifecycleOperation.certifyComponent(NodeTypeEnum.Service, actualService2, adminUser, adminUser, false);
Service certifiedService2 = (Service) certResponse2.left().value();
serviceOperation.updateDestributionStatus(certifiedService2, adminUser, DistributionStatusEnum.DISTRIBUTED);
Map<String, Object> propertiesToMatch = new HashMap<>();
propertiesToMatch.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFIED.name());
- Either<Set<Service>, StorageOperationStatus> services = serviceOperation
- .getCertifiedServicesWithDistStatus(propertiesToMatch, null, false);
+ Either<Set<Service>, StorageOperationStatus> services = serviceOperation.getCertifiedServicesWithDistStatus(propertiesToMatch, null, false);
assertTrue(services.isLeft());
Set<Service> result = services.left().value();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaDefinitionPathCalculatorTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaDefinitionPathCalculatorTest.java
new file mode 100644
index 0000000000..9aa0842bb3
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaDefinitionPathCalculatorTest.java
@@ -0,0 +1,61 @@
+package org.openecomp.sdc.be.model.operations.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.operations.api.ToscaDefinitionPathCalculator;
+
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class ToscaDefinitionPathCalculatorTest {
+
+ private static final String INSTANCE_ID = "123";
+ private static final String OWNER_ID = "321";
+
+ private ToscaDefinitionPathCalculator toscaDefinitionPathCalculator;
+
+
+ @Before
+ public void setUp() throws Exception {
+ toscaDefinitionPathCalculator = new ToscaDefinitionPathCalculatorImpl();
+ }
+
+ @Test
+ public void calculatePath_ownerAndComponentInstanceEqual() throws Exception {
+ ComponentInstance instance = getComponentInstance(INSTANCE_ID);
+ GraphEdge edge = createEdgeWithOwner(INSTANCE_ID);
+ List<String> definitionPath = toscaDefinitionPathCalculator.calculateToscaDefinitionPath(instance, edge);
+ assertEquals(1, definitionPath.size());
+ assertEquals(INSTANCE_ID, definitionPath.get(0));
+ }
+
+ @Test
+ public void calculatePath() throws Exception {
+ ComponentInstance instance = getComponentInstance(INSTANCE_ID);
+ GraphEdge edge = createEdgeWithOwner(OWNER_ID);
+ List<String> definitionPath = toscaDefinitionPathCalculator.calculateToscaDefinitionPath(instance, edge);
+ assertEquals(2, definitionPath.size());
+ assertEquals(INSTANCE_ID, definitionPath.get(0));
+ assertEquals(OWNER_ID, definitionPath.get(1));
+
+ }
+
+
+ private ComponentInstance getComponentInstance(String instanceId) {
+ ComponentInstance instance = new ComponentInstance();
+ instance.setUniqueId(instanceId);
+ return instance;
+ }
+
+ private GraphEdge createEdgeWithOwner(String owner) {
+ GraphEdge edge = new GraphEdge();
+ edge.setProperties(Collections.singletonMap(GraphEdgePropertiesDictionary.OWNER_ID.getProperty(), owner));
+ return edge;
+ }
+
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java
new file mode 100644
index 0000000000..103d430009
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java
@@ -0,0 +1,579 @@
+package org.openecomp.sdc.be.model.operations.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.structure.io.IoCore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runner.RunWith;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.ModelTestBase;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+
+import org.openecomp.sdc.be.model.jsontitan.datamodel.NodeType;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.common.util.ValidationUtils;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanVertex;
+
+import fj.data.Either;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath:application-context-test.xml")
+public class ToscaElementLifecycleOperationTest extends ModelTestBase {
+
+ @javax.annotation.Resource
+ protected TitanDao titanDao;
+
+ @javax.annotation.Resource
+ private NodeTypeOperation nodeTypeOperation;
+
+ @javax.annotation.Resource
+ private TopologyTemplateOperation topologyTemplateOperation;
+
+ @javax.annotation.Resource
+ private ToscaElementLifecycleOperation lifecycleOperation;
+
+ String categoryName = "category";
+ String subcategory = "mycategory";
+ String outputDirectory = "C:\\Output";
+
+ @Rule
+ public TestName name = new TestName();
+
+ @BeforeClass
+ public static void initLifecycleOperation() {
+ ModelTestBase.init();
+ }
+
+ private GraphVertex ownerVertex;
+ private GraphVertex modifierVertex;
+ private GraphVertex vfVertex;
+ private GraphVertex serviceVertex;
+
+ @Before
+ public void setupBefore() {
+ clearGraph();
+ createUsers();
+ createResourceCategory();
+ createServiceCategory();
+ createRootNodeType();
+ createNodeType("firstVf");
+ createTopologyTemplate("firstService");
+ }
+
+
+ @Test
+ public void lifecycleTest() {
+ Either<ToscaElement, StorageOperationStatus> res = lifecycleOperation
+ .checkinToscaELement(LifecycleStateEnum.findState((String) vfVertex.getMetadataProperty(GraphPropertyEnum.STATE)),
+ vfVertex.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ StorageOperationStatus status;
+
+ assertTrue(res.isLeft());
+ String id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.checkoutToscaElement(id, ownerVertex.getUniqueId(), modifierVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ PropertyDataDefinition prop55 = new PropertyDataDefinition();
+ prop55.setName("prop55");
+ prop55.setDefaultValue("def55");
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop55, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ CapabilityDataDefinition cap1 = new CapabilityDataDefinition();
+ cap1.setName("cap1");
+ cap1.setDescription("create");
+ cap1.setUniqueId(UniqueIdBuilder.buildCapabilityUid(id, "cap1"));
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.CAPABILITIES, VertexTypeEnum.CAPABILTIES, cap1, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, id, ownerVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.checkoutToscaElement(id, ownerVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ prop55.setDefaultValue("AAAAAAAA");
+ status = nodeTypeOperation.updateToscaDataOfToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop55, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ cap1.setDescription("update");
+
+ status = nodeTypeOperation.updateToscaDataOfToscaElement(id, EdgeLabelEnum.CAPABILITIES, VertexTypeEnum.CAPABILTIES, cap1, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ PropertyDataDefinition prop66 = new PropertyDataDefinition();
+ prop66.setName("prop66");
+ prop66.setDefaultValue("def66");
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop66, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ res = lifecycleOperation.requestCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.certifyToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.checkoutToscaElement(id, ownerVertex.getUniqueId(), modifierVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ PropertyDataDefinition prop77 = new PropertyDataDefinition();
+ prop77.setName("prop77");
+ prop77.setDefaultValue("def77");
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop77, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, id, ownerVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.checkoutToscaElement(id, ownerVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ PropertyDataDefinition prop88 = new PropertyDataDefinition();
+ prop88.setName("prop88");
+ prop88.setDefaultValue("def88");
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop88, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ res = lifecycleOperation.requestCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.certifyToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.checkoutToscaElement(id, ownerVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ PropertyDataDefinition prop99 = new PropertyDataDefinition();
+ prop99.setName("prop99");
+ prop99.setDefaultValue("def99");
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop99, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ res = lifecycleOperation.requestCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ status = nodeTypeOperation.deleteToscaDataElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, "prop99", JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ //cancel certification
+ res = lifecycleOperation.cancelOrFailCertification(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId(), LifecycleStateEnum.READY_FOR_CERTIFICATION);
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ //fail certification
+ res = lifecycleOperation.cancelOrFailCertification(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ assertTrue(res.isLeft());
+ id = res.left().value().getUniqueId();
+
+ //exportGraphMl(titanDao.getGraph().left().value());
+
+ }
+
+ @Test
+ public void serviceConformanceLevelTest() {
+ Either<ToscaElement, StorageOperationStatus> res = lifecycleOperation
+ .checkinToscaELement(LifecycleStateEnum.findState((String) serviceVertex.getMetadataProperty(GraphPropertyEnum.STATE)),
+ serviceVertex.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId());
+
+ assertTrue(res.isLeft());
+ String id = res.left().value().getUniqueId();
+
+ res = lifecycleOperation.checkoutToscaElement(id, ownerVertex.getUniqueId(), modifierVertex.getUniqueId());
+ assertTrue(res.isLeft());
+
+ String conformanceLevel = res.left().value().getMetadataValue(JsonPresentationFields.CONFORMANCE_LEVEL).toString();
+ assertEquals(conformanceLevel, ModelTestBase.configurationManager.getConfiguration().getToscaConformanceLevel());
+ }
+
+ private void createResourceCategory() {
+
+ GraphVertex cat = new GraphVertex(VertexTypeEnum.RESOURCE_CATEGORY);
+ Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
+ String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.RESOURCE_CATEGORY);
+ cat.setUniqueId(catId);
+ metadataProperties.put(GraphPropertyEnum.UNIQUE_ID,catId);
+ metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_CATEGORY.getName());
+ metadataProperties.put(GraphPropertyEnum.NAME,categoryName);
+ metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
+ cat.setMetadataProperties(metadataProperties);
+ cat.updateMetadataJsonWithCurrentMetadataProperties();
+
+ GraphVertex subCat = new GraphVertex(VertexTypeEnum.RESOURCE_SUBCATEGORY);
+ metadataProperties = new HashMap<>();
+ String subCatId = UniqueIdBuilder.buildSubCategoryUid(cat.getUniqueId(), subcategory);
+ subCat.setUniqueId(subCatId);
+ metadataProperties.put(GraphPropertyEnum.UNIQUE_ID,subCatId);
+ metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_SUBCATEGORY.getName());
+ metadataProperties.put(GraphPropertyEnum.NAME,subcategory);
+ subCat.setMetadataProperties(metadataProperties);
+ subCat.updateMetadataJsonWithCurrentMetadataProperties();
+
+ Either<GraphVertex, TitanOperationStatus> catRes = titanDao.createVertex(cat);
+
+ Either<GraphVertex, TitanOperationStatus> subCatRes = titanDao.createVertex(subCat);
+
+ TitanOperationStatus status = titanDao.createEdge(catRes.left().value().getVertex(), subCatRes.left().value().getVertex(), EdgeLabelEnum.SUB_CATEGORY, new HashMap<>());
+ assertEquals(TitanOperationStatus.OK, status);
+ }
+
+ private void createServiceCategory() {
+
+ GraphVertex cat = new GraphVertex(VertexTypeEnum.SERVICE_CATEGORY);
+ Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
+ String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.SERVICE_CATEGORY);
+ cat.setUniqueId(catId);
+ metadataProperties.put(GraphPropertyEnum.UNIQUE_ID,catId);
+ metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.SERVICE_CATEGORY.getName());
+ metadataProperties.put(GraphPropertyEnum.NAME,categoryName);
+ metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
+ cat.setMetadataProperties(metadataProperties);
+ cat.updateMetadataJsonWithCurrentMetadataProperties();
+
+ Either<GraphVertex, TitanOperationStatus> catRes = titanDao.createVertex(cat);
+
+ assertTrue(catRes.isLeft());
+ }
+
+ private TopologyTemplate createTopologyTemplate(String name) {
+
+ TopologyTemplate service = new TopologyTemplate();
+ String uniqueId = UniqueIdBuilder.buildResourceUniqueId();
+ service.setUniqueId(uniqueId);
+ service.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
+ service.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), name);
+ service.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
+ service.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "0.1");
+ service.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(),ResourceTypeEnum.VF.name());
+ service.getMetadata().put(JsonPresentationFields.COMPONENT_TYPE.getPresentation(),ComponentTypeEnum.RESOURCE);
+ List<CategoryDefinition> categories = new ArrayList<>();
+ CategoryDefinition cat = new CategoryDefinition();
+ categories.add(cat);
+ cat.setName(categoryName);
+ service.setCategories(categories);
+
+ service.setComponentType(ComponentTypeEnum.SERVICE);
+ Either<TopologyTemplate, StorageOperationStatus> createRes = topologyTemplateOperation.createTopologyTemplate(service);
+ assertTrue(createRes.isLeft());
+
+ Either<GraphVertex, TitanOperationStatus> getNodeTyeRes= titanDao.getVertexById(createRes.left().value().getUniqueId());
+ assertTrue(getNodeTyeRes.isLeft());
+
+ serviceVertex = getNodeTyeRes.left().value();
+
+ return service;
+ }
+
+ private <T extends ToscaDataDefinition> NodeType createNodeType(String nodeTypeName) {
+
+ NodeType vf = new NodeType();
+ String uniqueId = UniqueIdBuilder.buildResourceUniqueId();
+ vf.setUniqueId(uniqueId);
+ vf.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
+ vf.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), nodeTypeName);
+ vf.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
+ vf.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "0.1");
+ vf.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(),ResourceTypeEnum.VF.name());
+ vf.getMetadata().put(JsonPresentationFields.COMPONENT_TYPE.getPresentation(),ComponentTypeEnum.RESOURCE);
+ List<CategoryDefinition> categories = new ArrayList<>();
+ CategoryDefinition cat = new CategoryDefinition();
+ categories.add(cat);
+ cat.setName(categoryName);
+ List<SubCategoryDefinition> subCategories = new ArrayList<>();
+ SubCategoryDefinition subCat = new SubCategoryDefinition();
+ subCat.setName(subcategory);
+ subCategories.add(subCat);
+ cat.setSubcategories(subCategories);
+ vf.setCategories(categories);
+
+
+ List<String> derivedFrom = new ArrayList<>();
+ derivedFrom.add("root");
+ vf.setDerivedFrom(derivedFrom);
+
+// Map<String, PropertyDataDefinition> properties = new HashMap<>();
+// PropertyDataDefinition prop1 = new PropertyDataDefinition();
+// prop1.setName("prop1");
+// prop1.setDefaultValue("def1");
+//
+// properties.put("prop1", prop1);
+//
+// PropertyDataDefinition prop2 = new PropertyDataDefinition();
+// prop2.setName("prop2");
+// prop2.setDefaultValue("def2");
+// properties.put("prop2", prop2);
+//
+// PropertyDataDefinition prop3 = new PropertyDataDefinition();
+// prop3.setName("prop3");
+// prop3.setDefaultValue("def3");
+// properties.put("prop3", prop3);
+//
+// vf.setProperties(properties);
+ vf.setComponentType(ComponentTypeEnum.RESOURCE);
+ Either<NodeType, StorageOperationStatus> createVFRes = nodeTypeOperation.createNodeType(vf);
+ assertTrue(createVFRes.isLeft());
+
+ Either<GraphVertex, TitanOperationStatus> getNodeTyeRes= titanDao.getVertexById(createVFRes.left().value().getUniqueId());
+ assertTrue(getNodeTyeRes.isLeft());
+
+ vfVertex = getNodeTyeRes.left().value();
+
+
+
+ List<PropertyDataDefinition> addProperties = new ArrayList<>();
+ PropertyDataDefinition prop11 = new PropertyDataDefinition();
+ prop11.setName("prop11");
+ prop11.setDefaultValue("def11");
+
+ addProperties.add(prop11);
+
+ PropertyDataDefinition prop22 = new PropertyDataDefinition();
+ prop22.setName("prop22");
+ prop22.setDefaultValue("def22");
+ addProperties.add(prop22);
+
+ StorageOperationStatus status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, addProperties, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ PropertyDataDefinition prop33 = new PropertyDataDefinition();
+ prop33.setName("prop33");
+ prop33.setDefaultValue("def33");
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop33, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+ PropertyDataDefinition prop44 = new PropertyDataDefinition();
+ prop44.setName("prop44");
+ prop44.setDefaultValue("def44");
+
+ status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop44, JsonPresentationFields.NAME);
+ assertTrue(status == StorageOperationStatus.OK);
+
+
+ PropertyDataDefinition capProp = new PropertyDataDefinition();
+ capProp.setName( "capProp");
+ capProp.setDefaultValue( "capPropDef");
+
+ MapDataDefinition dataToCreate = new MapPropertiesDataDefinition();
+ dataToCreate.put("capProp", capProp);
+
+ Map<String, MapDataDefinition> capProps = new HashMap();
+ capProps.put("capName", dataToCreate);
+
+ Either<GraphVertex, StorageOperationStatus> res = nodeTypeOperation.assosiateElementToData(vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps);
+
+ // exportGraphMl(titanDao.getGraph().left().value());
+
+ List<String> pathKeys = new ArrayList<>();
+ pathKeys.add("capName");
+ capProp.setDefaultValue( "BBBB");
+ status = nodeTypeOperation.updateToscaDataDeepElementOfToscaElement(vfVertex, EdgeLabelEnum.CAPABILITIES_PROPERTIES, VertexTypeEnum.CAPABILITIES_PROPERTIES,
+ capProp, pathKeys, JsonPresentationFields.NAME);
+ return vf;
+ }
+
+ private void createRootNodeType() {
+
+ NodeType vf = new NodeType();
+ String uniqueId = UniqueIdBuilder.buildResourceUniqueId();
+ vf.setUniqueId(uniqueId);
+ vf.setComponentType(ComponentTypeEnum.RESOURCE);
+ vf.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
+ vf.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), "root");
+ vf.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
+ vf.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "1.0");
+ vf.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(),ResourceTypeEnum.VFC.name());
+ vf.getMetadata().put(JsonPresentationFields.LIFECYCLE_STATE.getPresentation(), LifecycleStateEnum.CERTIFIED.name());
+ vf.getMetadata().put(JsonPresentationFields.TOSCA_RESOURCE_NAME.getPresentation(), "root");
+ vf.getMetadata().put(JsonPresentationFields.HIGHEST_VERSION.getPresentation(), true);
+
+ List<CategoryDefinition> categories = new ArrayList<>();
+ CategoryDefinition cat = new CategoryDefinition();
+ categories.add(cat);
+ cat.setName(categoryName);
+ List<SubCategoryDefinition> subCategories = new ArrayList<>();
+ SubCategoryDefinition subCat = new SubCategoryDefinition();
+ subCat.setName(subcategory);
+ subCategories.add(subCat);
+ cat.setSubcategories(subCategories);
+ vf.setCategories(categories);
+
+
+ List<String> derivedFrom = new ArrayList<>();
+ vf.setDerivedFrom(derivedFrom);
+
+ Map<String, PropertyDataDefinition> properties = new HashMap<>();
+ PropertyDataDefinition prop1 = new PropertyDataDefinition();
+ prop1.setName("derived1");
+ prop1.setDefaultValue("deriveddef1");
+
+ properties.put("derived1", prop1);
+
+ PropertyDataDefinition prop2 = new PropertyDataDefinition();
+ prop2.setUniqueId("derived2");
+ prop2.setName("deriveddef2");
+ properties.put("derived2", prop2);
+
+ PropertyDataDefinition prop3 = new PropertyDataDefinition();
+ prop3.setName("derived3");
+ prop3.setDefaultValue("deriveddef3");
+ properties.put("derived3", prop3);
+
+ vf.setProperties(properties);
+ vf.setComponentType(ComponentTypeEnum.RESOURCE);
+ Either<NodeType, StorageOperationStatus> createVFRes = nodeTypeOperation.createNodeType(vf);
+ assertTrue(createVFRes.isLeft());
+
+ Either<GraphVertex, TitanOperationStatus> getNodeTyeRes= titanDao.getVertexById(createVFRes.left().value().getUniqueId());
+ assertTrue(getNodeTyeRes.isLeft());
+ }
+
+ private void createUsers() {
+
+ GraphVertex ownerV = new GraphVertex(VertexTypeEnum.USER);
+ ownerV.setUniqueId("user1");
+
+ Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
+ metadataProperties.put(GraphPropertyEnum.USERID, ownerV.getUniqueId());
+ metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.USER.getName());
+ metadataProperties.put(GraphPropertyEnum.NAME, "user1");
+ ownerV.setMetadataProperties(metadataProperties);
+ ownerV.updateMetadataJsonWithCurrentMetadataProperties();
+ ownerV.setJson(new HashMap<>());
+ Either<GraphVertex, TitanOperationStatus> createUserRes = titanDao.createVertex(ownerV);
+ assertTrue(createUserRes.isLeft());
+
+ ownerVertex = createUserRes.left().value();
+
+ GraphVertex modifierV = new GraphVertex(VertexTypeEnum.USER);
+ modifierV.setUniqueId("user2");
+
+ metadataProperties = new HashMap<>();
+ metadataProperties.put(GraphPropertyEnum.USERID, modifierV.getUniqueId());
+ metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.USER.getName());
+ metadataProperties.put(GraphPropertyEnum.NAME, "user2");
+ modifierV.setMetadataProperties(metadataProperties);
+ modifierV.updateMetadataJsonWithCurrentMetadataProperties();
+ modifierV.setJson(new HashMap<>());
+ createUserRes = titanDao.createVertex(modifierV);
+ assertTrue(createUserRes.isLeft());
+
+ modifierVertex = createUserRes.left().value();
+
+ Either<GraphVertex, TitanOperationStatus> getOwnerRes = lifecycleOperation.findUser(ownerVertex.getUniqueId());
+ assertTrue(getOwnerRes.isLeft());
+
+ }
+
+ @After
+ public void teardown() {
+ clearGraph();
+ }
+
+ private void clearGraph() {
+ Either<TitanGraph, TitanOperationStatus> graphResult = titanDao.getGraph();
+ TitanGraph graph = graphResult.left().value();
+
+ Iterable<TitanVertex> vertices = graph.query().vertices();
+ if (vertices != null) {
+ Iterator<TitanVertex> iterator = vertices.iterator();
+ while (iterator.hasNext()) {
+ TitanVertex vertex = iterator.next();
+ vertex.remove();
+ }
+ }
+ titanDao.commit();
+ }
+
+ private String exportGraphMl(TitanGraph graph) {
+ String result = null;
+ String outputFile = outputDirectory + File.separator + "exportGraph." + System.currentTimeMillis() + ".graphml";
+ try {
+ try (final OutputStream os = new BufferedOutputStream(new FileOutputStream(outputFile))) {
+ graph.io(IoCore.graphml()).writer().normalize(true).create().writeGraph(os, graph);
+ }
+ result = outputFile;
+ graph.tx().commit();
+ } catch (Exception e) {
+ graph.tx().rollback();
+ e.printStackTrace();
+ }
+ return result;
+
+ }
+
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java
index f77e477ed7..ed496b5e92 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java
@@ -20,6 +20,8 @@
package org.openecomp.sdc.be.model.operations.impl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -27,7 +29,11 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.temporal.TemporalField;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -61,10 +67,9 @@ import org.openecomp.sdc.common.api.UserRoleEnum;
import fj.data.Either;
public class UserAdminOperationTest extends ModelTestBase {
- @InjectMocks
- private static final UserAdminOperation userAdminOperation = new UserAdminOperation();
private static final TitanGenericDao titanGenericDao = mock(TitanGenericDao.class);
-
+ @InjectMocks
+ private static final UserAdminOperation userAdminOperation = new UserAdminOperation(titanGenericDao);
private static final String ADMIN = "admin";
@BeforeClass
@@ -85,8 +90,7 @@ public class UserAdminOperationTest extends ModelTestBase {
public void testDeActivateUserDataSuccess() {
UserData userData = mockTitanGet(ADMIN, UserRoleEnum.ADMIN, true);
- Either<User, StorageOperationStatus> eitherUser = userAdminOperation
- .deActivateUser(userAdminOperation.convertToUser(userData));
+ Either<User, StorageOperationStatus> eitherUser = userAdminOperation.deActivateUser(userAdminOperation.convertToUser(userData));
verify(titanGenericDao, times(1)).updateNode(Mockito.eq(userData), Mockito.eq(UserData.class));
verify(titanGenericDao, times(0)).deleteNode(Mockito.any(UserData.class), Mockito.eq(UserData.class));
@@ -97,24 +101,32 @@ public class UserAdminOperationTest extends ModelTestBase {
}
/*
- * @Test public void testDeActivateUserDataFail(){ UserData userData =
- * mockTitanGet(ADMIN, UserRoleEnum.ADMIN, false);
+ * @Test public void testDeActivateUserDataFail(){ UserData userData = mockTitanGet(ADMIN, UserRoleEnum.ADMIN, false);
*
- * Either<User, StorageOperationStatus> eitherUser =
- * userAdminOperation.deActivateUser(userAdminOperation.convertToUser(
- * userData));
+ * Either<User, StorageOperationStatus> eitherUser = userAdminOperation.deActivateUser(userAdminOperation.convertToUser( userData));
*
- * verify(titanGenericDao, times(0)).updateNode(Mockito.any(UserData.class),
- * Mockito.eq(UserData.class)); verify(titanGenericDao,
- * times(0)).deleteNode(Mockito.any(UserData.class),
- * Mockito.eq(UserData.class)); assertTrue(eitherUser.isRight());
- * assertTrue(eitherUser.right().value() ==
- * StorageOperationStatus.USER_INACTIVE);
+ * verify(titanGenericDao, times(0)).updateNode(Mockito.any(UserData.class), Mockito.eq(UserData.class)); verify(titanGenericDao, times(0)).deleteNode(Mockito.any(UserData.class), Mockito.eq(UserData.class)); assertTrue(eitherUser.isRight());
+ * assertTrue(eitherUser.right().value() == StorageOperationStatus.USER_INACTIVE);
*
* }
*/
@Test
+ public void testGetAllUsers() throws Exception {
+ UserData user1 = mockTitanGet("user1", UserRoleEnum.ADMIN, true);
+ UserData user2 = mockTitanGet("user2", UserRoleEnum.DESIGNER, false);
+ UserData user3 = mockTitanGet("user3", UserRoleEnum.PRODUCT_MANAGER, true);
+ when(titanGenericDao.getAll(NodeTypeEnum.User, UserData.class)).thenReturn(Either.left(Arrays.asList(user1, user2, user3)));
+
+ List<User> allUsers = userAdminOperation.getAllUsers().left().value();
+ assertEquals(3, allUsers.size());
+ assertUserEquals(user1, allUsers.get(0));
+ assertUserEquals(user2, allUsers.get(1));
+ assertUserEquals(user3, allUsers.get(2));
+ verify(titanGenericDao).commit();
+ }
+
+ @Test
public void testDeleteUserWithoutResources() {
UserData userData = mockTitanGet(ADMIN, UserRoleEnum.ADMIN, true);
@@ -199,8 +211,7 @@ public class UserAdminOperationTest extends ModelTestBase {
private UserData mockTitanGet(String userId, UserRoleEnum role, boolean isActive) {
UserData userData = buildUserData(userId, role, isActive);
Either<UserData, TitanOperationStatus> eitherUserData = Either.left(userData);
- when(titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), userId, UserData.class))
- .thenReturn(eitherUserData);
+ when(titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), userId, UserData.class)).thenReturn(eitherUserData);
return userData;
}
@@ -228,12 +239,25 @@ public class UserAdminOperationTest extends ModelTestBase {
}).when(titanGenericDao).deleteNode(Mockito.any(UserData.class), Mockito.eq(UserData.class));
}
+ private void assertUserEquals(UserData expected, User actual) {
+ assertEquals(expected.getEmail(), actual.getEmail());
+ assertEquals(expected.getFirstName(), actual.getFirstName());
+ assertEquals(expected.getLastName(), actual.getLastName());
+ assertEquals(expected.getRole(), actual.getRole());
+ assertEquals(expected.getStatus(), actual.getStatus().name());
+ assertEquals(expected.getUserId(), actual.getUserId());
+
+ }
+
private static UserData buildUserData(String userId, UserRoleEnum role, boolean isActive) {
UserData userData = new UserData();
userData.setUserId(userId);
userData.setRole(role.getName());
+ userData.setEmail("someEmail@somePlace.com");
+ userData.setFirstName("israel");
+ userData.setLastName("israeli");
+ userData.setLastLoginTime(Instant.MIN.getEpochSecond());
userData.setStatus(isActive ? UserStatusEnum.ACTIVE.name() : UserStatusEnum.INACTIVE.name());
return userData;
-
}
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java
index b58ce5598d..4b89f457bb 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java
@@ -316,7 +316,7 @@ public class PrintGraph {
switch (typeEnum) {
case User:
- uid = (String) properties.get(GraphPropertiesDictionary.USER_ID.getProperty());
+ uid = (String) properties.get(GraphPropertiesDictionary.USERID.getProperty());
break;
case ServiceCategory:
case ResourceCategory:
diff --git a/catalog-model/src/test/resources/application-context-test.xml b/catalog-model/src/test/resources/application-context-test.xml
index 43f4b088e4..58de573b55 100644
--- a/catalog-model/src/test/resources/application-context-test.xml
+++ b/catalog-model/src/test/resources/application-context-test.xml
@@ -8,6 +8,8 @@
<context:component-scan
base-package="org.openecomp.sdc.be.model.operations.impl,
+ org.openecomp.sdc.be.model.jsontitan.operations,
+ org.openecomp.sdc.be.dao.jsongraph,
org.openecomp.sdc.be.model.cache,
org.openecomp.sdc.be.dao.titan,
org.openecomp.sdc.be.dao.cassandra">