1 package org.openecomp.sdc.be.model.jsontitan.operations;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertTrue;
6 import java.io.BufferedOutputStream;
8 import java.io.FileOutputStream;
9 import java.io.OutputStream;
10 import java.util.ArrayList;
11 import java.util.HashMap;
12 import java.util.Iterator;
13 import java.util.List;
16 import javax.annotation.Resource;
18 import org.apache.tinkerpop.gremlin.structure.io.IoCore;
19 import org.junit.After;
20 import org.junit.Assert;
21 import org.junit.Before;
22 import org.junit.BeforeClass;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
26 import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
27 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
28 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
29 import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
30 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
31 import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
32 import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
33 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
34 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
35 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
36 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
37 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
38 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
39 import org.openecomp.sdc.be.model.InterfaceDefinition;
40 import org.openecomp.sdc.be.model.LifecycleStateEnum;
41 import org.openecomp.sdc.be.model.ModelTestBase;
42 import org.openecomp.sdc.be.model.Operation;
43 import org.openecomp.sdc.be.model.User;
44 import org.openecomp.sdc.be.model.catalog.CatalogComponent;
45 import org.openecomp.sdc.be.model.category.CategoryDefinition;
46 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
47 import org.openecomp.sdc.be.model.jsontitan.datamodel.NodeType;
48 import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
49 import org.openecomp.sdc.be.model.jsontitan.utils.GraphTestUtils;
50 import org.openecomp.sdc.be.model.operations.api.IElementOperation;
51 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
52 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
53 import org.openecomp.sdc.common.util.ValidationUtils;
54 import org.springframework.beans.factory.annotation.Autowired;
55 import org.springframework.test.context.ContextConfiguration;
56 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
58 import com.thinkaurelius.titan.core.TitanGraph;
59 import com.thinkaurelius.titan.core.TitanVertex;
61 import fj.data.Either;
63 @RunWith(SpringJUnit4ClassRunner.class)
64 @ContextConfiguration("classpath:application-context-test.xml")
65 public class InterfacesOperationTest extends ModelTestBase{
67 protected TitanDao titanDao;
69 private InterfaceOperation interfaceOperation;
72 protected TitanGraphClient titanGraphClient;
75 protected NodeTypeOperation nodeTypeOperation;
77 protected ToscaOperationFacade toscaOperationFacade;
80 protected TopologyTemplateOperation topologyTemplateOperation;
83 protected IElementOperation elementDao;
86 private ToscaElementLifecycleOperation lifecycleOperation;
88 protected static final String USER_ID = "jh0003";
89 protected static final String VF_NAME = "VF_NAME";
92 public static final String RESOURCE_CATEGORY = "Network Layer 2-3";
93 public static final String RESOURCE_SUBCATEGORY = "Router";
94 public static final String RESOURCE_NAME = "Resource Name";
96 private CategoryDefinition categoryDefinition;
97 private SubCategoryDefinition subCategoryDefinition = new SubCategoryDefinition();
98 protected static final String RESOURCE_ID = "resourceID";
99 protected static final String WORKFLOW_OPERATION_ID = "workflowOperationId";
100 public static final String DERIVED_NAME = "derivedName";
101 public static final String CSAR_UUID = "bla bla";
104 String categoryName = "category";
105 String subcategory = "mycategory";
106 String outputDirectory = "C:\\Output";
109 public static void initInterfacesOperation() {
113 private GraphVertex ownerVertex;
114 private GraphVertex modifierVertex;
115 private GraphVertex vfVertex;
116 private GraphVertex serviceVertex;
117 private GraphVertex rootVertex;
120 public void setupBefore() {
123 createResourceCategory();
124 createServiceCategory();
125 GraphTestUtils.createRootCatalogVertex(titanDao);
126 rootVertex = createRootNodeType();
127 createNodeType("firstVf");
128 serviceVertex = createTopologyTemplate("firstService");
132 public void cleanAfter() {
137 public void testAddInterface() {
138 org.openecomp.sdc.be.model.Resource resource = createResource();
139 InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
140 Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(resource.getUniqueId(),
141 interfaceDefinition);
142 Assert.assertTrue(res.isLeft());
146 public void testUpdateInterface() {
147 org.openecomp.sdc.be.model.Resource resource = createResource();
148 InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
149 interfaceDefinition.setOperationsMap(createMockOperationMap());
150 Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(resource.getUniqueId(),
151 interfaceDefinition);
152 Assert.assertTrue(res.isLeft());
153 InterfaceDefinition value = res.left().value();
154 String new_description = "New Description";
155 value.setDescription(new_description);
156 res = interfaceOperation.updateInterface(resource.getUniqueId(),
157 interfaceDefinition);
158 assertTrue(res.isLeft());
159 assertEquals(new_description,res.left().value().getDescription());
163 public void testUpdateInterfaceShouldFailWhenNOtCreatedFirst() {
164 org.openecomp.sdc.be.model.Resource resource = createResource();
165 InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
166 interfaceDefinition.setOperationsMap(createMockOperationMap());
167 Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.updateInterface(resource.getUniqueId(),
168 interfaceDefinition);
169 Assert.assertTrue(res.isRight());
172 private InterfaceDefinition buildInterfaceDefinition() {
173 InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
174 interfaceDefinition.setType("tosca.interfaces.standard");
175 interfaceDefinition.setCreationDate(new Long(101232));
178 return interfaceDefinition;
181 private org.openecomp.sdc.be.model.Resource createResource() {
182 org.openecomp.sdc.be.model.Resource resource = new org.openecomp.sdc.be.model.Resource();
183 resource.setUniqueId(RESOURCE_ID);
184 resource.setName(RESOURCE_NAME);
185 resource.addCategory(RESOURCE_CATEGORY, RESOURCE_SUBCATEGORY);
186 resource.setDescription("My short description");
187 resource.setInterfaces(createMockInterfaceDefinition());
192 private InterfaceDefinition createInterface(String uniqueID, String description, String type, String toscaResourceName,
193 Map<String, Operation> op) {
194 InterfaceDefinition id = new InterfaceDefinition();
196 id.setDescription(description);
197 id.setUniqueId(uniqueID);
198 id.setToscaResourceName(toscaResourceName);
199 id.setOperationsMap(op);
203 private Map<String, InterfaceDefinition> createMockInterfaceDefinition() {
204 Map<String, Operation> operationMap = createMockOperationMap();
205 Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
206 interfaceDefinitionMap.put("int1", createInterface("int1", "Interface 1",
207 "lifecycle", "tosca", operationMap));
209 return interfaceDefinitionMap;
212 private Map<String, Operation> createMockOperationMap() {
213 Operation operation = new Operation();
214 operation.setDefinition(false);
215 operation.setName("create");
216 Map<String, Operation> operationMap = new HashMap<>();
217 operationMap.put("op1", operation);
224 private void createResourceCategory() {
226 GraphVertex cat = new GraphVertex(VertexTypeEnum.RESOURCE_CATEGORY);
227 Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
228 String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.RESOURCE_CATEGORY);
229 cat.setUniqueId(catId);
230 metadataProperties.put(GraphPropertyEnum.UNIQUE_ID, catId);
231 metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_CATEGORY.getName());
232 metadataProperties.put(GraphPropertyEnum.NAME, categoryName);
233 metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
234 cat.setMetadataProperties(metadataProperties);
235 cat.updateMetadataJsonWithCurrentMetadataProperties();
237 GraphVertex subCat = new GraphVertex(VertexTypeEnum.RESOURCE_SUBCATEGORY);
238 metadataProperties = new HashMap<>();
239 String subCatId = UniqueIdBuilder.buildSubCategoryUid(cat.getUniqueId(), subcategory);
240 subCat.setUniqueId(subCatId);
241 metadataProperties.put(GraphPropertyEnum.UNIQUE_ID, subCatId);
242 metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_SUBCATEGORY.getName());
243 metadataProperties.put(GraphPropertyEnum.NAME, subcategory);
244 metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(subcategory));
245 subCat.setMetadataProperties(metadataProperties);
246 subCat.updateMetadataJsonWithCurrentMetadataProperties();
248 Either<GraphVertex, TitanOperationStatus> catRes = titanDao.createVertex(cat);
250 Either<GraphVertex, TitanOperationStatus> subCatRes = titanDao.createVertex(subCat);
252 TitanOperationStatus status = titanDao.createEdge(catRes.left().value().getVertex(), subCatRes.left().value().getVertex(), EdgeLabelEnum.SUB_CATEGORY, new HashMap<>());
253 assertEquals(TitanOperationStatus.OK, status);
256 private void createServiceCategory() {
258 GraphVertex cat = new GraphVertex(VertexTypeEnum.SERVICE_CATEGORY);
259 Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
260 String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.SERVICE_CATEGORY);
261 cat.setUniqueId(catId);
262 metadataProperties.put(GraphPropertyEnum.UNIQUE_ID, catId);
263 metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.SERVICE_CATEGORY.getName());
264 metadataProperties.put(GraphPropertyEnum.NAME, categoryName);
265 metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
266 cat.setMetadataProperties(metadataProperties);
267 cat.updateMetadataJsonWithCurrentMetadataProperties();
269 Either<GraphVertex, TitanOperationStatus> catRes = titanDao.createVertex(cat);
271 assertTrue(catRes.isLeft());
274 private GraphVertex createTopologyTemplate(String name) {
276 TopologyTemplate service = new TopologyTemplate();
277 String uniqueId = UniqueIdBuilder.buildResourceUniqueId();
278 service.setUniqueId(uniqueId);
279 service.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
280 service.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), name);
281 service.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
282 service.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "0.1");
283 service.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(), ResourceTypeEnum.VF.name());
284 service.getMetadata().put(JsonPresentationFields.COMPONENT_TYPE.getPresentation(), ComponentTypeEnum.RESOURCE);
285 List<CategoryDefinition> categories = new ArrayList<>();
286 CategoryDefinition cat = new CategoryDefinition();
288 cat.setName(categoryName);
289 service.setCategories(categories);
291 service.setComponentType(ComponentTypeEnum.SERVICE);
292 Either<TopologyTemplate, StorageOperationStatus> createRes = topologyTemplateOperation.createTopologyTemplate(service);
293 assertTrue(createRes.isLeft());
295 Either<GraphVertex, TitanOperationStatus> getNodeTyeRes = titanDao.getVertexById(createRes.left().value().getUniqueId());
296 assertTrue(getNodeTyeRes.isLeft());
298 // serviceVertex = getNodeTyeRes.left().value();
300 return getNodeTyeRes.left().value();
303 private <T extends ToscaDataDefinition> NodeType createNodeType(String nodeTypeName) {
305 NodeType vf = new NodeType();
306 String uniqueId = RESOURCE_ID; // UniqueIdBuilder.buildResourceUniqueId();
307 vf.setUniqueId(uniqueId);
308 vf.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
309 vf.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), nodeTypeName);
310 vf.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
311 vf.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "0.1");
312 vf.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(), ResourceTypeEnum.VF.name());
313 vf.getMetadata().put(JsonPresentationFields.COMPONENT_TYPE.getPresentation(), ComponentTypeEnum.RESOURCE);
314 List<CategoryDefinition> categories = new ArrayList<>();
315 CategoryDefinition cat = new CategoryDefinition();
317 cat.setName(categoryName);
318 List<SubCategoryDefinition> subCategories = new ArrayList<>();
319 SubCategoryDefinition subCat = new SubCategoryDefinition();
320 subCat.setName(subcategory);
321 subCategories.add(subCat);
322 cat.setSubcategories(subCategories);
323 vf.setCategories(categories);
325 List<String> derivedFrom = new ArrayList<>();
326 derivedFrom.add("root");
327 vf.setDerivedFrom(derivedFrom);
329 // Map<String, PropertyDataDefinition> properties = new HashMap<>();
330 // PropertyDataDefinition prop1 = new PropertyDataDefinition();
331 // prop1.setName("prop1");
332 // prop1.setDefaultValue("def1");
334 // properties.put("prop1", prop1);
336 // PropertyDataDefinition prop2 = new PropertyDataDefinition();
337 // prop2.setName("prop2");
338 // prop2.setDefaultValue("def2");
339 // properties.put("prop2", prop2);
341 // PropertyDataDefinition prop3 = new PropertyDataDefinition();
342 // prop3.setName("prop3");
343 // prop3.setDefaultValue("def3");
344 // properties.put("prop3", prop3);
346 // vf.setProperties(properties);
347 vf.setComponentType(ComponentTypeEnum.RESOURCE);
348 Either<NodeType, StorageOperationStatus> createVFRes = nodeTypeOperation.createNodeType(vf);
349 assertTrue(createVFRes.isLeft());
351 Either<GraphVertex, TitanOperationStatus> getNodeTyeRes = titanDao.getVertexById(createVFRes.left().value().getUniqueId());
352 assertTrue(getNodeTyeRes.isLeft());
354 vfVertex = getNodeTyeRes.left().value();
356 List<PropertyDataDefinition> addProperties = new ArrayList<>();
357 PropertyDataDefinition prop11 = new PropertyDataDefinition();
358 prop11.setName("prop11");
359 prop11.setDefaultValue("def11");
361 addProperties.add(prop11);
363 PropertyDataDefinition prop22 = new PropertyDataDefinition();
364 prop22.setName("prop22");
365 prop22.setDefaultValue("def22");
366 addProperties.add(prop22);
368 StorageOperationStatus status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, addProperties, JsonPresentationFields.NAME);
369 assertTrue(status == StorageOperationStatus.OK);
371 PropertyDataDefinition prop33 = new PropertyDataDefinition();
372 prop33.setName("prop33");
373 prop33.setDefaultValue("def33");
375 status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop33, JsonPresentationFields.NAME);
376 assertTrue(status == StorageOperationStatus.OK);
378 PropertyDataDefinition prop44 = new PropertyDataDefinition();
379 prop44.setName("prop44");
380 prop44.setDefaultValue("def44");
382 status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop44, JsonPresentationFields.NAME);
383 assertTrue(status == StorageOperationStatus.OK);
385 PropertyDataDefinition capProp = new PropertyDataDefinition();
386 capProp.setName("capProp");
387 capProp.setDefaultValue("capPropDef");
389 MapDataDefinition dataToCreate = new MapPropertiesDataDefinition();
390 dataToCreate.put("capProp", capProp);
392 Map<String, MapDataDefinition> capProps = new HashMap();
393 capProps.put("capName", dataToCreate);
395 Either<GraphVertex, StorageOperationStatus> res = nodeTypeOperation.assosiateElementToData(vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps);
397 // exportGraphMl(titanDao.getGraph().left().value());
399 List<String> pathKeys = new ArrayList<>();
400 pathKeys.add("capName");
401 capProp.setDefaultValue("BBBB");
402 status = nodeTypeOperation.updateToscaDataDeepElementOfToscaElement(vfVertex, EdgeLabelEnum.CAPABILITIES_PROPERTIES, VertexTypeEnum.CAPABILITIES_PROPERTIES, capProp, pathKeys, JsonPresentationFields.NAME);
406 private GraphVertex createRootNodeType() {
408 NodeType vf = new NodeType();
409 String uniqueId = UniqueIdBuilder.buildResourceUniqueId();
410 vf.setUniqueId(uniqueId);
411 vf.setComponentType(ComponentTypeEnum.RESOURCE);
412 vf.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
413 vf.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), "root");
414 vf.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
415 vf.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "1.0");
416 vf.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(), ResourceTypeEnum.VFC.name());
417 vf.getMetadata().put(JsonPresentationFields.LIFECYCLE_STATE.getPresentation(), LifecycleStateEnum.CERTIFIED.name());
418 vf.getMetadata().put(JsonPresentationFields.TOSCA_RESOURCE_NAME.getPresentation(), "root");
419 vf.getMetadata().put(JsonPresentationFields.HIGHEST_VERSION.getPresentation(), true);
421 List<CategoryDefinition> categories = new ArrayList<>();
422 CategoryDefinition cat = new CategoryDefinition();
424 cat.setName(categoryName);
425 List<SubCategoryDefinition> subCategories = new ArrayList<>();
426 SubCategoryDefinition subCat = new SubCategoryDefinition();
427 subCat.setName(subcategory);
428 subCategories.add(subCat);
429 cat.setSubcategories(subCategories);
430 vf.setCategories(categories);
432 List<String> derivedFrom = new ArrayList<>();
433 vf.setDerivedFrom(derivedFrom);
435 Map<String, PropertyDataDefinition> properties = new HashMap<>();
436 PropertyDataDefinition prop1 = new PropertyDataDefinition();
437 prop1.setName("derived1");
438 prop1.setDefaultValue("deriveddef1");
440 properties.put("derived1", prop1);
442 PropertyDataDefinition prop2 = new PropertyDataDefinition();
443 prop2.setUniqueId("derived2");
444 prop2.setName("deriveddef2");
445 properties.put("derived2", prop2);
447 PropertyDataDefinition prop3 = new PropertyDataDefinition();
448 prop3.setName("derived3");
449 prop3.setDefaultValue("deriveddef3");
450 properties.put("derived3", prop3);
452 vf.setProperties(properties);
453 vf.setComponentType(ComponentTypeEnum.RESOURCE);
454 Either<NodeType, StorageOperationStatus> createVFRes = nodeTypeOperation.createNodeType(vf);
455 assertTrue(createVFRes.isLeft());
457 Either<GraphVertex, TitanOperationStatus> getNodeTyeRes = titanDao.getVertexById(createVFRes.left().value().getUniqueId());
458 assertTrue(getNodeTyeRes.isLeft());
459 return getNodeTyeRes.left().value();
462 private void createUsers() {
464 GraphVertex ownerV = new GraphVertex(VertexTypeEnum.USER);
465 ownerV.setUniqueId("user1");
467 Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
468 metadataProperties.put(GraphPropertyEnum.USERID, ownerV.getUniqueId());
469 metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.USER.getName());
470 metadataProperties.put(GraphPropertyEnum.NAME, "user1");
471 ownerV.setMetadataProperties(metadataProperties);
472 ownerV.updateMetadataJsonWithCurrentMetadataProperties();
473 ownerV.setJson(new HashMap<>());
474 Either<GraphVertex, TitanOperationStatus> createUserRes = titanDao.createVertex(ownerV);
475 assertTrue(createUserRes.isLeft());
477 ownerVertex = createUserRes.left().value();
479 GraphVertex modifierV = new GraphVertex(VertexTypeEnum.USER);
480 modifierV.setUniqueId("user2");
482 metadataProperties = new HashMap<>();
483 metadataProperties.put(GraphPropertyEnum.USERID, modifierV.getUniqueId());
484 metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.USER.getName());
485 metadataProperties.put(GraphPropertyEnum.NAME, "user2");
486 modifierV.setMetadataProperties(metadataProperties);
487 modifierV.updateMetadataJsonWithCurrentMetadataProperties();
488 modifierV.setJson(new HashMap<>());
489 createUserRes = titanDao.createVertex(modifierV);
490 assertTrue(createUserRes.isLeft());
492 modifierVertex = createUserRes.left().value();
494 Either<GraphVertex, TitanOperationStatus> getOwnerRes = lifecycleOperation.findUser(ownerVertex.getUniqueId());
495 assertTrue(getOwnerRes.isLeft());
499 public void verifyInCatalogData(int expected, List<String> expectedIds) {
501 Either<List<CatalogComponent>, StorageOperationStatus> highestResourcesRes = topologyTemplateOperation.getElementCatalogData();
502 assertTrue(highestResourcesRes.isLeft());
503 List<CatalogComponent> highestResources = highestResourcesRes.left().value();
504 // calculate expected count value
505 assertEquals(expected, highestResources.stream().count());
506 if (expectedIds != null) {
507 highestResources.forEach(a -> assertTrue(expectedIds.contains(a.getUniqueId())));
512 public void teardown() {
516 private void clearGraph() {
517 Either<TitanGraph, TitanOperationStatus> graphResult = titanDao.getGraph();
518 TitanGraph graph = graphResult.left().value();
520 Iterable<TitanVertex> vertices = graph.query().vertices();
521 if (vertices != null) {
522 Iterator<TitanVertex> iterator = vertices.iterator();
523 while (iterator.hasNext()) {
524 TitanVertex vertex = iterator.next();
531 private String exportGraphMl(TitanGraph graph) {
532 String result = null;
533 String outputFile = outputDirectory + File.separator + "exportGraph." + System.currentTimeMillis() + ".graphml";
535 try (final OutputStream os = new BufferedOutputStream(new FileOutputStream(outputFile))) {
536 graph.io(IoCore.graphml()).writer().normalize(true).create().writeGraph(os, graph);
540 } catch (Exception e) {
541 graph.tx().rollback();