summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test')
-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
-rw-r--r--catalog-be/src/test/resources/node-types/resource-Extcp-template.yml95
4 files changed, 136 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);
diff --git a/catalog-be/src/test/resources/node-types/resource-Extcp-template.yml b/catalog-be/src/test/resources/node-types/resource-Extcp-template.yml
new file mode 100644
index 0000000000..4302a129d7
--- /dev/null
+++ b/catalog-be/src/test/resources/node-types/resource-Extcp-template.yml
@@ -0,0 +1,95 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+metadata:
+ invariantUUID: 93047af6-cd60-401a-b60b-346d67314aeb
+ UUID: e6e6753a-11a7-41d3-b563-90e4a2e5606d
+ name: ExtCP
+ description: The AT&T Connection Point base type all other CP derive from
+ model:
+ category: Generic
+ type: CP
+ subcategory: Network Elements
+ resourceVendor: ONAP (Tosca)
+ resourceVendorRelease: 1.0.0.wd03
+ reourceVendorModelNumber: ''
+imports:
+- nodes:
+ file: nodes.yml
+- datatypes:
+ file: data.yml
+- capabilities:
+ file: capabilities.yml
+- relationships:
+ file: relationships.yml
+- groups:
+ file: groups.yml
+- policies:
+ file: policies.yml
+node_types:
+ org.openecomp.resource.cp.extCP:
+ derived_from: tosca.nodes.Root
+ description: The AT&T Connection Point base type all other CP derive from
+ properties:
+ ip_requirements:
+ type: list
+ description: identifies IP requirements to the CP
+ required: true
+ entry_schema:
+ type: org.openecomp.datatypes.network.IpRequirements
+ network_role:
+ type: string
+ description: identical to VL network_role
+ required: true
+ subnetpoolid:
+ type: string
+ required: false
+ mac_requirements:
+ default:
+ mac_count_required:
+ is_required: false
+ type: org.openecomp.datatypes.network.MacRequirements
+ description: identifies MAC address assignments to the CP
+ required: false
+ exCP_naming:
+ default:
+ ecomp_generated_naming: true
+ type: org.openecomp.datatypes.Naming
+ required: false
+ vlan_requirements:
+ type: list
+ description: identifies vlan address assignments to the CP
+ required: false
+ entry_schema:
+ type: org.openecomp.datatypes.network.VlanRequirements
+ network_role_tag:
+ type: string
+ description: Must correlate to the set of defined network-role tag identifiers
+ from the associated HEAT template
+ required: true
+ capabilities:
+ internal_connectionPoint:
+ type: tosca.capabilities.Node
+ occurrences:
+ - 0
+ - UNBOUNDED
+ valid_source_types:
+ - tosca.nodes.network.Port
+ requirements:
+ - virtualBinding:
+ occurrences:
+ - 0
+ - UNBOUNDED
+ capability: tosca.capabilities.network.Bindable
+ relationship: tosca.relationships.network.BindsTo
+ - virtualLink:
+ occurrences:
+ - 0
+ - UNBOUNDED
+ capability: tosca.capabilities.network.Linkable
+ relationship: tosca.relationships.network.LinksTo
+ - external_virtualLink:
+ occurrences:
+ - 0
+ - UNBOUNDED
+ capability: tosca.capabilities.network.Linkable
+ node: org.openecomp.resource.vl.VL
+ relationship: tosca.relationships.network.LinksTo