Revert "Interface operation feature enhancements"
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / jsontitan / operations / InterfacesOperationTest.java
1 package org.openecomp.sdc.be.model.jsontitan.operations;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertSame;
5 import static org.junit.Assert.assertTrue;
6
7 import fj.data.Either;
8 import java.util.ArrayList;
9 import java.util.HashMap;
10 import java.util.List;
11 import java.util.Map;
12 import javax.annotation.Resource;
13 import org.junit.After;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
20 import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
21 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
22 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
23 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
24 import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
25 import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
26 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
28 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
29 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
30 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
31 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
32 import org.openecomp.sdc.be.model.Component;
33 import org.openecomp.sdc.be.model.InterfaceDefinition;
34 import org.openecomp.sdc.be.model.LifecycleStateEnum;
35 import org.openecomp.sdc.be.model.ModelTestBase;
36 import org.openecomp.sdc.be.model.Operation;
37 import org.openecomp.sdc.be.model.Service;
38 import org.openecomp.sdc.be.model.category.CategoryDefinition;
39 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
40 import org.openecomp.sdc.be.model.jsontitan.datamodel.NodeType;
41 import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
42 import org.openecomp.sdc.be.model.jsontitan.utils.GraphTestUtils;
43 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
44 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
45 import org.openecomp.sdc.common.util.ValidationUtils;
46 import org.springframework.test.context.ContextConfiguration;
47 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
48
49 @RunWith(SpringJUnit4ClassRunner.class)
50 @ContextConfiguration("classpath:application-context-test.xml")
51 public class InterfacesOperationTest extends ModelTestBase {
52     @Resource
53     protected TitanDao titanDao;
54
55     @Resource
56     private InterfaceOperation interfaceOperation;
57
58     @Resource
59     protected NodeTypeOperation nodeTypeOperation;
60
61     @Resource
62     protected TopologyTemplateOperation topologyTemplateOperation;
63
64     @Resource
65     private ToscaElementLifecycleOperation lifecycleOperation;
66
67     private static final String RESOURCE_NAME = "Resource Name";
68     private static final String RESOURCE_ID = "resourceID";
69
70     private static final String SERVICE_NAME = "Service Name";
71     private static final String SERVICE_ID = "serviceID";
72
73     private final String categoryName = "category";
74     private final String subcategory = "mycategory";
75
76     private GraphVertex ownerVertex;
77
78     private final Service service = createService();
79     private final org.openecomp.sdc.be.model.Resource resource = createResource();
80
81     @BeforeClass
82     public static void initInterfacesOperation() {
83         init();
84     }
85
86     @Before
87     public void setupBefore() {
88         GraphTestUtils.clearGraph(titanDao);
89         createUsers();
90         createResourceCategory();
91         createServiceCategory();
92         GraphTestUtils.createRootCatalogVertex(titanDao);
93         createRootNodeType();
94         createNodeType("resource", RESOURCE_ID);
95         createNodeType("service", SERVICE_ID);
96         createTopologyTemplate("firstService");
97     }
98
99     @After
100     public void cleanAfter() {
101         GraphTestUtils.clearGraph(titanDao);
102     }
103
104     @Test
105     public void testAddInterface_Service(){testAddInterface(service);}
106
107     @Test
108     public void testAddInterface_Resource(){testAddInterface(resource);}
109
110     @Test
111     public void testUpdateInterface_Service(){testUpdateInterface(service);}
112
113     @Test
114     public void testUpdateInterface_Resource(){testUpdateInterface(resource);}
115
116     @Test
117     public void testAddInterfaceOperation_Service(){testAddInterfaceOperation(service);}
118
119     @Test
120     public void testAddInterfaceOperation_Resource(){testAddInterfaceOperation(resource);}
121
122     @Test
123     public void testUpdateInterfaceOperation_Service(){testUpdateInterfaceOperation(service);}
124
125     @Test
126     public void testUpdateInterfaceOperation_Resource(){testUpdateInterfaceOperation(resource);}
127
128     @Test
129     public void testDeleteInterfaceOperation_Service(){testDeleteInterfaceOperation(service);}
130
131     @Test
132     public void testDeleteInterfaceOperation_Resource(){testDeleteInterfaceOperation(resource);}
133
134     @Test
135     public void testUpdateInterfaceShouldFailWhenNOtCreatedFirst() {
136         Component component = createResource();
137         InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
138         interfaceDefinition.setOperationsMap(createMockOperationMap());
139         Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.updateInterface(component.getUniqueId(),
140             interfaceDefinition);
141         Assert.assertTrue(res.isRight());
142     }
143
144     private void testAddInterface(Component component) {
145         InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
146         Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(),
147             interfaceDefinition);
148         Assert.assertTrue(res.isLeft());
149     }
150
151     private void testUpdateInterface(Component component) {
152         InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
153         interfaceDefinition.setOperationsMap(createMockOperationMap());
154         Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition);
155         Assert.assertTrue(res.isLeft());
156         InterfaceDefinition value = res.left().value();
157         String new_description = "New Description";
158         value.setDescription(new_description);
159         res = interfaceOperation.updateInterface(component.getUniqueId(), interfaceDefinition);
160         assertTrue(res.isLeft());
161         assertEquals(new_description,res.left().value().getDescription());
162     }
163
164     private void testAddInterfaceOperation(Component component) {
165         InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
166         Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition);
167         Assert.assertTrue(res.isLeft());
168         InterfaceDefinition value = res.left().value();
169         Operation op = createMockOperation();
170         Either<Operation, StorageOperationStatus> addInterfaceOperationRes = interfaceOperation.addInterfaceOperation(component.getUniqueId(), value, op);
171         assertTrue(addInterfaceOperationRes.isLeft());
172     }
173
174     private void testUpdateInterfaceOperation(Component component) {
175         InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
176         Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition);
177         Assert.assertTrue(res.isLeft());
178         InterfaceDefinition value = res.left().value();
179         Operation op = createMockOperation();
180         Either<Operation, StorageOperationStatus> addInterfaceOperationRes = interfaceOperation.addInterfaceOperation(component.getUniqueId(), value, op);
181         Assert.assertTrue(addInterfaceOperationRes.isLeft());
182         Operation resultOp = addInterfaceOperationRes.left().value();
183         resultOp.setName("New_Create");
184         Either<Operation, StorageOperationStatus> updateInterfaceOperationRes = interfaceOperation.updateInterfaceOperation(component.getUniqueId(), value, resultOp);
185         assertTrue(updateInterfaceOperationRes.isLeft());
186         assertEquals("New_Create", updateInterfaceOperationRes.left().value().getName());
187     }
188
189     private void testDeleteInterfaceOperation(Component component) {
190         InterfaceDefinition interfaceDefinition = buildInterfaceDefinition();
191         Either<InterfaceDefinition, StorageOperationStatus> res = interfaceOperation.addInterface(component.getUniqueId(), interfaceDefinition);
192         Assert.assertTrue(res.isLeft());
193         InterfaceDefinition value = res.left().value();
194         Operation op = createMockOperation();
195         Either<Operation, StorageOperationStatus> addInterfaceOperationRes = interfaceOperation.addInterfaceOperation(component.getUniqueId(), value, op);
196         Assert.assertTrue(addInterfaceOperationRes.isLeft());
197         Operation resultOp = addInterfaceOperationRes.left().value();
198         Either<Operation, StorageOperationStatus> deleteInterfaceOperationRes = interfaceOperation.deleteInterfaceOperation(component.getUniqueId(), value, resultOp.getUniqueId());
199         assertTrue(deleteInterfaceOperationRes.isLeft());
200     }
201
202     private InterfaceDefinition buildInterfaceDefinition() {
203         InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
204         interfaceDefinition.setType("tosca.interfaces.standard");
205         interfaceDefinition.setCreationDate(101232L);
206         return interfaceDefinition;
207     }
208
209     private org.openecomp.sdc.be.model.Resource createResource() {
210         org.openecomp.sdc.be.model.Resource resource = new org.openecomp.sdc.be.model.Resource();
211         resource.setUniqueId(RESOURCE_ID);
212         resource.setName(RESOURCE_NAME);
213         resource.setDescription("My short description");
214         resource.setInterfaces(createMockInterfaceDefinition());
215         return resource;
216     }
217
218     private Service createService() {
219         Service service = new Service();
220         service.setUniqueId(SERVICE_ID);
221         service.setName(SERVICE_NAME);
222         service.setDescription("My short description");
223         service.setInterfaces(createMockInterfaceDefinition());
224         return service;
225     }
226
227     private InterfaceDefinition createInterface(String uniqueID, String description, String type, String toscaResourceName,
228         Map<String, Operation> op) {
229         InterfaceDefinition id = new InterfaceDefinition();
230         id.setType(type);
231         id.setDescription(description);
232         id.setUniqueId(uniqueID);
233         id.setToscaResourceName(toscaResourceName);
234         id.setOperationsMap(op);
235         return id;
236     }
237
238     private  Map<String, InterfaceDefinition> createMockInterfaceDefinition() {
239         Map<String, Operation> operationMap = createMockOperationMap();
240         Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
241         interfaceDefinitionMap.put("int1", createInterface("int1", "Interface 1",
242             "lifecycle", "tosca", operationMap));
243         return interfaceDefinitionMap;
244     }
245
246     private Map<String, Operation> createMockOperationMap() {
247         Map<String, Operation> operationMap = new HashMap<>();
248         operationMap.put("op1", createMockOperation());
249         return operationMap;
250     }
251
252     private Operation createMockOperation() {
253         Operation operation = new Operation();
254         operation.setDefinition(false);
255         operation.setName("create");
256         operation.setUniqueId("op1");
257         return operation;
258     }
259
260     private void createResourceCategory() {
261         GraphVertex cat = new GraphVertex(VertexTypeEnum.RESOURCE_CATEGORY);
262         Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
263         String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.RESOURCE_CATEGORY);
264         cat.setUniqueId(catId);
265         metadataProperties.put(GraphPropertyEnum.UNIQUE_ID, catId);
266         metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_CATEGORY.getName());
267         metadataProperties.put(GraphPropertyEnum.NAME, categoryName);
268         metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
269         cat.setMetadataProperties(metadataProperties);
270         cat.updateMetadataJsonWithCurrentMetadataProperties();
271
272         GraphVertex subCat = new GraphVertex(VertexTypeEnum.RESOURCE_SUBCATEGORY);
273         metadataProperties = new HashMap<>();
274         String subCatId = UniqueIdBuilder.buildSubCategoryUid(cat.getUniqueId(), subcategory);
275         subCat.setUniqueId(subCatId);
276         metadataProperties.put(GraphPropertyEnum.UNIQUE_ID, subCatId);
277         metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_SUBCATEGORY.getName());
278         metadataProperties.put(GraphPropertyEnum.NAME, subcategory);
279         metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(subcategory));
280         subCat.setMetadataProperties(metadataProperties);
281         subCat.updateMetadataJsonWithCurrentMetadataProperties();
282
283         Either<GraphVertex, TitanOperationStatus> catRes = titanDao.createVertex(cat);
284         Either<GraphVertex, TitanOperationStatus> subCatRes = titanDao.createVertex(subCat);
285         titanDao.createEdge(catRes.left().value().getVertex(), subCatRes.left().value().getVertex(), EdgeLabelEnum.SUB_CATEGORY, new HashMap<>());
286     }
287
288     private void createServiceCategory() {
289         GraphVertex cat = new GraphVertex(VertexTypeEnum.SERVICE_CATEGORY);
290         Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
291         String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.SERVICE_CATEGORY);
292         cat.setUniqueId(catId);
293         metadataProperties.put(GraphPropertyEnum.UNIQUE_ID, catId);
294         metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.SERVICE_CATEGORY.getName());
295         metadataProperties.put(GraphPropertyEnum.NAME, categoryName);
296         metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
297         cat.setMetadataProperties(metadataProperties);
298         cat.updateMetadataJsonWithCurrentMetadataProperties();
299         titanDao.createVertex(cat);
300     }
301
302     private void createTopologyTemplate(String name) {
303         TopologyTemplate service = new TopologyTemplate();
304         String uniqueId = UniqueIdBuilder.buildResourceUniqueId();
305         service.setUniqueId(uniqueId);
306         service.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
307         service.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), name);
308         service.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
309         service.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "0.1");
310         service.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(), ResourceTypeEnum.VF.name());
311         service.getMetadata().put(JsonPresentationFields.COMPONENT_TYPE.getPresentation(), ComponentTypeEnum.RESOURCE);
312         List<CategoryDefinition> categories = new ArrayList<>();
313         CategoryDefinition cat = new CategoryDefinition();
314         categories.add(cat);
315         cat.setName(categoryName);
316         service.setCategories(categories);
317
318         service.setComponentType(ComponentTypeEnum.SERVICE);
319         Either<TopologyTemplate, StorageOperationStatus> createRes = topologyTemplateOperation.createTopologyTemplate(service);
320         Either<GraphVertex, TitanOperationStatus> getNodeTyeRes = titanDao.getVertexById(createRes.left().value().getUniqueId());
321
322         getNodeTyeRes.left().value();
323     }
324
325     private <T extends ToscaDataDefinition> void createNodeType(String nodeTypeName, String uniqueId) {
326         NodeType vf = new NodeType();
327         vf.setUniqueId(uniqueId);
328         vf.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
329         vf.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), nodeTypeName);
330         vf.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
331         vf.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "0.1");
332         vf.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(), ResourceTypeEnum.VF.name());
333         vf.getMetadata().put(JsonPresentationFields.COMPONENT_TYPE.getPresentation(), ComponentTypeEnum.RESOURCE);
334         List<CategoryDefinition> categories = new ArrayList<>();
335         CategoryDefinition cat = new CategoryDefinition();
336         categories.add(cat);
337         cat.setName(categoryName);
338         List<SubCategoryDefinition> subCategories = new ArrayList<>();
339         SubCategoryDefinition subCat = new SubCategoryDefinition();
340         subCat.setName(subcategory);
341         subCategories.add(subCat);
342         cat.setSubcategories(subCategories);
343         vf.setCategories(categories);
344
345         List<String> derivedFrom = new ArrayList<>();
346         derivedFrom.add("root");
347         vf.setDerivedFrom(derivedFrom);
348
349         vf.setComponentType(ComponentTypeEnum.RESOURCE);
350         Either<NodeType, StorageOperationStatus> createVFRes = nodeTypeOperation.createNodeType(vf);
351
352         Either<GraphVertex, TitanOperationStatus> getNodeTyeRes = titanDao.getVertexById(createVFRes.left().value().getUniqueId());
353
354         GraphVertex vfVertex = getNodeTyeRes.left().value();
355
356         List<PropertyDataDefinition> addProperties = new ArrayList<>();
357         PropertyDataDefinition prop11 = new PropertyDataDefinition();
358         prop11.setName("prop11");
359         prop11.setDefaultValue("def11");
360
361         addProperties.add(prop11);
362
363         PropertyDataDefinition prop22 = new PropertyDataDefinition();
364         prop22.setName("prop22");
365         prop22.setDefaultValue("def22");
366         addProperties.add(prop22);
367
368         StorageOperationStatus status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, addProperties, JsonPresentationFields.NAME);
369         assertSame(status, StorageOperationStatus.OK);
370
371         PropertyDataDefinition prop33 = new PropertyDataDefinition();
372         prop33.setName("prop33");
373         prop33.setDefaultValue("def33");
374
375         status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop33, JsonPresentationFields.NAME);
376         assertSame(status, StorageOperationStatus.OK);
377
378         PropertyDataDefinition prop44 = new PropertyDataDefinition();
379         prop44.setName("prop44");
380         prop44.setDefaultValue("def44");
381
382         status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop44, JsonPresentationFields.NAME);
383         assertSame(status, StorageOperationStatus.OK);
384
385         PropertyDataDefinition capProp = new PropertyDataDefinition();
386         capProp.setName("capProp");
387         capProp.setDefaultValue("capPropDef");
388
389         MapDataDefinition dataToCreate = new MapPropertiesDataDefinition();
390         dataToCreate.put("capProp", capProp);
391
392         Map<String, MapDataDefinition> capProps = new HashMap<>();
393         capProps.put("capName", dataToCreate);
394
395         nodeTypeOperation.associateElementToData(
396             vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps);
397
398         List<String> pathKeys = new ArrayList<>();
399         pathKeys.add("capName");
400         capProp.setDefaultValue("BBBB");
401         nodeTypeOperation.updateToscaDataDeepElementOfToscaElement(vfVertex, EdgeLabelEnum.CAPABILITIES_PROPERTIES, VertexTypeEnum.CAPABILITIES_PROPERTIES, capProp, pathKeys, JsonPresentationFields.NAME);
402     }
403
404     private void createRootNodeType() {
405         NodeType vf = new NodeType();
406         String uniqueId = UniqueIdBuilder.buildResourceUniqueId();
407         vf.setUniqueId(uniqueId);
408         vf.setComponentType(ComponentTypeEnum.RESOURCE);
409         vf.setCreatorUserId((String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID));
410         vf.getMetadata().put(JsonPresentationFields.NAME.getPresentation(), "root");
411         vf.getMetadata().put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
412         vf.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "1.0");
413         vf.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(), ResourceTypeEnum.VFC.name());
414         vf.getMetadata().put(JsonPresentationFields.LIFECYCLE_STATE.getPresentation(), LifecycleStateEnum.CERTIFIED.name());
415         vf.getMetadata().put(JsonPresentationFields.TOSCA_RESOURCE_NAME.getPresentation(), "root");
416         vf.getMetadata().put(JsonPresentationFields.HIGHEST_VERSION.getPresentation(), true);
417
418         List<CategoryDefinition> categories = new ArrayList<>();
419         CategoryDefinition cat = new CategoryDefinition();
420         categories.add(cat);
421         cat.setName(categoryName);
422         List<SubCategoryDefinition> subCategories = new ArrayList<>();
423         SubCategoryDefinition subCat = new SubCategoryDefinition();
424         subCat.setName(subcategory);
425         subCategories.add(subCat);
426         cat.setSubcategories(subCategories);
427         vf.setCategories(categories);
428
429         List<String> derivedFrom = new ArrayList<>();
430         vf.setDerivedFrom(derivedFrom);
431
432         Map<String, PropertyDataDefinition> properties = new HashMap<>();
433         PropertyDataDefinition prop1 = new PropertyDataDefinition();
434         prop1.setName("derived1");
435         prop1.setDefaultValue("deriveddef1");
436         properties.put("derived1", prop1);
437
438         PropertyDataDefinition prop2 = new PropertyDataDefinition();
439         prop2.setUniqueId("derived2");
440         prop2.setName("deriveddef2");
441         properties.put("derived2", prop2);
442
443         PropertyDataDefinition prop3 = new PropertyDataDefinition();
444         prop3.setName("derived3");
445         prop3.setDefaultValue("deriveddef3");
446         properties.put("derived3", prop3);
447
448         vf.setProperties(properties);
449         vf.setComponentType(ComponentTypeEnum.RESOURCE);
450         Either<NodeType, StorageOperationStatus> createVFRes = nodeTypeOperation.createNodeType(vf);
451
452         Either<GraphVertex, TitanOperationStatus> getNodeTyeRes = titanDao.getVertexById(createVFRes.left().value().getUniqueId());
453         getNodeTyeRes.left().value();
454     }
455
456     private void createUsers() {
457         GraphVertex ownerV = new GraphVertex(VertexTypeEnum.USER);
458         ownerV.setUniqueId("user1");
459
460         Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
461         metadataProperties.put(GraphPropertyEnum.USERID, ownerV.getUniqueId());
462         metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.USER.getName());
463         metadataProperties.put(GraphPropertyEnum.NAME, "user1");
464         ownerV.setMetadataProperties(metadataProperties);
465         ownerV.updateMetadataJsonWithCurrentMetadataProperties();
466         ownerV.setJson(new HashMap<>());
467         Either<GraphVertex, TitanOperationStatus> createUserRes = titanDao.createVertex(ownerV);
468
469         ownerVertex = createUserRes.left().value();
470
471         GraphVertex modifierV = new GraphVertex(VertexTypeEnum.USER);
472         modifierV.setUniqueId("user2");
473
474         metadataProperties = new HashMap<>();
475         metadataProperties.put(GraphPropertyEnum.USERID, modifierV.getUniqueId());
476         metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.USER.getName());
477         metadataProperties.put(GraphPropertyEnum.NAME, "user2");
478         modifierV.setMetadataProperties(metadataProperties);
479         modifierV.updateMetadataJsonWithCurrentMetadataProperties();
480         modifierV.setJson(new HashMap<>());
481         createUserRes = titanDao.createVertex(modifierV);
482         createUserRes.left().value();
483
484         lifecycleOperation.findUser(ownerVertex.getUniqueId());
485     }
486
487     @After
488     public void teardown() {
489         GraphTestUtils.clearGraph(titanDao);
490     }
491
492 }