diff options
Diffstat (limited to 'catalog-be/src/test')
2 files changed, 58 insertions, 7 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java index c6ba0ba9ac..47be73a423 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java @@ -1547,6 +1547,37 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @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; Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>(); @@ -2506,7 +2537,8 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest 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); } @@ -2516,7 +2548,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest 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); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java index df53faa3b7..14546e01d7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.openecomp.sdc.be.components.impl; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -65,6 +66,8 @@ import org.openecomp.sdc.be.components.validation.service.ServiceTypeValidator; import org.openecomp.sdc.be.components.validation.service.ServiceValidator; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.externalapi.servlet.representation.AbstractResourceInfo; @@ -93,6 +96,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.UploadCapInfo; import org.openecomp.sdc.be.model.UploadComponentInstanceInfo; +import org.openecomp.sdc.be.model.UploadInterfaceInfo; import org.openecomp.sdc.be.model.UploadNodeFilterInfo; import org.openecomp.sdc.be.model.UploadReqInfo; import org.openecomp.sdc.be.model.UploadServiceInfo; @@ -117,19 +121,17 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM protected static final String INSTANTIATION_TYPE = "A-la-carte"; protected static final String COMPONENT_ID = "myUniqueId"; protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service"; - private static final String RESOURCE_NAME = "My-Resource_Name with space"; protected static final String RESOURCE_TOSCA_NAME = "org.openecomp.resource.cp.extCP"; + private static final String RESOURCE_NAME = "My-Resource_Name with space"; private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3"; private static final String RESOURCE_SUBCATEGORY = "Router"; - - private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class); - private final ServletUtils servletUtils = mock(ServletUtils.class); - protected final ServletContext servletContext = mock(ServletContext.class); protected final ComponentValidator componentValidator = mock(ComponentValidator.class); final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = mock(ComponentInstanceBusinessLogic.class); final CsarBusinessLogic csarBusinessLogic = mock(CsarBusinessLogic.class); final CompositionBusinessLogic compositionBusinessLogic = mock(CompositionBusinessLogic.class); + private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class); + private final ServletUtils servletUtils = mock(ServletUtils.class); protected UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class); protected WebAppContextWrapper webAppContextWrapper = mock(WebAppContextWrapper.class); protected WebApplicationContext webAppContext = mock(WebApplicationContext.class); @@ -406,6 +408,23 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM return uploadCapInfoMap; } + protected Map<String, UploadInterfaceInfo> getInterfaces() { + UploadInterfaceInfo uploadInterfaceInfo = new UploadInterfaceInfo(); + uploadInterfaceInfo.setName("TestInterface"); + uploadInterfaceInfo.setDescription("Description used for testing interfaces"); + OperationDataDefinition operation = new OperationDataDefinition(); + operation.setDescription("Description used for testing operations"); + ArtifactDataDefinition implementation = new ArtifactDataDefinition(); + implementation.setArtifactName("desc"); + operation.setImplementation(implementation); + Map<String, OperationDataDefinition> operations = new HashMap<>(); + operations.put("TestInterface", operation); + uploadInterfaceInfo.setOperations(operations); + Map<String, UploadInterfaceInfo> uploadInterfaceInfoMap = new HashMap<>(); + uploadInterfaceInfoMap.put("tosca.capabilities.Node", uploadInterfaceInfo); + return uploadInterfaceInfoMap; + } + protected List<ComponentInstance> creatComponentInstances() { List<ComponentInstance> componentInstances = new ArrayList<>(); ComponentInstance componentInstance = new ComponentInstance(); |