X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Ftest%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fcomponents%2FResourceImportManagerTest.java;h=d64aaf8cd0e545bbae15c540ad618cd7480fdf3b;hb=f4668df71072c8ecd4b9d05423006265b36a6ef7;hp=0d6922e3f2d447fabc1e343ff03217899d84673c;hpb=7c61c7bb0369bc27d05c8801c8cb0cca41e494bf;p=sdc.git diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index 0d6922e3f2..d64aaf8cd0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -477,7 +477,7 @@ class ResourceImportManagerTest { NodeTypesMetadataList nodeTypesMetadataList = new NodeTypesMetadataList(); List nodeTypeMetadataList = new ArrayList<>(); Map allTypesToCreate = new HashMap<>(); - ServiceCsarInfo csarInfo= getCsarInfo(); + ServiceCsarInfo csarInfo = getCsarInfo(); List nodeTypesToCreate = csarInfo.getNodeTypesUsed(); nodeTypesToCreate.stream().forEach(nodeType -> { allTypesToCreate.put(nodeType.getMappedNodeType().getKey(), nodeType.getMappedNodeType().getValue()); @@ -487,15 +487,26 @@ class ResourceImportManagerTest { when(toscaOperationFacade.getLatestByName(any(), any())).thenReturn(Either.left(null)).thenReturn(Either.left(null)); when(toscaOperationFacade.getLatestByToscaResourceName("org.openecomp.resource.VFC-root", "ETSI SOL001 v2.5.1")) - .thenReturn(Either.left(null)); - when(resourceBusinessLogic - .createOrUpdateResourceByImport(any(Resource.class), any(User.class), eq(true), eq(true), eq(false), eq(null), eq(null), eq(false))) - .thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK)).thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK)); + .thenReturn(Either.left(null)); + when(toscaOperationFacade.getLatestByToscaResourceName("tosca.nodes.nfv.NS", "")) + .thenReturn(Either.left(createResourceNS())); + when(toscaOperationFacade.getLatestByToscaResourceName("org.openecomp.service.Etsiwithchild", "")) + .thenReturn(Either.right(null)); + when(resourceBusinessLogic.createOrUpdateResourceByImport(any(Resource.class), any(User.class), eq(true), eq(true), eq(false), eq(null), + eq(null), eq(false))).thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK)) + .thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK)); + when(responseFormatManager.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(mock(ResponseFormat.class)); importManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, null, user, "", false, false); verify(janusGraphDao).commit(); } + private Resource createResourceNS() { + Resource ns = new Resource(); + ns.setName("tosca.nodes.nfv.NS"); + return ns; + } + private void setResourceBusinessLogicMock() { when(resourceBusinessLogic.getUserAdmin()).thenReturn(userAdmin); when(resourceBusinessLogic.createOrUpdateResourceByImport(any(Resource.class), any(User.class), anyBoolean(), anyBoolean(), anyBoolean(), @@ -768,7 +779,8 @@ class ResourceImportManagerTest { assertNotNull(mainTemplateService); final String mainTemplateContent = new String(mainTemplateService); - return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, null, mainTemplateName, mainTemplateContent, false, mock(ModelOperation.class)); + return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, null, mainTemplateName, mainTemplateContent, false, + mock(ModelOperation.class)); } catch (URISyntaxException | ZipException e) { fail(e); }