summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2022-08-15 13:40:19 +0100
committerMichael Morris <michael.morris@est.tech>2022-09-06 16:45:46 +0000
commit745e350c8595f7e44846a3de1d2c946485a63ad0 (patch)
treea6f78fdba6aaa243172d50ae3f1a8723975847b3 /catalog-be/src/test/java
parentc7d44853b881daadccc6c05cddcbb89743f1bffc (diff)
Support import of updated node types
Support addition of new properties Issue-ID: SDC-4131 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I9f12d0f4f9727c33f8444980b780758533e714cf
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java42
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java1
3 files changed, 41 insertions, 4 deletions
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 04a87e1db4..9c583729f0 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
@@ -494,7 +494,7 @@ class ResourceImportManagerTest {
.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));
- importManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, false, false);
+ importManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, "", false, false);
verify(janusGraphDao).commit();
}
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 3f8f9c382c..a77ef5bd76 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
@@ -115,6 +115,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
import org.openecomp.sdc.be.tosca.CsarUtils;
+import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
@@ -173,6 +174,18 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
jsonObject.put(ToscaGetFunctionType.GET_INPUT.getFunctionName(), "zxjTestImportServiceAb_propertiesName");
componentInstanceProperty.setValue(jsonObject.toJSONString());
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifactDef = new ArtifactDefinition();
+ String artifactUniqueId = "test_extcp_resource.assettoscatemplate";
+ artifactDef.setUniqueId(artifactUniqueId);
+ toscaArtifacts.put(ToscaExportHandler.ASSET_TOSCA_TEMPLATE, artifactDef);
+ Resource resource = new Resource();
+ String resourceUniqueId = "extcp_resource";
+ resource.setUniqueId(resourceUniqueId);
+ resource.setToscaArtifacts(toscaArtifacts);
+ ImmutablePair<String, byte[]> resourceTemplate = getNodeType();
+ String updatedNodeType = "org.openecomp.resource.cp.extCP";
+
newService.setComponentInstancesProperties(
Collections.singletonMap(COMPONENT_ID + "." + "zxjTestImportServiceAb", Collections.singletonList(componentInstanceProperty)));
newService.setProperties(getProperties());
@@ -234,8 +247,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
- when(toscaOperationFacade.getLatestByToscaResourceName(contains("org.openecomp.resource"), isNull())).thenReturn(Either.left(null));
- when(toscaOperationFacade.getLatestByToscaResourceName(contains("tosca.nodes."), isNull())).thenReturn(Either.left(null));
+ when(toscaOperationFacade.getLatestByToscaResourceName(contains("org.openecomp.resource"), isNull()))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ when(toscaOperationFacade.getLatestByToscaResourceName(contains("tosca.nodes."), isNull()))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ when(toscaOperationFacade.getLatestByToscaResourceName(contains(updatedNodeType), isNull())).thenReturn(Either.left(resource));
+ 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));
@@ -258,6 +276,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
assertNotNull(yamlMap.get("tosca.datatypes.test_a"));
assertNotNull(yamlMap.get("tosca.datatypes.test_b"));
assertNotNull(yamlMap.get("onap.datatypes.ToscaConceptIdentifier"));
+
+ ArgumentCaptor<Map<String, Object>> nodeTypes = ArgumentCaptor.forClass(Map.class);
+ verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), 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());
}
@Test
@@ -2431,6 +2456,19 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
return null;
}
+ private ImmutablePair<String, byte[]> getNodeType() {
+ try {
+ File resource = new File(
+ 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);
+ } catch (URISyntaxException | IOException e) {
+ fail(e);
+ }
+ return null;
+ }
+
protected CsarUtils.NonMetaArtifactInfo getNonMetaArtifactInfo() {
String artifactName = "artifactName", path = "/src/test/resources/valid_vf.csar", artifactType = "AAI_SERVICE_MODEL";
ArtifactGroupTypeEnum artifactGroupType = ArtifactGroupTypeEnum.TOSCA;
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 fd39b65db0..ecec834599 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
@@ -131,7 +131,6 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM
private static final String RESOURCE_SUBCATEGORY = "Router";
private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class);
- private final ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
private final ServletUtils servletUtils = mock(ServletUtils.class);
protected final ServletContext servletContext = mock(ServletContext.class);