import static org.mockito.Mockito.anyMap;
import static org.mockito.Mockito.contains;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.isNull;
import static org.mockito.Mockito.matches;
.thenReturn(Either.left(newService));
when(toscaOperationFacade.validateCsarUuidUniqueness(anyString())).thenReturn(StorageOperationStatus.OK);
ServiceCsarInfo csarInfo = getCsarInfo();
- when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString())).thenReturn(csarInfo);
+ when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString(), any())).thenReturn(csarInfo);
when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), any(Service.class)))
.thenReturn(Either.left(new HashMap<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>>()));
- when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), any(), any(Service.class)))
- .thenReturn(getParsedToscaYamlInfo());
+ doReturn(getParsedToscaYamlInfo()).when(csarBusinessLogic)
+ .getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), any(), any(Service.class));
+ doReturn(getParsedToscaYamlInfo()).when(csarBusinessLogic).getParsedToscaYamlInfo(any(ServiceCsarInfo.class), any(Service.class));
when(serviceBusinessLogic.lockComponentByName(newService.getSystemName(), oldService, CREATE_RESOURCE)).thenReturn(Either.left(true));
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(createOldResource()));
- when(serviceImportParseLogic.createServiceTransaction(oldService, csarInfo.getModifier(), false)).thenReturn(newService);
+ when(serviceImportParseLogic.createServiceTransaction(oldService, csarInfo.getModifier(), false,
+ AuditingActionEnum.CREATE_RESOURCE)).thenReturn(newService);
when(serviceImportParseLogic.createInputsOnService(eq(oldService), anyMap())).thenReturn(newService);
Assertions.assertDoesNotThrow(() -> {
when(serviceImportParseLogic.createSubstitutionFilterOnService(eq(oldService), any())).thenReturn(newService);
properties.add(versionProperty);
typeToBeUpdated.setProperties(properties);
when(applicationDataTypeCache.get(any(), eq("onap.datatypes.ToscaConceptIdentifier.datatype"))).thenReturn(Either.left(typeToBeUpdated));
- when(applicationDataTypeCache.get(any(), matches("^((?!(tosca.datatypes.test_|onap.datatypes.ToscaConceptIdentifier)).)*$"))).thenReturn(Either.left(new DataTypeDefinition()));
+ when(applicationDataTypeCache.get(any(), matches("^((?!(tosca.datatypes.test_|onap.datatypes.ToscaConceptIdentifier)).)*$"))).thenReturn(
+ Either.left(new DataTypeDefinition()));
- when(artifactTypeOperation.getArtifactTypeByUid(contains("tosca.testartifacts.Name"))).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ when(artifactTypeOperation.getArtifactTypeByUid(contains("tosca.testartifacts.Name"))).thenReturn(
+ Either.right(StorageOperationStatus.NOT_FOUND));
when(artifactTypeOperation.getArtifactTypeByUid(contains("tosca.artifacts"))).thenReturn(Either.left(null));
when(interfaceLifecycleTypeOperation.getInterface(contains("tosca.interfaces"))).thenReturn(Either.left(new InterfaceDefinition()));
- when(interfaceLifecycleTypeOperation.getInterface(contains("tosca.interfaces.test"))).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-
+ when(interfaceLifecycleTypeOperation.getInterface(contains("tosca.interfaces.test"))).thenReturn(
+ Either.right(StorageOperationStatus.NOT_FOUND));
when(capabilityTypeOperation.getCapabilityType(anyString()))
.thenReturn(Either.left(new CapabilityTypeDefinition()));
.thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
when(toscaOperationFacade.getLatestByToscaResourceName(contains("org.openecomp.resource"), isNull()))
- .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
when(toscaOperationFacade.getLatestByToscaResourceName(contains("tosca.nodes."), isNull()))
- .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
when(toscaOperationFacade.getLatestByToscaResourceName(updatedNodeType, null)).thenReturn(Either.left(resource));
- when(artifactsBusinessLogic.handleDownloadRequestById(resourceUniqueId, artifactUniqueId, user.getUserId(), ComponentTypeEnum.RESOURCE, null, null))
- .thenReturn(resourceTemplate);
+ when(toscaOperationFacade.getLatestByToscaResourceName(contains("org.openecomp.service."), isNull()))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ when(artifactsBusinessLogic.handleDownloadRequestById(resourceUniqueId, artifactUniqueId, user.getUserId(), ComponentTypeEnum.RESOURCE, null,
+ null))
+ .thenReturn(resourceTemplate);
when(toscaOperationFacade.updatePropertyOfComponent(eq(oldService), any(PropertyDefinition.class))).thenReturn(Either.left(null));
when(toscaOperationFacade.updateComponentInstancePropsToComponent(anyMap(), anyString())).thenReturn(Either.left(null));
when(groupTypeOperation.getGroupTypeByUid(anyString())).thenReturn(Either.left(new GroupTypeDefinition()));
assertNotNull(yamlMap.get("onap.datatypes.ToscaConceptIdentifier"));
ArgumentCaptor<String> artifactTypes = ArgumentCaptor.forClass(String.class);
- verify(artifactTypeImportManager).createArtifactTypes(artifactTypes.capture(),isNull(), anyBoolean());
+ verify(artifactTypeImportManager).createArtifactTypes(artifactTypes.capture(), isNull(), anyBoolean());
Map<String, Object> artifactTypesMap = new Yaml().load(artifactTypes.getValue());
assertEquals(1, artifactTypesMap.size());
assertNotNull(artifactTypesMap.get("tosca.testartifacts.Name"));
assertNotNull(capabilityTypesMap.get("tosca.testcapabilitytypes.Name"));
ArgumentCaptor<Map<String, Object>> nodeTypes = ArgumentCaptor.forClass(Map.class);
- verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(),
- anyBoolean(), anyBoolean());
+ verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(), any(),
+ anyBoolean(), anyBoolean());
Map<String, Object> nodeTypesMap = nodeTypes.getValue();
Map<String, Object> newUpdatedNodeType = (Map<String, Object>) nodeTypesMap.get(updatedNodeType);
assertEquals(8, ((Map<String, Object>) newUpdatedNodeType.get("properties")).size());
when(serviceBusinessLogic.validateServiceBeforeCreate(any(Service.class), any(User.class), any(AuditingActionEnum.class)))
.thenReturn(Either.left(newService));
when(toscaOperationFacade.validateCsarUuidUniqueness(anyString())).thenReturn(StorageOperationStatus.OK);
- when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString())).thenReturn(getCsarInfo());
+ when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString(), any())).thenReturn(getCsarInfo());
when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), any(Service.class)))
.thenReturn(Either.right(ActionStatus.GENERAL_ERROR));
when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), anyString(),
new HashedMap();
when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class),
- any(Map.class), anyString())).thenReturn(csarInfo);
+ any(Map.class), anyString(), any())).thenReturn(csarInfo);
when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class),
any(Service.class))).thenReturn(Either.left(map));
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceFromCsar(oldService,
- user, payload, csarUUID));
+ user, payload, csarUUID, null));
}
@Test
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceFromYaml(oldService,
topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo,
- nodeTypesArtifactsToCreate, false, true, nodeName, user.getUserId()));
+ nodeTypesArtifactsToCreate, false, true, nodeName, user.getUserId(), null));
}
@Test
csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource));
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService,
- false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId()));
+ false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId(), null));
}
@Test
csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource));
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService,
- false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId()));
+ false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId(), null));
}
@Test
artifactDefinition.setArtifactName("artifactDefinition");
deploymentArtifacts.put("deploymentArtifacts", artifactDefinition);
preparedService.setDeploymentArtifacts(deploymentArtifacts);
- String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
- NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName, nodeTypesArtifactsToHandle);
when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(createServiceObject(true)));
when(csarArtifactsAndGroupsBusinessLogic.updateResourceArtifactsFromCsar(any(CsarInfo.class), any(Service.class),
anyString(), anyString(), anyList(), anyBoolean(), anyBoolean())).thenReturn(Either.left(preparedService));
Assertions.assertNotNull(
sIBL.createOrUpdateArtifacts(operation, createdArtifacts, yamlFileName, csarInfo,
- preparedService, nodeTypeInfoToUpdateArtifacts, true, true));
+ preparedService, true, true));
}
@Test
any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition);
when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat);
when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(service));
- Assertions.assertNotNull(sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap));
+ Assertions.assertNotNull(sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap, null));
}
@Test
Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
Assertions.assertThrows(ComponentException.class,
- () -> sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap));
+ () -> sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap, null));
}
@Test
originResource);
}
+ @Test
+ void testProcessComponentInstanceInterfaces() {
+ Service service = createServiceObject(true);
+ service.setModel("testModel");
+ Map<String, Map<String, InterfaceDefinition>> instInterfaces = new HashMap<>();
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ uploadComponentInstanceInfo.setInterfaces(getInterfaces());
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ Resource originResource = createParseResourceObject(false);
+ Assertions.assertNotNull(originResource);
+
+ InterfaceDefinition interfaceDef = new InterfaceDefinition();
+ interfaceDef.setUniqueId("tosca.interfaces.lifecycle.TestInterface");
+ Map<String, InterfaceDefinition> interfaceLifecycleTypes = new HashMap<>();
+ interfaceLifecycleTypes.put("tosca.interfaces.lifecycle.TestInterface", interfaceDef);
+ when(interfaceLifecycleTypeOperation.getAllInterfaceLifecycleTypes("testModel")).thenReturn(Either.left(interfaceLifecycleTypes));
+
+ sIBL.addInterfaceValuesToRi(uploadComponentInstanceInfo, service, originResource, currentCompInstance, instInterfaces);
+ }
+
+ @Test
+ void testProcessComponentInstanceInterfaces_null() {
+ Service service = createServiceObject(true);
+ Map<String, Map<String, InterfaceDefinition>> instInterfaces = new HashMap<>();
+ UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
+ ComponentInstance currentCompInstance = new ComponentInstance();
+ Resource originResource = createParseResourceObject(false);
+ Assertions.assertNotNull(originResource);
+ sIBL.addInterfaceValuesToRi(uploadComponentInstanceInfo, service, originResource, currentCompInstance, instInterfaces);
+ }
+
@Test
void testUpdateCapabilityPropertiesValues() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null;
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);
}
private ImmutablePair<String, byte[]> getNodeType() {
try {
File resource = new File(
- ServiceImportBusinessLogicTest.class.getClassLoader().getResource("node-types/resource-Extcp-template.yml").toURI());
+ ServiceImportBusinessLogicTest.class.getClassLoader().getResource("node-types/resource-Extcp-template.yml").toURI());
byte[] extcpResource = Files.readAllBytes(resource.toPath());
return new ImmutablePair<>("org.openecomp.resource.cp.extCP", extcpResource);