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