summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-08-16 17:28:10 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-08-25 11:02:32 +0000
commitf7776389f137cb881033d77d89cc3f1eb4974077 (patch)
tree2f084f62801873351bcbd851aa382fee96393110 /catalog-be/src/test/java
parent35841a655443834474b48d94ae8b124d6f0896ff (diff)
Import VSP with non-standard data types
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3673 Change-Id: I0fd16410788da3a82c74b1d38ffa4458e85e6ccc
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogicTest.java13
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java4
5 files changed, 34 insertions, 11 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
index fddb79afb6..07a8ded378 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
@@ -127,10 +127,10 @@ public class CsarInfoTest {
}
@Test
- public void csarCheckNodeTypesInfoTest() {
+ public void csarCheckTypesInfoTest() {
// when
- Map<String, NodeTypeInfo> nodeTypeInfoMap = csarInfo.extractNodeTypesInfo();
+ Map<String, NodeTypeInfo> nodeTypeInfoMap = csarInfo.extractTypesInfo();
NodeTypeInfo nodeTypeInfo = nodeTypeInfoMap.get(NODE_TYPE);
// then
@@ -140,6 +140,10 @@ public class CsarInfoTest {
assertEquals(MAIN_TEMPLATE_NAME, csarInfo.getMainTemplateName());
assertEquals(csarInfo.getMainTemplateName(), nodeTypeInfo.getTemplateFileName());
+
+ Map<String, Object> dataTypes = csarInfo.getDataTypes();
+ assertTrue(dataTypes.containsKey("tosca.datatypes.testDataType.FromMainTemplate"));
+ assertTrue(dataTypes.containsKey("tosca.datatypes.testDataType.FromGlobalSub"));
}
@Test
@@ -176,15 +180,15 @@ public class CsarInfoTest {
final String nodeTypeInSubstitutionMapping = (String) ((Map<String, Object>)((Map<String, Object>)csarInfo.getMappedToscaMainTemplate().get("topology_template")).get("substitution_mappings")).get("node_type");
assertTrue(((Map<String, Object>) csarInfo.getMappedToscaMainTemplate().get("node_types")).containsKey(nodeTypeInSubstitutionMapping));
- assertTrue(csarInfo.extractNodeTypesInfo().isEmpty());
+ assertTrue(csarInfo.extractTypesInfo().isEmpty());
}
@Test
public void testCreateCsarInfoVnfWithNodeTypeInGlobalSub() throws URISyntaxException, ZipException {
final CsarInfo csarInfo = createCsarInfo("nodeTypeInGlobalSub.csar", "Definitions/MainServiceTemplate.yaml");
- assertEquals(1, csarInfo.extractNodeTypesInfo().size());
- final NodeTypeInfo nodeTypeInfo = csarInfo.extractNodeTypesInfo().get("tosca.nodes.l3vpn");
+ assertEquals(1, csarInfo.extractTypesInfo().size());
+ final NodeTypeInfo nodeTypeInfo = csarInfo.extractTypesInfo().get("tosca.nodes.l3vpn");
assertNotNull(nodeTypeInfo);
assertEquals("Definitions/GlobalSubstitutionTypesServiceTemplate.yaml", nodeTypeInfo.getTemplateFileName());
assertEquals("tosca.nodes.l3vpn", nodeTypeInfo.getType());
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogicTest.java
index ef334f5510..08d0787b27 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogicTest.java
@@ -58,6 +58,8 @@ class ModelBusinessLogicTest {
private ModelBusinessLogic modelBusinessLogic;
@Mock
private ModelOperation modelOperation;
+ @Mock
+ private DataTypeImportManager dataTypeImportManager;
private Model model;
private final Path modelImportsResourcePath = Path.of("src/test/resources/modelImports");
@@ -78,6 +80,17 @@ class ModelBusinessLogicTest {
assertThat(result).isNotNull();
assertThat(result.getName()).isEqualTo(model.getName());
}
+
+ @Test
+ void createModelWithDataTypesTest() {
+ final String dataTypes = "dummyString";
+ when(modelOperation.createModel(model, false)).thenReturn(model);
+ final Model result = modelBusinessLogic.createModel(model, dataTypes);
+ assertThat(result).isNotNull();
+ assertThat(result.getName()).isEqualTo(model.getName());
+
+ verify(dataTypeImportManager).createDataTypes(dataTypes, model.getName());
+ }
@Test
void createModelFailTest() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index 542b142c21..6b52ed8d87 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -190,7 +190,8 @@ public class ResourceBusinessLogicTest {
private final IGroupOperation groupOperation = Mockito.mock(IGroupOperation.class);
private final IGroupInstanceOperation groupInstanceOperation = Mockito.mock(IGroupInstanceOperation.class);
private final IGroupTypeOperation groupTypeOperation = Mockito.mock(IGroupTypeOperation.class);
- private final GroupBusinessLogic groupBusinessLogic = Mockito.mock(GroupBusinessLogic.class);
+ private final GroupBusinessLogic groupBusinessLogic = Mockito.mock(GroupBusinessLogic.class);
+ private final ModelBusinessLogic modelBusinessLogic = Mockito.mock(ModelBusinessLogic.class);
private final InterfaceOperation interfaceOperation = Mockito.mock(InterfaceOperation.class);
private final ArtifactsOperations artifactToscaOperation = Mockito.mock(ArtifactsOperations.class);
private final PropertyBusinessLogic propertyBusinessLogic = Mockito.mock(PropertyBusinessLogic.class);
@@ -313,7 +314,7 @@ public class ResourceBusinessLogicTest {
csarArtifactsAndGroupsBusinessLogic, mergeInstanceUtils, uiComponentDataConverter, csarBusinessLogic,
artifactToscaOperation, propertyBusinessLogic, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator,
- componentDescriptionValidator, policyBusinessLogic);
+ componentDescriptionValidator, policyBusinessLogic, modelBusinessLogic);
bl.setElementDao(mockElementDao);
bl.setUserAdmin(mockUserAdmin);
bl.setCapabilityTypeOperation(capabilityTypeOperation);
@@ -1460,6 +1461,8 @@ public class ResourceBusinessLogicTest {
YamlTemplateParsingHandler yamlTemplateParser = new YamlTemplateParsingHandler(mockJanusGraphDao, null, Mockito.mock(AnnotationBusinessLogic.class), null);
final ParsedToscaYamlInfo parsedToscaYamlInfo = yamlTemplateParser.parseResourceInfoFromYAML("Definitions/my_vnf.yml", resourceYml, Collections.EMPTY_MAP, Collections.EMPTY_MAP, "myVnf", resourceResponse);
+ when(propertyOperation.getDataTypeByName("tosca.datatypes.testDataType.FromMainTemplate", "testModel")).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+
when(toscaOperationFacade.getLatestByToscaResourceName(anyString(), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Resource vduCp = new Resource();
vduCp.setToscaResourceName("tosca.nodes.nfv.VduCp");
@@ -1502,6 +1505,7 @@ public class ResourceBusinessLogicTest {
resourceResponse.setModel("testModel");
resourceResponse.setResourceType(ResourceTypeEnum.VF);
resourceResponse.setProperties(new ArrayList<>());
+ resourceResponse.setCsarVersion("1.0");
Resource derivedFrom = new Resource();
List<PropertyDefinition> properties = new ArrayList<>();
@@ -1513,7 +1517,7 @@ public class ResourceBusinessLogicTest {
when(genericTypeBusinessLogic.fetchDerivedFromGenericType(any(), eq("tosca.nodes.nfv.VNF"))).thenReturn(Either.left(derivedFrom));
when(toscaOperationFacade
- .validateComponentNameAndModelExists("myVnf", "testModel", ResourceTypeEnum.VF, ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(false));
+ .validateComponentNameAndModelExists("myVnf", "testModel_myVnf1.0", ResourceTypeEnum.VF, ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(false));
when(toscaOperationFacade.addPropertyToComponent(any(), any(), any())).thenReturn(Either.left(new PropertyDefinition()));
when(toscaOperationFacade.associateComponentInstancePropertiesToComponent(any(), any())).thenReturn(Either.left(Collections.emptyMap()));
@@ -1521,7 +1525,7 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.associateDeploymentArtifactsToInstances(any(), any(), any())).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.associateInstAttributeToComponentToInstances(any(), any())).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.associateResourceInstances(any(Component.class), anyString(), anyList())).thenReturn(Either.left(Collections.EMPTY_LIST));
- when(applicationDataTypeCache.getAll(resourceResponse.getModel())).thenReturn(Either.left(emptyDataTypes));
+ when(applicationDataTypeCache.getAll("testModel_myVnf1.0")).thenReturn(Either.left(emptyDataTypes));
doAnswer(invocation -> {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instReqs = invocation.getArgument(1);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
index 059dde3254..3b7ffd70cf 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
@@ -149,7 +149,7 @@ public class YamlTemplateParsingHandlerTest {
Resource resource = new Resource();
ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
- csarInfo.extractNodeTypesInfo(), NODE_NAME, resource);
+ csarInfo.extractTypesInfo(), NODE_NAME, resource);
validateParsedYaml(parsedYaml, NESTED_GROUP_NAME,
Lists.newArrayList("heat_file", "description"));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java
index 47ca94dbdc..46040ca2d6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java
@@ -30,6 +30,7 @@ import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.CompositionBusinessLogic;
import org.openecomp.sdc.be.components.impl.InputsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ModelBusinessLogic;
import org.openecomp.sdc.be.components.impl.OutputsBusinessLogic;
import org.openecomp.sdc.be.components.impl.PolicyBusinessLogic;
import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
@@ -68,6 +69,7 @@ public class CheckoutTest extends LifecycleTestBase {
private final ComponentContactIdValidator componentContactIdValidator = new ComponentContactIdValidator(componentsUtils);
private final ComponentNameValidator componentNameValidator = new ComponentNameValidator(componentsUtils, toscaOperationFacade);
private final PolicyBusinessLogic policyBusinessLogic = Mockito.mock(PolicyBusinessLogic.class);
+ private final ModelBusinessLogic modelBusinessLogic = Mockito.mock(ModelBusinessLogic.class);
@InjectMocks
ResourceBusinessLogic bl = new ResourceBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic,
@@ -75,7 +77,7 @@ public class CheckoutTest extends LifecycleTestBase {
resourceDataMergeBusinessLogic, csarArtifactsAndGroupsBusinessLogic, mergeInstanceUtils,
uiComponentDataConverter, csarBusinessLogic, artifactToscaOperation, propertyBusinessLogic,
componentContactIdValidator, componentNameValidator, componentTagsValidator, componentValidator,
- componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator ,policyBusinessLogic);
+ componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator ,policyBusinessLogic, modelBusinessLogic);
@Before
public void setup() {