Make Service base type optional
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / operations / impl / ElementOperationTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 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.operations.impl;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertNotNull;
25 import static org.junit.jupiter.api.Assertions.assertTrue;
26 import static org.mockito.ArgumentMatchers.anyMap;
27 import static org.mockito.Mockito.any;
28 import static org.mockito.Mockito.eq;
29 import static org.mockito.Mockito.isNull;
30 import static org.mockito.Mockito.mock;
31 import static org.mockito.Mockito.when;
32
33 import fj.data.Either;
34 import java.util.ArrayList;
35 import java.util.Collections;
36 import java.util.HashMap;
37 import java.util.List;
38 import java.util.Map;
39 import org.apache.tinkerpop.gremlin.structure.T;
40 import org.junit.jupiter.api.BeforeAll;
41 import org.junit.jupiter.api.BeforeEach;
42 import org.junit.jupiter.api.Test;
43 import org.mockito.InjectMocks;
44 import org.mockito.Mock;
45 import org.mockito.MockitoAnnotations;
46 import org.openecomp.sdc.be.config.ArtifactConfiguration;
47 import org.openecomp.sdc.be.config.CategoryBaseTypeConfig;
48 import org.openecomp.sdc.be.dao.api.ActionStatus;
49 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
50 import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao;
51 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
52 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
53 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
54 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
55 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
56 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
57 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
58 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
59 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
60 import org.openecomp.sdc.be.model.ArtifactType;
61 import org.openecomp.sdc.be.model.BaseType;
62 import org.openecomp.sdc.be.model.LifecycleStateEnum;
63 import org.openecomp.sdc.be.model.ModelTestBase;
64 import org.openecomp.sdc.be.model.PropertyScope;
65 import org.openecomp.sdc.be.model.Tag;
66 import org.openecomp.sdc.be.model.category.CategoryDefinition;
67 import org.openecomp.sdc.be.model.category.GroupingDefinition;
68 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
69 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
70 import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
71 import org.openecomp.sdc.be.resources.data.category.CategoryData;
72 import org.springframework.test.context.ContextConfiguration;
73
74 @ContextConfiguration("classpath:application-context-test.xml")
75 public class ElementOperationTest extends ModelTestBase {
76
77     @InjectMocks
78     private ElementOperation elementOperation;
79
80     @Mock
81     private JanusGraphGenericDao janusGraphDao;
82     @Mock
83     private HealingJanusGraphDao healingJanusGraphDao;
84
85     private static final String CATEGORY = "category";
86     private static final String SUBCATEGORY = "subcategory";
87
88     @BeforeAll
89     public static void setupBeforeClass() {
90         ModelTestBase.init();
91     }
92
93     @BeforeEach
94     void beforeEachInit() {
95         MockitoAnnotations.openMocks(this);
96     }
97
98     @Test
99     public void testGetArtifactsTypes() {
100         final List<ArtifactConfiguration> expectedArtifactConfigurationList = new ArrayList<>();
101         final ArtifactConfiguration artifactConfiguration1 = new ArtifactConfiguration();
102         artifactConfiguration1.setType("type1");
103         expectedArtifactConfigurationList.add(artifactConfiguration1);
104         final ArtifactConfiguration artifactConfiguration2 = new ArtifactConfiguration();
105         artifactConfiguration2.setType("type2");
106         expectedArtifactConfigurationList.add(artifactConfiguration2);
107         final ArtifactConfiguration artifactConfiguration3 = new ArtifactConfiguration();
108         artifactConfiguration3.setType("type3");
109         expectedArtifactConfigurationList.add(artifactConfiguration3);
110         configurationManager.getConfiguration().setArtifacts(expectedArtifactConfigurationList);
111
112         List<ArtifactType> actualArtifactTypes = elementOperation.getAllArtifactTypes();
113         assertNotNull(actualArtifactTypes);
114         assertEquals(expectedArtifactConfigurationList.size(), actualArtifactTypes.size());
115         boolean allMatch = actualArtifactTypes.stream().allMatch(artifactType ->
116             expectedArtifactConfigurationList.stream()
117                 .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equals(artifactType.getName()))
118         );
119         assertTrue(allMatch);
120
121         expectedArtifactConfigurationList.remove(0);
122         actualArtifactTypes = elementOperation.getAllArtifactTypes();
123         assertNotNull(actualArtifactTypes);
124         assertEquals(expectedArtifactConfigurationList.size(), actualArtifactTypes.size());
125
126         allMatch = actualArtifactTypes.stream().allMatch(artifactType ->
127             expectedArtifactConfigurationList.stream()
128                 .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equals(artifactType.getName()))
129         );
130         assertTrue(allMatch);
131     }
132
133     // @Test
134     public void testGetResourceAndServiceCategoty() {
135         String id = OperationTestsUtil.deleteAndCreateResourceCategory(CATEGORY, SUBCATEGORY, janusGraphDao);
136
137         Either<CategoryDefinition, ActionStatus> res = elementOperation.getCategory(NodeTypeEnum.ResourceNewCategory, id);
138         assertTrue(res.isLeft());
139         CategoryDefinition categoryDefinition = (CategoryDefinition) res.left().value();
140         assertEquals(CATEGORY, categoryDefinition.getName());
141         assertEquals(SUBCATEGORY, categoryDefinition.getSubcategories().get(0).getName());
142
143         id = OperationTestsUtil.deleteAndCreateServiceCategory(CATEGORY, janusGraphDao);
144
145         res = elementOperation.getCategory(NodeTypeEnum.ServiceNewCategory, id);
146         assertTrue(res.isLeft());
147         categoryDefinition = (CategoryDefinition) res.left().value();
148         assertEquals(CATEGORY, categoryDefinition.getName());
149     }
150
151     private ElementOperation createTestSubject() {
152         return new ElementOperation(new JanusGraphGenericDao(new JanusGraphClient()),
153             new HealingJanusGraphDao(new HealingPipelineDao(), new JanusGraphClient()));
154     }
155
156     @Test
157     public void testGetAllServiceCategories() throws Exception {
158         ElementOperation testSubject;
159         Either<List<CategoryDefinition>, ActionStatus> result;
160
161         // default test
162         testSubject = createTestSubject();
163         result = testSubject.getAllServiceCategories();
164     }
165
166     @Test
167     public void testGetAllResourceCategories() throws Exception {
168         ElementOperation testSubject;
169         Either<List<CategoryDefinition>, ActionStatus> result;
170
171         // default test
172         testSubject = createTestSubject();
173         result = testSubject.getAllResourceCategories();
174     }
175
176     @Test
177     public void testGetAllProductCategories() throws Exception {
178         ElementOperation testSubject;
179         Either<List<CategoryDefinition>, ActionStatus> result;
180
181         // default test
182         testSubject = createTestSubject();
183         result = testSubject.getAllProductCategories();
184     }
185
186     @Test
187     public void testCreateCategory() throws Exception {
188         ElementOperation testSubject;
189         CategoryDefinition category = new CategoryDefinition();
190         NodeTypeEnum nodeType = NodeTypeEnum.AdditionalInfoParameters;
191         Either<CategoryDefinition, ActionStatus> result;
192
193         // default test
194         testSubject = createTestSubject();
195         result = testSubject.createCategory(category, nodeType);
196     }
197
198     @Test
199     public void testCreateCategory_1() throws Exception {
200         ElementOperation testSubject;
201         CategoryDefinition category = new CategoryDefinition();
202         NodeTypeEnum nodeType = NodeTypeEnum.ArtifactRef;
203         boolean inTransaction = false;
204         Either<CategoryDefinition, ActionStatus> result;
205
206         // default test
207         testSubject = createTestSubject();
208         result = testSubject.createCategory(category, nodeType, inTransaction);
209     }
210
211     @Test
212     public void testCreateSubCategory() throws Exception {
213         ElementOperation testSubject;
214         String categoryId = "";
215         SubCategoryDefinition subCategory = null;
216         NodeTypeEnum nodeType = null;
217         Either<SubCategoryDefinition, ActionStatus> result;
218
219         // default test
220         testSubject = createTestSubject();
221         result = testSubject.createSubCategory(categoryId, subCategory, nodeType);
222     }
223
224     @Test
225     public void testCreateSubCategory_1() throws Exception {
226         ElementOperation testSubject;
227         String categoryId = "";
228         SubCategoryDefinition subCategory = null;
229         NodeTypeEnum nodeType = null;
230         boolean inTransaction = false;
231         Either<SubCategoryDefinition, ActionStatus> result;
232
233         // default test
234         testSubject = createTestSubject();
235         result = testSubject.createSubCategory(categoryId, subCategory, nodeType, inTransaction);
236     }
237
238     @Test
239     public void testCreateGrouping() throws Exception {
240         ElementOperation testSubject;
241         String subCategoryId = "";
242         GroupingDefinition grouping = null;
243         NodeTypeEnum nodeType = null;
244         Either<GroupingDefinition, ActionStatus> result;
245
246         // default test
247         testSubject = createTestSubject();
248         result = testSubject.createGrouping(subCategoryId, grouping, nodeType);
249     }
250
251     @Test
252     public void testGetAllCategories() throws Exception {
253         ElementOperation testSubject;
254         NodeTypeEnum nodeType = NodeTypeEnum.Capability;
255         boolean inTransaction = false;
256         Either<List<CategoryDefinition>, ActionStatus> result;
257
258         // default test
259         testSubject = createTestSubject();
260         result = testSubject.getAllCategories(nodeType, inTransaction);
261     }
262
263     @Test
264     public void testGetCategory() throws Exception {
265         ElementOperation testSubject;
266         NodeTypeEnum nodeType = NodeTypeEnum.CapabilityType;
267         String categoryId = "";
268         Either<CategoryDefinition, ActionStatus> result;
269
270         // default test
271         testSubject = createTestSubject();
272         result = testSubject.getCategory(nodeType, categoryId);
273     }
274
275     @Test
276     public void testGetSubCategory() throws Exception {
277         ElementOperation testSubject;
278         NodeTypeEnum nodeType = NodeTypeEnum.Group;
279         String subCategoryId = "";
280         Either<SubCategoryDefinition, ActionStatus> result;
281
282         // default test
283         testSubject = createTestSubject();
284         result = testSubject.getSubCategory(nodeType, subCategoryId);
285     }
286
287     @Test
288     public void testDeleteCategory() throws Exception {
289         ElementOperation testSubject;
290         NodeTypeEnum nodeType = NodeTypeEnum.getByName("resource");
291         String categoryId = "";
292         Either<CategoryDefinition, ActionStatus> result;
293
294         // default test
295         testSubject = createTestSubject();
296         result = testSubject.deleteCategory(nodeType, categoryId);
297     }
298
299     @Test
300     public void testDeleteSubCategory() throws Exception {
301         ElementOperation testSubject;
302         NodeTypeEnum nodeType = NodeTypeEnum.Attribute;
303         String subCategoryId = "";
304         Either<SubCategoryDefinition, ActionStatus> result;
305
306         // default test
307         testSubject = createTestSubject();
308         result = testSubject.deleteSubCategory(nodeType, subCategoryId);
309     }
310
311     @Test
312     public void testDeleteGrouping() throws Exception {
313         ElementOperation testSubject;
314         NodeTypeEnum nodeType = NodeTypeEnum.DataType;
315         String groupingId = "";
316         Either<GroupingDefinition, ActionStatus> result;
317
318         // default test
319         testSubject = createTestSubject();
320         result = testSubject.deleteGrouping(nodeType, groupingId);
321     }
322
323     @Test
324     public void testIsCategoryUniqueForType() throws Exception {
325         ElementOperation testSubject;
326         NodeTypeEnum nodeType = null;
327         String normalizedName = "";
328         Either<Boolean, ActionStatus> result;
329
330         // default test
331         testSubject = createTestSubject();
332         result = testSubject.isCategoryUniqueForType(nodeType, normalizedName);
333     }
334
335     @Test
336     public void testIsSubCategoryUniqueForCategory() throws Exception {
337         ElementOperation testSubject;
338         NodeTypeEnum nodeType = null;
339         String subCategoryNormName = "";
340         String parentCategoryId = "";
341         Either<Boolean, ActionStatus> result;
342
343         // default test
344         testSubject = createTestSubject();
345         result = testSubject.isSubCategoryUniqueForCategory(nodeType, subCategoryNormName, parentCategoryId);
346     }
347
348     @Test
349     public void testIsGroupingUniqueForSubCategory() throws Exception {
350         ElementOperation testSubject;
351         NodeTypeEnum nodeType = null;
352         String groupingNormName = "";
353         String parentSubCategoryId = "";
354         Either<Boolean, ActionStatus> result;
355
356         // default test
357         testSubject = createTestSubject();
358         result = testSubject.isGroupingUniqueForSubCategory(nodeType, groupingNormName, parentSubCategoryId);
359     }
360
361     @Test
362     public void testGetSubCategoryUniqueForType() throws Exception {
363         ElementOperation testSubject;
364         NodeTypeEnum nodeType = null;
365         String normalizedName = "";
366         Either<SubCategoryDefinition, ActionStatus> result;
367
368         // default test
369         testSubject = createTestSubject();
370         result = testSubject.getSubCategoryUniqueForType(nodeType, normalizedName);
371     }
372
373     @Test
374     public void testGetGroupingUniqueForType() throws Exception {
375         ElementOperation testSubject;
376         NodeTypeEnum nodeType = null;
377         String groupingNormalizedName = "";
378         Either<GroupingDefinition, ActionStatus> result;
379
380         // default test
381         testSubject = createTestSubject();
382         result = testSubject.getGroupingUniqueForType(nodeType, groupingNormalizedName);
383     }
384
385     @Test
386     public void testGetAllTags() throws Exception {
387         ElementOperation testSubject;
388         Either<List<Tag>, ActionStatus> result;
389
390         // default test
391         testSubject = createTestSubject();
392         result = testSubject.getAllTags();
393     }
394
395     @Test
396     public void testGetCategoryData() throws Exception {
397         ElementOperation testSubject;
398         String name = "";
399         NodeTypeEnum type = NodeTypeEnum.DataType;
400         Class<T> clazz = null;
401         Either<org.openecomp.sdc.be.resources.data.CategoryData, StorageOperationStatus> result;
402
403         // test 1
404         testSubject = createTestSubject();
405         name = null;
406         result = testSubject.getCategoryData(name, type, null);
407
408         // test 2
409         testSubject = createTestSubject();
410         name = "";
411         result = testSubject.getCategoryData(name, type, null);
412     }
413
414     @Test
415     public void testGetAllPropertyScopes() throws Exception {
416         ElementOperation testSubject;
417         Either<List<PropertyScope>, ActionStatus> result;
418
419         // default test
420         testSubject = createTestSubject();
421         result = testSubject.getAllPropertyScopes();
422     }
423
424     @Test
425     public void testGetResourceTypesMap() throws Exception {
426         ElementOperation testSubject;
427         Either<Map<String, String>, ActionStatus> result;
428
429         // default test
430         testSubject = createTestSubject();
431         result = testSubject.getResourceTypesMap();
432     }
433
434     @Test
435     public void testGetNewCategoryData() throws Exception {
436         ElementOperation testSubject;
437         String name = "";
438         NodeTypeEnum type = NodeTypeEnum.HeatParameter;
439         Class<T> clazz = null;
440         Either<CategoryData, StorageOperationStatus> result;
441
442         // test 1
443         testSubject = createTestSubject();
444         name = null;
445         result = testSubject.getNewCategoryData(name, type, null);
446
447         // test 2
448         testSubject = createTestSubject();
449         name = "";
450         result = testSubject.getNewCategoryData(name, type, null);
451     }
452
453     @Test
454     public void testBaseTypes_serviceSpecific() {
455         Map<String, CategoryBaseTypeConfig> preExistingServiceNodeTypes = configurationManager.getConfiguration().getServiceBaseNodeTypes();
456         Map<String, String> preExistingGenericNodeTypes = configurationManager.getConfiguration().getGenericAssetNodeTypes();
457
458         try {
459             final Map<String, CategoryBaseTypeConfig> serviceBaseNodeTypeConfigMap = new HashMap<>();
460             final var categoryBaseTypeConfig = new CategoryBaseTypeConfig();
461             categoryBaseTypeConfig.setBaseTypes(List.of("org.base.type"));
462             serviceBaseNodeTypeConfigMap.put("serviceCategoryA", categoryBaseTypeConfig);
463             configurationManager.getConfiguration().setServiceBaseNodeTypes(serviceBaseNodeTypeConfigMap);
464
465             Map<String, String> genericNodeTypes = new HashMap<>();
466             genericNodeTypes.put("service", "org.service.default");
467             configurationManager.getConfiguration().setGenericAssetNodeTypes(genericNodeTypes);
468
469             HealingJanusGraphDao healingJanusGraphDao = mock(HealingJanusGraphDao.class);
470             ElementOperation elementOperation = new ElementOperation(new JanusGraphGenericDao(new JanusGraphClient()), healingJanusGraphDao);
471
472             GraphVertex baseTypeVertex = mock(GraphVertex.class);
473             when(baseTypeVertex.getMetadataProperty(GraphPropertyEnum.VERSION)).thenReturn("1.0");
474             when(healingJanusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), any(), isNull(), eq(JsonParseFlagEnum.ParseAll), any()))
475                 .thenReturn(Either.left(Collections.singletonList(baseTypeVertex)));
476
477             GraphVertex derivedTypeVertex = mock(GraphVertex.class);
478             when(derivedTypeVertex.getMetadataProperty(GraphPropertyEnum.STATE)).thenReturn(LifecycleStateEnum.CERTIFIED.name());
479             when(derivedTypeVertex.getMetadataProperty(GraphPropertyEnum.VERSION)).thenReturn("1.0");
480
481             GraphVertex derivedTypeVertexUncertified = mock(GraphVertex.class);
482             when(derivedTypeVertexUncertified.getMetadataProperty(GraphPropertyEnum.STATE)).thenReturn(
483                 LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name());
484             when(derivedTypeVertexUncertified.getMetadataProperty(GraphPropertyEnum.VERSION)).thenReturn("1.1");
485
486             when(healingJanusGraphDao.getParentVertices(baseTypeVertex, EdgeLabelEnum.DERIVED_FROM,
487                 JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(Collections.singletonList(derivedTypeVertex)));
488             when(healingJanusGraphDao.getParentVertices(derivedTypeVertex, EdgeLabelEnum.DERIVED_FROM,
489                 JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
490             when(derivedTypeVertex.getMetadataProperty(GraphPropertyEnum.TOSCA_RESOURCE_NAME)).thenReturn("org.parent.type");
491
492             List<BaseType> baseTypes = elementOperation.getServiceBaseTypes("serviceCategoryA", null);
493
494             assertEquals(2, baseTypes.size());
495             assertEquals("org.base.type", baseTypes.get(0).getToscaResourceName());
496             assertEquals(1, baseTypes.get(0).getVersions().size());
497             assertEquals("1.0", baseTypes.get(0).getVersions().get(0));
498             assertEquals("org.parent.type", baseTypes.get(1).getToscaResourceName());
499         } finally {
500             configurationManager.getConfiguration().setServiceBaseNodeTypes(preExistingServiceNodeTypes);
501             configurationManager.getConfiguration().setGenericAssetNodeTypes(preExistingGenericNodeTypes);
502         }
503     }
504
505     @Test
506     public void testBaseTypes_default() {
507         Map<String, CategoryBaseTypeConfig> preExistingServiceNodeTypes = configurationManager.getConfiguration().getServiceBaseNodeTypes();
508         Map<String, String> preExistingGenericNodeTypes =
509             configurationManager.getConfiguration().getGenericAssetNodeTypes();
510
511         try {
512             Map<String, String> genericNodeTypes = new HashMap<>();
513             genericNodeTypes.put("Service", "org.service.default");
514             configurationManager.getConfiguration().setGenericAssetNodeTypes(genericNodeTypes);
515             configurationManager.getConfiguration().setServiceBaseNodeTypes(null);
516
517             HealingJanusGraphDao healingJanusGraphDao = mock(HealingJanusGraphDao.class);
518             final var elementOperation = new ElementOperation(new JanusGraphGenericDao(new JanusGraphClient()), healingJanusGraphDao);
519
520             GraphVertex baseTypeVertex = mock(GraphVertex.class);
521             when(baseTypeVertex.getMetadataProperty(GraphPropertyEnum.VERSION)).thenReturn("1.0");
522             when(healingJanusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), any(), isNull(), eq(JsonParseFlagEnum.ParseAll), any()))
523                 .thenReturn(Either.left(Collections.singletonList(baseTypeVertex)));
524
525             when(healingJanusGraphDao.getParentVertices(baseTypeVertex, EdgeLabelEnum.DERIVED_FROM,
526                 JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
527
528             List<BaseType> baseTypes = elementOperation.getServiceBaseTypes("serviceCategoryA", null);
529
530             assertEquals(1, baseTypes.size());
531             assertEquals("org.service.default", baseTypes.get(0).getToscaResourceName());
532             assertEquals(1, baseTypes.get(0).getVersions().size());
533         } finally {
534             configurationManager.getConfiguration().setServiceBaseNodeTypes(preExistingServiceNodeTypes);
535             configurationManager.getConfiguration().setGenericAssetNodeTypes(preExistingGenericNodeTypes);
536         }
537     }
538
539     @Test
540     public void testGetServiceBaseTypes_categoryWithRequiredBaseType() {
541         defaultBaseTypeMock();
542         final List<BaseType> actualBaseTypeList = elementOperation.getServiceBaseTypes("CategoryA", null);
543         assertEquals(actualBaseTypeList.size(), 1);
544         final BaseType expectedBaseType = actualBaseTypeList.get(0);
545         assertEquals(expectedBaseType.getToscaResourceName(), "org.openecomp.resource.abstract.nodes.A");
546
547     }
548
549     @Test
550     public void testGetServiceBaseTypes_categoryWithOptionalBaseType() {
551         defaultBaseTypeMock();
552         final List<BaseType> actualBaseTypeList = elementOperation.getServiceBaseTypes("CategoryC", null);
553         assertEquals(actualBaseTypeList.size(), 2);
554         assertEquals(actualBaseTypeList.get(0).getToscaResourceName(), "org.openecomp.resource.abstract.nodes.C1");
555         assertEquals(actualBaseTypeList.get(1).getToscaResourceName(), "org.openecomp.resource.abstract.nodes.C2");
556     }
557
558     @Test
559     public void testGetServiceBaseTypes_categoryWithNoBaseType() {
560         defaultBaseTypeMock();
561         final List<BaseType> actualBaseTypeList = elementOperation.getServiceBaseTypes("CategoryB", null);
562         assertTrue(actualBaseTypeList.isEmpty());
563     }
564
565     @Test
566     public void testGetServiceBaseTypes_notConfiguredCategoryThatFallsBackToGenericType() {
567         defaultBaseTypeMock();
568         final List<BaseType> actualBaseTypeList = elementOperation.getServiceBaseTypes("CategoryD", null);
569
570         assertEquals(actualBaseTypeList.size(), 1);
571         final BaseType expectedBaseType = actualBaseTypeList.get(0);
572         assertEquals(expectedBaseType.getToscaResourceName(), "org.openecomp.resource.abstract.nodes.service");
573     }
574
575     private void defaultBaseTypeMock() {
576         final GraphVertex baseTypeVertex = mock(GraphVertex.class);
577         when(baseTypeVertex.getMetadataProperty(GraphPropertyEnum.VERSION)).thenReturn("1.0");
578         when(healingJanusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap(), isNull(), eq(JsonParseFlagEnum.ParseAll), isNull()))
579             .thenReturn(Either.left(Collections.singletonList(baseTypeVertex)));
580         when(healingJanusGraphDao.getParentVertices(eq(baseTypeVertex), eq(EdgeLabelEnum.DERIVED_FROM), eq(JsonParseFlagEnum.ParseAll)))
581             .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
582     }
583
584 }