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