diff options
author | priyanshu <pagarwal@amdocs.com> | 2018-09-05 18:05:36 +0530 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-09-13 13:00:27 +0000 |
commit | b65c8eeb334a2c579a2dc0241f480d81e9309f9c (patch) | |
tree | b3b3ed06b53703f771da51bec4b40e71b9e1bd1d /catalog-model/src/test/java/org/openecomp | |
parent | f1e032cf4ae3505eb8acbce56ac978649d6f63d4 (diff) |
Interface operation support for service - BE
1. Interface operation support for service
2. Refactored common code of operationspa
3. ONAP Bug fixes VF operations
Change-Id: If1c4fd5f17626dbe568ee66ad997eb8ffb772e29
Issue-ID: SDC-1739
Signed-off-by: priyanshu <pagarwal@amdocs.com>
Diffstat (limited to 'catalog-model/src/test/java/org/openecomp')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfacesOperationTest.java | 294 |
1 files changed, 152 insertions, 142 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfacesOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfacesOperationTest.java index f2aefa0aa3..375208d24e 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfacesOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfacesOperationTest.java @@ -1,15 +1,25 @@ package org.openecomp.sdc.be.model.jsontitan.operations; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanVertex; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import fj.data.Either; -import org.junit.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; 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.TitanGraphClient; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition; @@ -19,145 +29,180 @@ 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.*; +import org.openecomp.sdc.be.model.Component; +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.Service; 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.utils.GraphTestUtils; -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.UniqueIdBuilder; import org.openecomp.sdc.common.util.ValidationUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import javax.annotation.Resource; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.util.*; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:application-context-test.xml") -public class InterfacesOperationTest extends ModelTestBase{ +public class InterfacesOperationTest extends ModelTestBase { @Resource protected TitanDao titanDao; + @Resource private InterfaceOperation interfaceOperation; - @Autowired - protected TitanGraphClient titanGraphClient; - @Resource protected NodeTypeOperation nodeTypeOperation; - @Autowired - protected ToscaOperationFacade toscaOperationFacade; @Resource protected TopologyTemplateOperation topologyTemplateOperation; - @Autowired - protected IElementOperation elementDao; - @Resource private ToscaElementLifecycleOperation lifecycleOperation; - protected static final String USER_ID = "jh0003"; - protected static final String VF_NAME = "VF_NAME"; - protected User user; + private static final String RESOURCE_NAME = "Resource Name"; + private static final String RESOURCE_ID = "resourceID"; - public static final String RESOURCE_CATEGORY = "Network Layer 2-3"; - public static final String RESOURCE_SUBCATEGORY = "Router"; - public static final String RESOURCE_NAME = "Resource Name"; + private static final String SERVICE_NAME = "Service Name"; + private static final String SERVICE_ID = "serviceID"; - private CategoryDefinition categoryDefinition; - private SubCategoryDefinition subCategoryDefinition = new SubCategoryDefinition(); - protected static final String RESOURCE_ID = "resourceID"; - protected static final String WORKFLOW_OPERATION_ID = "workflowOperationId"; - public static final String DERIVED_NAME = "derivedName"; - public static final String CSAR_UUID = "bla bla"; + private final String categoryName = "category"; + private final String subcategory = "mycategory"; + private GraphVertex ownerVertex; - String categoryName = "category"; - String subcategory = "mycategory"; - String outputDirectory = "C:\\Output"; + private final Service service = createService(); + private final org.openecomp.sdc.be.model.Resource resource = createResource(); @BeforeClass public static void initInterfacesOperation() { init(); } - private GraphVertex ownerVertex; - private GraphVertex modifierVertex; - private GraphVertex vfVertex; - private GraphVertex serviceVertex; - private GraphVertex rootVertex; - @Before public void setupBefore() { - clearGraph(); + GraphTestUtils.clearGraph(titanDao); createUsers(); createResourceCategory(); createServiceCategory(); GraphTestUtils.createRootCatalogVertex(titanDao); - rootVertex = createRootNodeType(); - createNodeType("firstVf"); - serviceVertex = createTopologyTemplate("firstService"); + createRootNodeType(); + createNodeType("resource", RESOURCE_ID); + createNodeType("service", SERVICE_ID); + createTopologyTemplate("firstService"); } @After public void cleanAfter() { - clearGraph(); + GraphTestUtils.clearGraph(titanDao); } @Test - public void testAddInterface() { - org.openecomp.sdc.be.model.Resource resource = createResource(); + public void testAddInterface_Service(){testAddInterface(service);} + + @Test + public void testAddInterface_Resource(){testAddInterface(resource);} + + @Test + public void testUpdateInterface_Service(){testUpdateInterface(service);} + + @Test + public void testUpdateInterface_Resource(){testUpdateInterface(resource);} + + @Test + public void testAddInterfaceOperation_Service(){testAddInterfaceOperation(service);} + + @Test + public void testAddInterfaceOperation_Resource(){testAddInterfaceOperation(resource);} + + @Test + public void testUpdateInterfaceOperation_Service(){testUpdateInterfaceOperation(service);} + + @Test + public void testUpdateInterfaceOperation_Resource(){testUpdateInterfaceOperation(resource);} + + @Test + public void testDeleteInterfaceOperation_Service(){testDeleteInterfaceOperation(service);} + + @Test + public void testDeleteInterfaceOperation_Resource(){testDeleteInterfaceOperation(resource);} + + @Test + public void testUpdateInterfaceShouldFailWhenNOtCreatedFirst() { + Component component = createResource(); InterfaceDefinition interfaceDefinition = buildInterfaceDefinition(); - Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(resource.getUniqueId(), + interfaceDefinition.setOperationsMap(createMockOperationMap()); + Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.updateInterface(component.getUniqueId(), + interfaceDefinition); + Assert.assertTrue(res.isRight()); + } + + private void testAddInterface(Component component) { + InterfaceDefinition interfaceDefinition = buildInterfaceDefinition(); + Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition); Assert.assertTrue(res.isLeft()); } - @Test - public void testUpdateInterface() { - org.openecomp.sdc.be.model.Resource resource = createResource(); + private void testUpdateInterface(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition(); interfaceDefinition.setOperationsMap(createMockOperationMap()); - Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(resource.getUniqueId(), - interfaceDefinition); + Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition); Assert.assertTrue(res.isLeft()); InterfaceDefinition value = res.left().value(); String new_description = "New Description"; value.setDescription(new_description); - res = interfaceOperation.updateInterface(resource.getUniqueId(), - interfaceDefinition); + res = interfaceOperation.updateInterface(component.getUniqueId(), interfaceDefinition); assertTrue(res.isLeft()); assertEquals(new_description,res.left().value().getDescription()); } - @Test - public void testUpdateInterfaceShouldFailWhenNOtCreatedFirst() { - org.openecomp.sdc.be.model.Resource resource = createResource(); + private void testAddInterfaceOperation(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition(); - interfaceDefinition.setOperationsMap(createMockOperationMap()); - Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.updateInterface(resource.getUniqueId(), - interfaceDefinition); - Assert.assertTrue(res.isRight()); + Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition); + Assert.assertTrue(res.isLeft()); + InterfaceDefinition value = res.left().value(); + Operation op = createMockOperation(); + Either<Operation, StorageOperationStatus> addInterfaceOperationRes = interfaceOperation.addInterfaceOperation(component.getUniqueId(), value, op); + assertTrue(addInterfaceOperationRes.isLeft()); + } + + private void testUpdateInterfaceOperation(Component component) { + InterfaceDefinition interfaceDefinition = buildInterfaceDefinition(); + Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition); + Assert.assertTrue(res.isLeft()); + InterfaceDefinition value = res.left().value(); + Operation op = createMockOperation(); + Either<Operation, StorageOperationStatus> addInterfaceOperationRes = interfaceOperation.addInterfaceOperation(component.getUniqueId(), value, op); + Assert.assertTrue(addInterfaceOperationRes.isLeft()); + Operation resultOp = addInterfaceOperationRes.left().value(); + resultOp.setName("New_Create"); + Either<Operation, StorageOperationStatus> updateInterfaceOperationRes = interfaceOperation.updateInterfaceOperation(component.getUniqueId(), value, resultOp); + assertTrue(updateInterfaceOperationRes.isLeft()); + assertEquals("New_Create", updateInterfaceOperationRes.left().value().getName()); + } + + private void testDeleteInterfaceOperation(Component component) { + InterfaceDefinition interfaceDefinition = buildInterfaceDefinition(); + Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition); + Assert.assertTrue(res.isLeft()); + InterfaceDefinition value = res.left().value(); + Operation op = createMockOperation(); + Either<Operation, StorageOperationStatus> addInterfaceOperationRes = interfaceOperation.addInterfaceOperation(component.getUniqueId(), value, op); + Assert.assertTrue(addInterfaceOperationRes.isLeft()); + Operation resultOp = addInterfaceOperationRes.left().value(); + Either<Operation, StorageOperationStatus> deleteInterfaceOperationRes = interfaceOperation.deleteInterfaceOperation(component.getUniqueId(), value, resultOp.getUniqueId()); + assertTrue(deleteInterfaceOperationRes.isLeft()); } private InterfaceDefinition buildInterfaceDefinition() { InterfaceDefinition interfaceDefinition = new InterfaceDefinition(); interfaceDefinition.setType("tosca.interfaces.standard"); - interfaceDefinition.setCreationDate(new Long(101232)); - - + interfaceDefinition.setCreationDate(101232L); return interfaceDefinition; } @@ -165,12 +210,19 @@ public class InterfacesOperationTest extends ModelTestBase{ org.openecomp.sdc.be.model.Resource resource = new org.openecomp.sdc.be.model.Resource(); resource.setUniqueId(RESOURCE_ID); resource.setName(RESOURCE_NAME); - resource.addCategory(RESOURCE_CATEGORY, RESOURCE_SUBCATEGORY); resource.setDescription("My short description"); resource.setInterfaces(createMockInterfaceDefinition()); return resource; } + private Service createService() { + Service service = new Service(); + service.setUniqueId(SERVICE_ID); + service.setName(SERVICE_NAME); + service.setDescription("My short description"); + service.setInterfaces(createMockInterfaceDefinition()); + return service; + } private InterfaceDefinition createInterface(String uniqueID, String description, String type, String toscaResourceName, Map<String, Operation> op) { @@ -188,24 +240,24 @@ public class InterfacesOperationTest extends ModelTestBase{ Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>(); interfaceDefinitionMap.put("int1", createInterface("int1", "Interface 1", "lifecycle", "tosca", operationMap)); - return interfaceDefinitionMap; } private Map<String, Operation> createMockOperationMap() { - Operation operation = new Operation(); - operation.setDefinition(false); - operation.setName("create"); Map<String, Operation> operationMap = new HashMap<>(); - operationMap.put("op1", operation); + operationMap.put("op1", createMockOperation()); return operationMap; } - - + private Operation createMockOperation() { + Operation operation = new Operation(); + operation.setDefinition(false); + operation.setName("create"); + operation.setUniqueId("op1"); + return operation; + } private void createResourceCategory() { - GraphVertex cat = new GraphVertex(VertexTypeEnum.RESOURCE_CATEGORY); Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>(); String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.RESOURCE_CATEGORY); @@ -229,15 +281,11 @@ public class InterfacesOperationTest extends ModelTestBase{ 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); + titanDao.createEdge(catRes.left().value().getVertex(), subCatRes.left().value().getVertex(), EdgeLabelEnum.SUB_CATEGORY, new HashMap<>()); } private void createServiceCategory() { - GraphVertex cat = new GraphVertex(VertexTypeEnum.SERVICE_CATEGORY); Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>(); String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.SERVICE_CATEGORY); @@ -248,14 +296,10 @@ public class InterfacesOperationTest extends ModelTestBase{ metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName)); cat.setMetadataProperties(metadataProperties); cat.updateMetadataJsonWithCurrentMetadataProperties(); - - Either<GraphVertex, TitanOperationStatus> catRes = titanDao.createVertex(cat); - - assertTrue(catRes.isLeft()); + titanDao.createVertex(cat); } - private GraphVertex createTopologyTemplate(String name) { - + private void createTopologyTemplate(String name) { TopologyTemplate service = new TopologyTemplate(); String uniqueId = UniqueIdBuilder.buildResourceUniqueId(); service.setUniqueId(uniqueId); @@ -273,20 +317,13 @@ public class InterfacesOperationTest extends ModelTestBase{ 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 getNodeTyeRes.left().value(); + getNodeTyeRes.left().value(); } - private <T extends ToscaDataDefinition> NodeType createNodeType(String nodeTypeName) { - + private <T extends ToscaDataDefinition> void createNodeType(String nodeTypeName, String uniqueId) { NodeType vf = new NodeType(); - String uniqueId = RESOURCE_ID; // UniqueIdBuilder.buildResourceUniqueId(); vf.setUniqueId(uniqueId); vf.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID)); vf.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), nodeTypeName); @@ -308,15 +345,13 @@ public class InterfacesOperationTest extends ModelTestBase{ List<String> derivedFrom = new ArrayList<>(); derivedFrom.add("root"); vf.setDerivedFrom(derivedFrom); - vf.setComponentType(ComponentTypeEnum.RESOURCE); + 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(); + GraphVertex vfVertex = getNodeTyeRes.left().value(); List<PropertyDataDefinition> addProperties = new ArrayList<>(); PropertyDataDefinition prop11 = new PropertyDataDefinition(); @@ -331,21 +366,21 @@ public class InterfacesOperationTest extends ModelTestBase{ addProperties.add(prop22); StorageOperationStatus status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, addProperties, JsonPresentationFields.NAME); - assertTrue(status == StorageOperationStatus.OK); + assertSame(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); + assertSame(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); + assertSame(status, StorageOperationStatus.OK); PropertyDataDefinition capProp = new PropertyDataDefinition(); capProp.setName("capProp"); @@ -354,20 +389,19 @@ public class InterfacesOperationTest extends ModelTestBase{ MapDataDefinition dataToCreate = new MapPropertiesDataDefinition(); dataToCreate.put("capProp", capProp); - Map<String, MapDataDefinition> capProps = new HashMap(); + Map<String, MapDataDefinition> capProps = new HashMap<>(); capProps.put("capName", dataToCreate); - Either<GraphVertex, StorageOperationStatus> res = nodeTypeOperation.associateElementToData(vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps); + nodeTypeOperation.associateElementToData( + vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps); 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; + nodeTypeOperation.updateToscaDataDeepElementOfToscaElement(vfVertex, EdgeLabelEnum.CAPABILITIES_PROPERTIES, VertexTypeEnum.CAPABILITIES_PROPERTIES, capProp, pathKeys, JsonPresentationFields.NAME); } - private GraphVertex createRootNodeType() { - + private void createRootNodeType() { NodeType vf = new NodeType(); String uniqueId = UniqueIdBuilder.buildResourceUniqueId(); vf.setUniqueId(uniqueId); @@ -399,7 +433,6 @@ public class InterfacesOperationTest extends ModelTestBase{ PropertyDataDefinition prop1 = new PropertyDataDefinition(); prop1.setName("derived1"); prop1.setDefaultValue("deriveddef1"); - properties.put("derived1", prop1); PropertyDataDefinition prop2 = new PropertyDataDefinition(); @@ -415,15 +448,12 @@ public class InterfacesOperationTest extends ModelTestBase{ 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()); - return getNodeTyeRes.left().value(); + getNodeTyeRes.left().value(); } private void createUsers() { - GraphVertex ownerV = new GraphVertex(VertexTypeEnum.USER); ownerV.setUniqueId("user1"); @@ -435,7 +465,6 @@ public class InterfacesOperationTest extends ModelTestBase{ ownerV.updateMetadataJsonWithCurrentMetadataProperties(); ownerV.setJson(new HashMap<>()); Either<GraphVertex, TitanOperationStatus> createUserRes = titanDao.createVertex(ownerV); - assertTrue(createUserRes.isLeft()); ownerVertex = createUserRes.left().value(); @@ -450,33 +479,14 @@ public class InterfacesOperationTest extends ModelTestBase{ 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()); + createUserRes.left().value(); + lifecycleOperation.findUser(ownerVertex.getUniqueId()); } @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(); + GraphTestUtils.clearGraph(titanDao); } } |