diff options
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/tosca')
31 files changed, 689 insertions, 3523 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java deleted file mode 100644 index 38bf484595..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.openecomp.sdc.be.tosca; - -import java.util.List; - -import org.junit.Test; -import org.onap.sdc.generator.data.ArtifactType; - - -public class ArtifactTypesTest { - - private ArtifactTypes createTestSubject() { - return new ArtifactTypes(); - } - - - @Test - public void testGetArtifactTypes() throws Exception { - ArtifactTypes testSubject; - List<ArtifactType> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactTypes(); - } - - - @Test - public void testSetArtifactTypes() throws Exception { - ArtifactTypes testSubject; - List<ArtifactType> artifactTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactTypes(artifactTypes); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverterTest.java index 5f051b7970..675c51d635 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverterTest.java @@ -1,18 +1,6 @@ package org.openecomp.sdc.be.tosca; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.doReturn; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -32,24 +20,31 @@ import org.openecomp.sdc.be.model.RequirementDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.tosca.ToscaUtils.SubstituitionEntry; import org.openecomp.sdc.be.tosca.model.SubstitutionMapping; import org.openecomp.sdc.be.tosca.model.ToscaNodeTemplate; import org.openecomp.sdc.be.tosca.model.ToscaNodeType; import org.openecomp.sdc.be.tosca.model.ToscaTemplateCapability; + import fj.data.Either; import mockit.Deencapsulation; -public class CapabiltyRequirementConvertorTest { +import java.util.*; +import java.util.stream.Collectors; + +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.doReturn; + +public class CapabilityRequirementConverterTest { @InjectMocks - CapabiltyRequirementConvertor testSubject; + CapabilityRequirementConverter testSubject; @Mock ToscaOperationFacade toscaOperationFacade; - CapabiltyRequirementConvertor capabiltyRequirementConvertor = Mockito.spy(new CapabiltyRequirementConvertor()); + CapabilityRequirementConverter capabiltyRequirementConvertor = Mockito.spy(new CapabilityRequirementConverter()); ComponentInstance instanceProxy = Mockito.spy(new ComponentInstance()); ComponentInstance vfInstance = Mockito.spy(new ComponentInstance()); Component vfComponent = Mockito.spy(new Resource()); @@ -63,7 +58,7 @@ public class CapabiltyRequirementConvertorTest { @Test public void testGetInstance() { - CapabiltyRequirementConvertor.getInstance(); + CapabilityRequirementConverter.getInstance(); } @Test @@ -74,7 +69,7 @@ public class CapabiltyRequirementConvertorTest { Map<String, DataTypeDefinition> testDataTypes = new HashMap<String, DataTypeDefinition>(); capabilities.get("att.Node").clear(); - testSubject.convertComponentInstanceCapabilties(vfInstance, testDataTypes, nodeTemplate); + testSubject.convertComponentInstanceCapabilities(vfInstance, testDataTypes, nodeTemplate); capabilities = newCapabilities("port"); vfInstance.setCapabilities(capabilities); @@ -84,7 +79,7 @@ public class CapabiltyRequirementConvertorTest { Mockito.any(ComponentParametersView.class))) .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); - testSubject.convertComponentInstanceCapabilties(vfInstance, testDataTypes, nodeTemplate); + testSubject.convertComponentInstanceCapabilities(vfInstance, testDataTypes, nodeTemplate); } @@ -102,48 +97,11 @@ public class CapabiltyRequirementConvertorTest { Mockito.any(ComponentParametersView.class))) .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); - testSubject.convertComponentInstanceCapabilties(vfInstance, testDataTypes, nodeTemplate); + testSubject.convertComponentInstanceCapabilities(vfInstance, testDataTypes, nodeTemplate); } - @Test - public void testConvertOverridenProperty() { - ComponentInstance instance = new ComponentInstance(); - Map<String, DataTypeDefinition> testDataTypes = new HashMap<String, DataTypeDefinition>(); - Map<String, ToscaTemplateCapability> capabilities = new HashMap<>(); - ComponentInstanceProperty p = new ComponentInstanceProperty(); - SchemaDefinition entrySchema = new SchemaDefinition(); - entrySchema.setProperty(new PropertyDataDefinition()); - p.setSchema(entrySchema); - - Deencapsulation.invoke(testSubject, "convertOverridenProperty", instance, testDataTypes, capabilities, p, - "port"); - } - - @Test - public void testConvertRequirements() { - ToscaNodeType nodeType = new ToscaNodeType(); - - testSubject.convertRequirements(vfComponent, nodeType); - - } - - @Test - public void testConvertRequirements_1() { - ToscaNodeType nodeType = new ToscaNodeType(); - Map<String, List<RequirementDefinition>> requirementsMap = new HashMap<String, List<RequirementDefinition>>(); - - List<RequirementDefinition> requirementsArray = new ArrayList<RequirementDefinition>(); - RequirementDefinition definition = new RequirementDefinition(); - definition.setOwnerId("id"); - requirementsArray.add(definition); - requirementsMap.put("key", requirementsArray); - vfComponent.setRequirements(requirementsMap); - vfComponent.setUniqueId("id"); - testSubject.convertRequirements(vfComponent, nodeType); - - } @Test public void testConvertSubstitutionMappingRequirements() { @@ -273,108 +231,6 @@ public class CapabiltyRequirementConvertorTest { } @Test - public void testBuildSubstitutedNamePerInstance() { - Map<String, Component> componentsCache = new HashMap<>(); - String name = "name"; - String ownerId = "id"; - List<String> path = new ArrayList<>(); - path.add("id"); - SubstituitionEntry entry = new SubstituitionEntry(); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - instance.setComponentUid("uid"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class), - Mockito.any(ComponentParametersView.class))) - .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); - - Deencapsulation.invoke(testSubject, "buildSubstitutedNamePerInstance", componentsCache, vfComponent, name, path, - ownerId, entry); - } - - @Test - public void testConvertRequirement() { - RequirementDefinition definition = new RequirementDefinition(); - List<String> path = new ArrayList<>(); - path.add("value"); - path.add("id"); - definition.setName("name"); - definition.setPath(path); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - Deencapsulation.invoke(testSubject, "convertRequirement", vfComponent, false, definition); - } - - @Test - public void testConvertRequirement_1() { - RequirementDefinition definition = new RequirementDefinition(); - List<String> path = new ArrayList<>(); - path.add("id"); - definition.setName("name"); - definition.setPath(path); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - Deencapsulation.invoke(testSubject, "convertRequirement", vfComponent, false, definition); - } - - @Test - public void testConvertRequirement_2() { - RequirementDefinition definition = new RequirementDefinition(); - List<String> path = new ArrayList<>(); - path.add("id"); - definition.setName("name"); - definition.setPath(path); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - path.add("value"); - definition.setPath(path); - definition.setMaxOccurrences("1000"); - - Deencapsulation.invoke(testSubject, "convertRequirement", vfComponent, false, definition); - } - - @Test - public void testConvertCapabilities() { - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - - testSubject.convertCapabilities(vfComponent, dataTypes); - - Map<String, List<CapabilityDefinition>> capabilitiesMap = new HashMap<String, List<CapabilityDefinition>>(); - List<CapabilityDefinition> capabilitiesArray = new ArrayList<CapabilityDefinition>(); - CapabilityDefinition definition = new CapabilityDefinition(); - definition.setOwnerId("id"); - capabilitiesArray.add(definition); - capabilitiesMap.put("key", capabilitiesArray); - vfComponent.setUniqueId("id"); - vfComponent.setCapabilities(capabilitiesMap); - - testSubject.convertCapabilities(vfComponent, dataTypes); - } - - @Test public void testConvertProxyCapabilities() { Map<String, Component> componentsCache = new HashMap<>(); Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); @@ -448,110 +304,6 @@ public class CapabiltyRequirementConvertorTest { testSubject.convertSubstitutionMappingCapabilities(componentsCache, vfComponent); } - @Test - public void testGetCapabilityPath() { - CapabilityDefinition definition = new CapabilityDefinition(); - List<String> path = new ArrayList<>(); - path.add("value"); - path.add("id"); - definition.setName("name"); - definition.setPath(path); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - Deencapsulation.invoke(testSubject, "getCapabilityPath", definition, vfComponent); - } - - @Test - public void testGetCapabilityPath_1() { - CapabilityDefinition definition = new CapabilityDefinition(); - List<String> path = new ArrayList<>(); - path.add("id"); - definition.setName("name"); - definition.setPath(path); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - Deencapsulation.invoke(testSubject, "getCapabilityPath", definition, vfComponent); - } - - @Test - public void testGetCapabilityPath_2() { - CapabilityDefinition definition = new CapabilityDefinition(); - List<String> path = new ArrayList<>(); - path.add("id"); - definition.setName("name"); - definition.setPath(path); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - path.add("value"); - definition.setPath(path); - - Deencapsulation.invoke(testSubject, "getCapabilityPath", definition, vfComponent); - } - - @Test - public void testConvertCapability_1() { - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - - Map<String, List<CapabilityDefinition>> capabilitiesMap = new HashMap<String, List<CapabilityDefinition>>(); - List<CapabilityDefinition> capabilitiesArray = new ArrayList<CapabilityDefinition>(); - CapabilityDefinition definition = new CapabilityDefinition(); - List<ComponentInstanceProperty> properties = new ArrayList<>(); - properties.add(new ComponentInstanceProperty()); - definition.setOwnerId("id"); - definition.setName("name"); - definition.setProperties(properties); - definition.setMaxOccurrences("1000"); - List<String> path = new ArrayList<>(); - path.add("value"); - path.add("id"); - definition.setPath(path); - capabilitiesArray.add(definition); - capabilitiesMap.put("key", capabilitiesArray); - vfComponent.setUniqueId("id"); - vfComponent.setCapabilities(capabilitiesMap); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - componentInstances.add(instance); - - vfComponent.setComponentInstances(componentInstances); - - Deencapsulation.invoke(testSubject, "convertCapabilty", vfComponent, new HashMap<>(), false, definition, - dataTypes, "name"); - } - - @Test - public void testBuildSubstitutedName() { - ComponentInstance instance = new ComponentInstance(); - instance.setUniqueId("id"); - List<ComponentInstance> resourceInstances = new ArrayList<>(); - resourceInstances.add(instance); - vfComponent.setComponentInstances(resourceInstances); - - List<String> path = new ArrayList<>(); - path.add("notId"); - - Deencapsulation.invoke(testSubject, "buildSubstitutedName", new HashMap<>(), vfComponent, path, "name"); - } @Test public void testAppendNameRecursively() { @@ -599,7 +351,7 @@ public class CapabiltyRequirementConvertorTest { pathList.add("5f172af9-1588-443e-8897-1432b19aad8c.2cb7514a-1e50-4280-8457-baacb97b50bf.vepdgtp4837vf0"); pathList.add("86ae128e-3d0a-41f7-a957-db1df9fe598c.9cc8f8ac-6869-4dd6-a6e1-74ecb9570dc4.vepdgtp4837svc_proxy0"); - List<String> reducedMap = new CapabiltyRequirementConvertor().getReducedPathByOwner(pathList, uniqueId); + List<String> reducedMap = new CapabilityRequirementConverter().getReducedPathByOwner( pathList , uniqueId ); assertThat(reducedMap).isNotNull().doesNotContain(exerpt).containsOnlyOnce(duplicate).hasSize(4); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java index adee99efab..cdb1cbf817 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java @@ -20,1291 +20,72 @@ package org.openecomp.sdc.be.tosca; -import static org.junit.Assert.assertTrue; +import fj.data.Either; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo; +import org.openecomp.sdc.common.api.ConfigurationSource; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; -import java.io.IOException; -import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.ImmutableTriple; -import org.apache.commons.lang3.tuple.Triple; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.sdc.generator.data.ArtifactType; -import org.openecomp.sdc.be.components.BeConfDependentTest; -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; -import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao; -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.OriginTypeEnum; -import org.openecomp.sdc.be.impl.ComponentsUtils; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.InterfaceDefinition; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; -import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.resources.data.ESArtifactData; -import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData; -import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo; -import org.openecomp.sdc.be.tosca.model.ToscaTemplate; -import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; -import org.openecomp.sdc.exception.ResponseFormat; - -import fj.data.Either; -import mockit.Deencapsulation; - -public class CsarUtilsTest extends BeConfDependentTest { - - @InjectMocks - CsarUtils testSubject; - - @Mock - private ArtifactCassandraDao artifactCassandraDao; - - @Mock - private ComponentsUtils componentsUtils; - - @Mock - private ToscaExportHandler toscaExportUtils; - - @Mock - private SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao; - - @Mock - private ToscaOperationFacade toscaOperationFacade; - - @Mock - private ArtifactsBusinessLogic artifactsBusinessLogic; - - @Before - public void setUpMock() throws Exception { - MockitoAnnotations.initMocks(this); - - } - - private NonMetaArtifactInfo createNonMetaArtifactInfoTestSubject() { - return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL, - ArtifactGroupTypeEnum.DEPLOYMENT, new byte[0], "mock", true); - } - - @Test - public void testCreateCsar() { - Component component = new Resource(); - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))) - .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR)); - - Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class))) - .thenReturn(ActionStatus.GENERAL_ERROR); - - testSubject.createCsar(component, true, true); - } - - @Test - public void testCreateCsarWithGenerateCsarZipResponseIsLeft() { - Component component = new Resource(); - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - toscaTemplate.setDependencies(dependencies); - - List<SdcSchemaFilesData> filesData = new ArrayList<>(); - SdcSchemaFilesData filedata = new SdcSchemaFilesData(); - filedata.setPayloadAsArray(data); - filesData.add(filedata); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class))) - .thenReturn(ActionStatus.GENERAL_ERROR); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - Mockito.when( - sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class))) - .thenReturn(Either.left(filesData)); - - testSubject.createCsar(component, false, true); - } - - @Test - public void testGenerateCsarZipThrowsIOException() { - Deencapsulation.invoke(testSubject, "generateCsarZip", byte[].class, byte[].class, new Resource(), true, false, - false); - } - - @Test - public void testPopulateZipWhenGetDependenciesIsRight() { - Component component = new Service(); - boolean getFromCS = false; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaRepresentation tosca = new ToscaRepresentation(); - tosca.setMainYaml("value"); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca)); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.right(ToscaError.GENERAL_ERROR)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, false, false); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testPopulateZipWhenExportComponentIsRight() { - Component component = new Resource(); - boolean getFromCS = false; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))) - .thenReturn(Either.right(ToscaError.GENERAL_ERROR)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, false, false); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testPopulateZipWhenComponentIsServiceAndCollectComponentCsarDefinitionIsRight() { - Component component = new Service(); - boolean getFromCS = false; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - component.setVersion("1.0"); - component.setLastUpdaterUserId("userId"); - component.setUniqueId("uid"); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - List<SdcSchemaFilesData> filesData = new ArrayList<>(); - SdcSchemaFilesData filedata = new SdcSchemaFilesData(); - filedata.setPayloadAsArray(data); - filesData.add(filedata); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - Triple<String, String, Component> triple = Triple.of("fileName", "cassandraId", component); - dependencies.add(triple); - toscaTemplate.setDependencies(dependencies); - - ToscaRepresentation tosca = new ToscaRepresentation(); - tosca.setMainYaml("value"); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca)); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - Mockito.when( - sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class))) - .thenReturn(Either.left(filesData)); - - Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))) - .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); - - Mockito.when(artifactsBusinessLogic.validateUserExists(Mockito.any(String.class), Mockito.any(String.class), - Mockito.any(Boolean.class))).thenReturn(Either.left(new User())); - - Mockito.when(artifactsBusinessLogic.validateAndHandleArtifact(Mockito.any(String.class), - Mockito.any(ComponentTypeEnum.class), Mockito.any(ArtifactOperationInfo.class), Mockito.isNull(), - Mockito.any(ArtifactDefinition.class), Mockito.any(String.class), Mockito.any(String.class), - Mockito.isNull(), Mockito.isNull(), Mockito.any(User.class), Mockito.any(Component.class), - Mockito.any(Boolean.class), Mockito.any(Boolean.class), Mockito.any(Boolean.class))) - .thenReturn(Either.left(Mockito.any(Either.class))); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true, true); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testPopulateZipWhenGetEntryDataIsRight() { - Component component = new Service(); - boolean getFromCS = true; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - component.setVersion("1.0"); - component.setLastUpdaterUserId("userId"); - component.setUniqueId("uid"); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - Triple<String, String, Component> triple = Triple.of("fileName", "", component); - dependencies.add(triple); - toscaTemplate.setDependencies(dependencies); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))) - .thenReturn(Either.right(ToscaError.GENERAL_ERROR)); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true, true); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testPopulateZipWhenGetEntryDataOfInnerComponentIsRight() { - Component component = new Service(); - boolean getFromCS = false; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - component.setVersion("1.0"); - component.setLastUpdaterUserId("userId"); - component.setUniqueId("uid"); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - Triple<String, String, Component> triple = Triple.of("fileName", "", component); - dependencies.add(triple); - toscaTemplate.setDependencies(dependencies); - - ToscaRepresentation tosca = new ToscaRepresentation(); - tosca.setMainYaml("value"); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca), - Either.left(tosca), Either.right(ToscaError.GENERAL_ERROR)); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true, true); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testPopulateZipWhenLatestSchemaFilesFromCassandraIsRight() { - Component component = new Service(); - boolean getFromCS = false; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - component.setVersion("1.0"); - component.setLastUpdaterUserId("userId"); - component.setUniqueId("uid"); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - Triple<String, String, Component> triple = Triple.of("fileName", "", component); - dependencies.add(triple); - toscaTemplate.setDependencies(dependencies); - - ToscaRepresentation tosca = new ToscaRepresentation(); - tosca.setMainYaml("value"); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca)); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - Mockito.when( - sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class))) - .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true, true); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testPopulateZipWhenAddSchemaFilesFromCassandraIsRight() { - Component component = new Service(); - boolean getFromCS = false; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - component.setVersion("1.0"); - component.setLastUpdaterUserId("userId"); - component.setUniqueId("uid"); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - Triple<String, String, Component> triple = Triple.of("fileName", "", component); - dependencies.add(triple); - toscaTemplate.setDependencies(dependencies); - - ToscaRepresentation tosca = new ToscaRepresentation(); - tosca.setMainYaml("value"); - - List<SdcSchemaFilesData> schemaList = new ArrayList<>(); - SdcSchemaFilesData schemaData = new SdcSchemaFilesData(); - schemaData.setPayloadAsArray(null); - schemaList.add(schemaData); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca)); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - Mockito.when( - sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class))) - .thenReturn(Either.left(schemaList)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true, true); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testPopulateZipWhenHandleAllAAIArtifactsInDataModelIsRight() { - Component component = new Service(); - boolean getFromCS = false; - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - component.setVersion("1.0"); - component.setLastUpdaterUserId("userId"); - component.setUniqueId("uid"); - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - Triple<String, String, Component> triple = Triple.of("fileName", "", component); - dependencies.add(triple); - toscaTemplate.setDependencies(dependencies); - - ToscaRepresentation tosca = new ToscaRepresentation(); - tosca.setMainYaml("value"); - - List<SdcSchemaFilesData> schemaList = new ArrayList<>(); - SdcSchemaFilesData schemaData = new SdcSchemaFilesData(); - schemaData.setPayloadAsArray(data); - schemaList.add(schemaData); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData)); - - Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca)); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - Mockito.when( - sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class))) - .thenReturn(Either.left(schemaList)); - - Mockito.when(artifactsBusinessLogic.validateUserExists(Mockito.any(String.class), Mockito.any(String.class), - Mockito.any(Boolean.class))).thenReturn(Either.right(new ResponseFormat(500))); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true, true); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testAddSchemaFilesFromCassandra() { - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - ZipOutputStream zip = new ZipOutputStream(out); - ByteArrayOutputStream outMockStream = new ByteArrayOutputStream(); - ZipOutputStream outMock = new ZipOutputStream(outMockStream);) { - - outMock.putNextEntry(new ZipEntry("mock1")); - outMock.write(new byte[1]); - outMock.putNextEntry(new ZipEntry("mock2")); - outMock.write(new byte[3]); - outMock.close(); - byte[] byteArray = outMockStream.toByteArray(); - Deencapsulation.invoke(testSubject, "addSchemaFilesFromCassandra", zip, byteArray); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - @Test - public void testAddInnerComponentsToCache() { - Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>(); - Component childComponent = new Resource(); - Component componentRI = new Service(); - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setComponentUid("resourceUid"); - componentInstances.add(instance); - childComponent.setComponentInstances(componentInstances); - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - componentRI.setToscaArtifacts(toscaArtifacts); - - Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))) - .thenReturn(Either.left(componentRI)); - - Deencapsulation.invoke(testSubject, "addInnerComponentsToCache", componentCache, childComponent); - } - - @Test - public void testAddInnerComponentsToCacheWhenGetToscaElementIsRight() { - Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>(); - Component childComponent = new Resource(); - - List<ComponentInstance> componentInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - componentInstances.add(instance); - childComponent.setComponentInstances(componentInstances); - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - - Component componentRI = new Service(); - componentRI.setToscaArtifacts(toscaArtifacts); - - Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))) - .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); - - Deencapsulation.invoke(testSubject, "addInnerComponentsToCache", componentCache, childComponent); - } - - @Test - public void testAddComponentToCache() { - Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>(); - String id = "id"; - String fileName = "fileName"; - Component component = new Resource(); - component.setInvariantUUID("key"); - component.setVersion("1.0"); - - Component cachedComponent = new Resource(); - cachedComponent.setVersion("0.3"); - - componentCache.put("key", new ImmutableTriple<String, String, Component>(id, fileName, cachedComponent)); - - Deencapsulation.invoke(testSubject, "addComponentToCache", componentCache, id, fileName, component); - } - - @Test - public void testWriteComponentInterface() { - String fileName = "name.hello"; - ToscaRepresentation tosca = new ToscaRepresentation(); - tosca.setMainYaml("value"); - - Mockito.when(toscaExportUtils.exportComponentInterface(Mockito.any(Component.class))) - .thenReturn(Either.left(tosca)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "writeComponentInterface", new Resource(), zip, fileName); - } catch (IOException e) { - e.printStackTrace(); - } - - } - - @Test - public void testHandleAAIArtifacts() { - Component component = new Service(); - component.setComponentType(ComponentTypeEnum.SERVICE); - byte[] data = "value".getBytes(); - - List<ImmutablePair<Component, byte[]>> generatorInputs = new ArrayList<>(); - generatorInputs.add(new ImmutablePair<Component, byte[]>(component, data)); - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifact.setDescription("description"); - artifact.setArtifactLabel("artifactLabel"); - toscaArtifacts.put("assettoscatemplate", artifact); - component.setToscaArtifacts(toscaArtifacts); - component.setVersion("1.3"); - - Deencapsulation.invoke(testSubject, "handleAAIArtifacts", component, false, generatorInputs); - } - - @Test - public void testHandleAllAAIArtifactsInDataModelWhenArtifactOperationDeleteAndCreateIsRight() { - Component component = new Resource(); - List<ArtifactDefinition> artifactsFromAAI = new ArrayList<>(); - ArtifactDefinition AAIartifact = new ArtifactDefinition(); - AAIartifact.setArtifactLabel("artifactLabel"); - AAIartifact.setGenerated(true); - Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); - artifactsFromAAI.add(AAIartifact); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactLabel("label"); - artifact.setGenerated(true); - deploymentArtifacts.put("label", artifact); - component.setDeploymentArtifacts(deploymentArtifacts); - component.setArtifacts(deploymentArtifacts); - component.setLastUpdaterUserId("userId"); - component.setUniqueId("id"); - - Mockito.when(artifactsBusinessLogic.validateUserExists(Mockito.any(String.class), Mockito.any(String.class), - Mockito.any(Boolean.class))).thenReturn(Either.left(new User())); - - Mockito.when(artifactsBusinessLogic.validateAndHandleArtifact(Mockito.any(String.class), - Mockito.any(ComponentTypeEnum.class), Mockito.any(ArtifactOperationInfo.class), Mockito.isNull(), - Mockito.any(ArtifactDefinition.class), Mockito.any(String.class), Mockito.any(String.class), - Mockito.isNull(), Mockito.isNull(), Mockito.any(User.class), Mockito.any(Component.class), - Mockito.any(Boolean.class), Mockito.any(Boolean.class), Mockito.any(Boolean.class))) - .thenReturn(Either.right(new ResponseFormat())); - - Deencapsulation.invoke(testSubject, "handleAllAAIArtifactsInDataModel", component, artifactsFromAAI, true, - true); - } - - @Test - public void testCheckAaiForUpdateWithGetGeneratedFalse() { - Component component = new Resource(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactLabel("label"); - artifact.setGenerated(false); - Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); - deploymentArtifacts.put("label", artifact); - component.setDeploymentArtifacts(deploymentArtifacts); - - Deencapsulation.invoke(testSubject, "checkAaiForUpdate", component, artifact); - } - - @Test - public void testCheckAaiForUpdateWithGetGeneratedTrue() { - Component component = new Resource(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactLabel("label"); - artifact.setGenerated(true); - Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); - deploymentArtifacts.put("label", artifact); - component.setDeploymentArtifacts(deploymentArtifacts); - - Deencapsulation.invoke(testSubject, "checkAaiForUpdate", component, artifact); - } - - @Test - public void testCheckAaiForUpdateWithDeploymentArtifactIsNull() { - Component component = new Resource(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactLabel("label1"); - artifact.setGenerated(true); - Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); - deploymentArtifacts.put("label", artifact); - component.setDeploymentArtifacts(deploymentArtifacts); - - Deencapsulation.invoke(testSubject, "checkAaiForUpdate", component, artifact); - } - - @Test - public void testGetEntryData() { - String cassandraId = "id"; - Component childComponent = new Resource(); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))) - .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR)); - - Deencapsulation.invoke(testSubject, "getEntryData", cassandraId, childComponent); - } - - @Test - public void testGetLatestSchemaFilesFromCassandraWhenListOfSchemasIsEmpty() { - List<SdcSchemaFilesData> filesData = new ArrayList<>(); - - Mockito.when( - sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class))) - .thenReturn(Either.left(filesData)); - Deencapsulation.invoke(testSubject, "getLatestSchemaFilesFromCassandra"); - } - - @Test - public void testArtifactGenerator() { - Component component = new Resource(); - - component.setVersion("1.0"); - - Deencapsulation.invoke(testSubject, "artifactGenerator", new ArrayList<>(), ArtifactType.class, component); - } - - @Test - public void testExtractVfcsArtifactsFromCsar() { - String key = "Artifacts/org.openecomp.resource.some/path/to/resource"; - byte[] data = "value".getBytes(); - - Map<String, byte[]> csar = new HashMap<>(); - csar.put(key, data); - - CsarUtils.extractVfcsArtifactsFromCsar(csar); - } - - @Test - public void testAddExtractedVfcArtifactWhenArtifactsContainsExtractedArtifactKey() { - ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>( - "key", new ArtifactDefinition()); - Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>(); - artifacts.put("key", new ArrayList<>()); - - Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts); - } - - @Test - public void testAddExtractedVfcArtifactWhenArtifactsDoesntContainsExtractedArtifactKey() { - ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>( - "key", new ArtifactDefinition()); - Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>(); - artifacts.put("key1", new ArrayList<>()); - - Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts); - } - - @Test - public void testExtractVfcArtifact() { - String path = "path/to/informational/artificat"; - Map<String, byte[]> map = new HashMap<>(); - map.put(path, "value".getBytes()); - Entry<String, byte[]> entry = map.entrySet().iterator().next(); - - Deencapsulation.invoke(testSubject, "extractVfcArtifact", entry, new HashMap<>()); - } - - @Test - public void testDetectArtifactGroupTypeWithExceptionBeingCaught() { - Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", Map.class); - } - - @Test - public void testDetectArtifactGroupTypeWWhenCollectedWarningMessagesContainesKey() { - Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); - - collectedWarningMessages.put("Warning - unrecognized artifact group type {} was received.", new HashSet<>()); - Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", collectedWarningMessages); - } - - @Test - public void testNonMetaArtifactInfoCtor() { - createNonMetaArtifactInfoTestSubject(); - } - - @Test - public void testNonMetaArtifactInfoGetPath() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getPath(); - } - - @Test - public void testNonMetaArtifactInfoGetArtifactName() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactName(); - } - - @Test - public void testNonMetaArtifactInfoGetArtifactType() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactType(); - } - - @Test - public void testNonMetaArtifactInfoGetDisplayName() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getDisplayName(); - } - - @Test - public void testNonMetaArtifactInfoGetArtifactGroupType() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactGroupType(); - } - - @Test - public void testNonMetaArtifactInfoGetArtifactLabel() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactLabel(); - } - - @Test - public void testNonMetaArtifactInfoGetIsFromCsar() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.isFromCsar(); - } - - @Test - public void testNonMetaArtifactInfoGetPayloadData() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getPayloadData(); - } - - @Test - public void testNonMetaArtifactInfoGetArtifaactChecksum() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactChecksum(); - } - - @Test - public void testNonMetaArtifactInfoGetArtifactUniqueId() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactUniqueId(); - } - - @Test - public void testNonMetaArtifactInfosetArtifactUniqueId() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.setArtifactUniqueId("artifactUniqueId"); - } - - @Test - public void testValidateNonMetaArtifactWithExceptionCaught() { - CsarUtils.validateNonMetaArtifact("", new byte[0], new HashMap<>()); - } - - @Test - public void testWriteAllFilesToCsarWhenWriteOperationsArtifactsToCsarIsRight() { - Component component = new Resource(); - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - Map<String, InterfaceDefinition> interfaces = new HashMap<>(); - InterfaceDefinition interfaceDef = new InterfaceDefinition(); - Map<String, OperationDataDefinition> operations = new HashMap<>(); - OperationDataDefinition operation = new OperationDataDefinition(); - ArtifactDataDefinition implementation = new ArtifactDataDefinition(); - implementation.setArtifactUUID("artifactUUID"); - implementation.setArtifactName("artifactName"); - operation.setImplementation(implementation); - operations.put("key", operation); - interfaceDef.setOperations(operations); - interfaces.put("key", interfaceDef); - ((Resource) component).setInterfaces(interfaces); - - ESArtifactData artifactData = new ESArtifactData(); - byte[] data = "value".getBytes(); - artifactData.setDataAsArray(data); - - ToscaTemplate toscaTemplate = new ToscaTemplate("version"); - List<Triple<String, String, Component>> dependencies = new ArrayList<>(); - toscaTemplate.setDependencies(dependencies); - - List<SdcSchemaFilesData> filesData = new ArrayList<>(); - SdcSchemaFilesData filedata = new SdcSchemaFilesData(); - filedata.setPayloadAsArray(data); - filesData.add(filedata); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData), - Either.right(CassandraOperationStatus.GENERAL_ERROR)); - - Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class))) - .thenReturn(ActionStatus.GENERAL_ERROR); - - Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class))) - .thenReturn(Either.left(toscaTemplate)); - - Mockito.when( - sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class))) - .thenReturn(Either.left(filesData)); - - testSubject.createCsar(component, false, true); - } - - @Test - public void testWriteOperationsArtifactsToCsarWhenComponentIsService() { - Component component = new Service(); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "writeOperationsArtifactsToCsar", component, zip); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testWriteOperationsArtifactsToCsarWhenOperationGetImplementaionIsNull() { - Component component = new Resource(); - Map<String, InterfaceDefinition> interfaces = new HashMap<>(); - InterfaceDefinition interfaceDef = new InterfaceDefinition(); - Map<String, OperationDataDefinition> operations = new HashMap<>(); - operations.put("key", new OperationDataDefinition()); - interfaceDef.setOperations(operations); - interfaces.put("key", interfaceDef); - - ((Resource) component).setInterfaces(interfaces); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "writeOperationsArtifactsToCsar", component, zip); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testWriteOperationsArtifactsToCsarWhenOperationGetArtifactNameIsNull() { - Component component = new Resource(); - - Map<String, InterfaceDefinition> interfaces = new HashMap<>(); - InterfaceDefinition interfaceDef = new InterfaceDefinition(); - Map<String, OperationDataDefinition> operations = new HashMap<>(); - OperationDataDefinition operation = new OperationDataDefinition(); - ArtifactDataDefinition implementation = new ArtifactDataDefinition(); - operation.setImplementation(implementation); - operations.put("key", operation); - interfaceDef.setOperations(operations); - interfaces.put("key", interfaceDef); - ((Resource) component).setInterfaces(interfaces); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "writeOperationsArtifactsToCsar", component, zip); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testWriteOperationsArtifactsToCsarWhenGettingArtifactFromCassandra() { - Component component = new Resource(); - - Map<String, InterfaceDefinition> interfaces = new HashMap<>(); - InterfaceDefinition interfaceDef = new InterfaceDefinition(); - Map<String, OperationDataDefinition> operations = new HashMap<>(); - OperationDataDefinition operation = new OperationDataDefinition(); - ArtifactDataDefinition implementation = new ArtifactDataDefinition(); - implementation.setArtifactName("artifactName"); - implementation.setArtifactUUID("artifactUUID"); - operation.setImplementation(implementation); - operations.put("key", operation); - interfaceDef.setOperations(operations); - interfaceDef.setToscaResourceName("toscaResourceName"); - interfaces.put("key", interfaceDef); - ((Resource) component).setInterfaces(interfaces); - component.setNormalizedName("normalizedName"); - - ESArtifactData data = new ESArtifactData(); - data.setDataAsArray("data".getBytes()); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(data)); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "writeOperationsArtifactsToCsar", component, zip); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testWriteOperationsArtifactsToCsarWhenNullPointerExceptionIsCaught() { - Component component = new Resource(); - - Map<String, InterfaceDefinition> interfaces = new HashMap<>(); - InterfaceDefinition interfaceDef = new InterfaceDefinition(); - Map<String, OperationDataDefinition> operations = new HashMap<>(); - OperationDataDefinition operation = new OperationDataDefinition(); - ArtifactDataDefinition implementation = new ArtifactDataDefinition(); - implementation.setArtifactName("artifactName"); - implementation.setArtifactUUID("artifactUUID"); - operation.setImplementation(implementation); - operations.put("key", operation); - interfaceDef.setOperations(operations); - interfaceDef.setToscaResourceName("toscaResourceName"); - interfaces.put("key", interfaceDef); - ((Resource) component).setInterfaces(interfaces); - component.setNormalizedName("normalizedName"); - - Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))) - .thenReturn(Either.left(new ESArtifactData())); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "writeOperationsArtifactsToCsar", component, zip); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testWriteArtifactDefinition() { - Component component = new Service(); - List<ArtifactDefinition> artifactDefinitionList = new ArrayList<>(); - String artifactPathAndFolder = ""; - - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.getType()); - artifactDefinitionList.add(artifact); - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) { - Deencapsulation.invoke(testSubject, "writeArtifactDefinition", component, zip, artifactDefinitionList, - artifactPathAndFolder, false); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testCollectComponentCsarDefinitionWhenComponentIsServiceAndGetToscaElementIsLeft() { - Component component = new Service(); - component.setUniqueId("uniqueId"); - List<ComponentInstance> resourceInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setComponentUid("resourceUid"); - instance.setOriginType(OriginTypeEnum.SERVICE); - resourceInstances.add(instance); - component.setComponentInstances(resourceInstances); - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - - Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component), - Either.right(StorageOperationStatus.BAD_REQUEST)); - - Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component); - - } - - @Test - public void testCollectComponentTypeArtifactsWhenFetchedComponentHasComponentInstances() { - Component component = new Service(); - Component fetchedComponent = new Resource(); - component.setUniqueId("uniqueId"); - List<ComponentInstance> resourceInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setComponentUid("resourceUid"); - instance.setOriginType(OriginTypeEnum.SERVICE); - resourceInstances.add(instance); - component.setComponentInstances(resourceInstances); - fetchedComponent.setComponentInstances(resourceInstances); - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("YANG"); - toscaArtifacts.put("assettoscatemplate", artifact); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - - fetchedComponent.setToscaArtifacts(toscaArtifacts); - fetchedComponent.setDeploymentArtifacts(toscaArtifacts); - fetchedComponent.setArtifacts(toscaArtifacts); - - Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component), - Either.left(fetchedComponent), Either.right(StorageOperationStatus.BAD_REQUEST)); - - Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component); - } - - @Test - public void testCollectComponentTypeArtifactsWhenFetchedComponentDontHaveComponentInstances() { - Component component = new Service(); - Component fetchedComponent = new Resource(); - component.setUniqueId("uniqueId"); - List<ComponentInstance> resourceInstances = new ArrayList<>(); - ComponentInstance instance = new ComponentInstance(); - instance.setComponentUid("resourceUid"); - instance.setOriginType(OriginTypeEnum.SERVICE); - - Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); - ArtifactDefinition artifact = new ArtifactDefinition(); - artifact.setArtifactName("artifactName"); - artifact.setEsId("esId"); - artifact.setArtifactUUID("artifactUUID"); - artifact.setArtifactType("PLAN"); - toscaArtifacts.put("assettoscatemplate", artifact); - - instance.setDeploymentArtifacts(toscaArtifacts); - - resourceInstances.add(instance); - component.setComponentInstances(resourceInstances); - - component.setToscaArtifacts(toscaArtifacts); - component.setDeploymentArtifacts(toscaArtifacts); - component.setArtifacts(toscaArtifacts); - - fetchedComponent.setToscaArtifacts(toscaArtifacts); - fetchedComponent.setDeploymentArtifacts(toscaArtifacts); - fetchedComponent.setArtifacts(toscaArtifacts); - - Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component), - Either.left(fetchedComponent)); - - Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component); - } - - @Test - public void testValidateNonMetaArtifactHappyScenario() { - String artifactPath = "Artifacts/Deployment/YANG_XML/myYang.xml"; - byte[] payloadData = "some payload data".getBytes(); - Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); - Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, - payloadData, collectedWarningMessages); - assertTrue(eitherNonMetaArtifact.isLeft()); - assertTrue(collectedWarningMessages.isEmpty()); - - artifactPath = "Artifacts/Informational/OTHER/someArtifact.xml"; - eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages); - assertTrue(eitherNonMetaArtifact.isLeft()); - assertTrue(collectedWarningMessages.isEmpty()); - } - - @Test - public void testValidateNonMetaArtifactScenarioWithWarnnings() { - String artifactPath = "Artifacts/Deployment/Buga/myYang.xml"; - byte[] payloadData = "some payload data".getBytes(); - Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); - Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, - payloadData, collectedWarningMessages); - assertTrue(eitherNonMetaArtifact.isLeft()); - - artifactPath = "Artifacts/Informational/Buga2/someArtifact.xml"; - eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages); - assertTrue(eitherNonMetaArtifact.isLeft()); - - assertTrue(collectedWarningMessages.size() == 1); - assertTrue(collectedWarningMessages.values().iterator().next().size() == 2); - } +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; - @Test - public void testValidateNonMetaArtifactUnhappyScenario() { - String artifactPath = "Artifacts/Buga/YANG_XML/myYang.xml"; - byte[] payloadData = "some payload data".getBytes(); - Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); - Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, - payloadData, collectedWarningMessages); - assertTrue(eitherNonMetaArtifact.isRight()); - assertTrue(!collectedWarningMessages.isEmpty()); - } +public class CsarUtilsTest { + @Before + public void setup() { + ExternalConfiguration.setAppName("catalog-be"); + + // init Configuration + String appConfigDir = "src/test/resources/config/catalog-be"; + ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); + ConfigurationManager configurationManager = new ConfigurationManager(configurationSource); + } + + @Test + public void testValidateNonMetaArtifactHappyScenario(){ + String artifactPath = "Artifacts/Deployment/YANG_XML/myYang.xml"; + byte[] payloadData = "some payload data".getBytes(); + Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); + Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages); + assertTrue(eitherNonMetaArtifact.isLeft() ); + assertTrue(collectedWarningMessages.isEmpty() ); + + artifactPath = "Artifacts/Informational/OTHER/someArtifact.xml"; + eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages); + assertTrue(eitherNonMetaArtifact.isLeft() ); + assertTrue(collectedWarningMessages.isEmpty() ); + } + + @Test + public void testValidateNonMetaArtifactScenarioWithWarnnings(){ + String artifactPath = "Artifacts/Deployment/Buga/myYang.xml"; + byte[] payloadData = "some payload data".getBytes(); + Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); + Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages); + assertTrue(eitherNonMetaArtifact.isLeft() ); + + artifactPath = "Artifacts/Informational/Buga2/someArtifact.xml"; + eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages); + assertTrue(eitherNonMetaArtifact.isLeft() ); + + assertEquals(1, collectedWarningMessages.size()); + assertEquals(2, collectedWarningMessages.values().iterator().next().size()); + } + + @Test + public void testValidateNonMetaArtifactUnhappyScenario(){ + String artifactPath = "Artifacts/Buga/YANG_XML/myYang.xml"; + byte[] payloadData = "some payload data".getBytes(); + Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); + Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages); + assertTrue(eitherNonMetaArtifact.isRight() ); + assertTrue( !collectedWarningMessages.isEmpty() ); + } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java new file mode 100644 index 0000000000..f439b4d31f --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java @@ -0,0 +1,151 @@ +package org.openecomp.sdc.be.tosca; + +import fj.data.Either; +import org.apache.commons.lang3.tuple.Pair; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundException; +import org.openecomp.sdc.be.components.utils.GroupDefinitionBuilder; +import org.openecomp.sdc.be.components.utils.ResourceBuilder; +import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; +import org.openecomp.sdc.be.tosca.model.ToscaGroupTemplate; +import org.openecomp.sdc.be.tosca.model.ToscaTemplateCapability; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class GroupExportParserImplTest { + + private static final String GROUP_DEFINITION_NAME = "groupDefinitionName"; + private static final String GROUP_DEFINITION_INVARIANT_UUID = "groupDefinitionInvariantUUID"; + private static final String GROUP_DEFINITION_GROUP_UUID = "groupDefinitionGroupUUID"; + private static final String GROUP_DEFINITION_VERSION = "groupDefinitionVersion"; + private static final String GROUP_DEFINITION_TYPE = "groupDefinitionType"; + + private static final String CAPABILITIE_NAME = "capabilitieName"; + private static final String COMPONENT_INSTANCE_PROPERTY_NAME = "componentInstancePropertyName"; + private static final String COMPONENT_INSTANCE_PROPERTY_VALUE = "componentInstancePropertyValue"; + + + private GroupExportParser groupExportParser; + + @Mock + private ApplicationDataTypeCache dataTypeCache; + + @Mock + private Component component; + + @Before + public void setUp() throws Exception { + initGroupExportParser(); + } + + private void initGroupExportParser() { + when(dataTypeCache.getAll()).thenReturn(Either.left(null)); + groupExportParser = new GroupExportParserImpl(dataTypeCache); + } + + @Test + public void failToGetAllDataTypes() { + when(dataTypeCache.getAll()).thenReturn(Either.right(null)); + assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> groupExportParser = new GroupExportParserImpl(dataTypeCache)); + } + + @Test + public void noGroupsInComponent() { + when(component.getGroups()).thenReturn(null); + Map<String, ToscaGroupTemplate> groups = groupExportParser.getGroups(component); + assertThat(groups).isNull(); + } + + @Test + public void oneGroupInComponent() { + when(component.getGroups()).thenReturn(genOneGroup()); + Map<String, ToscaGroupTemplate> groups = groupExportParser.getGroups(component); + assertThat(groups).isNotNull(); + assertThat(groups.size()).isOne(); + ToscaGroupTemplate toscaGroupTemplate = groups.get(GROUP_DEFINITION_NAME); + Map<String, ToscaTemplateCapability> capabilities = toscaGroupTemplate.getCapabilities(); + ToscaTemplateCapability toscaTemplateCapability = capabilities.get(CAPABILITIE_NAME); + Map<String, Object> properties = toscaTemplateCapability.getProperties(); + assertThat(properties).containsEntry(COMPONENT_INSTANCE_PROPERTY_NAME, COMPONENT_INSTANCE_PROPERTY_VALUE); + + } + + @Test + public void whenExportingGroupMembers_takeNamesFromTheMembersAndNotFromTheGroupMembersMap() { + GroupDefinition group1 = getGroup("group1", "type1", Pair.of("instance1Name", "inst1")); + GroupDefinition group2 = getGroup("group2", "type2", Pair.of("instance2Name", "inst2")); + Resource resource = new ResourceBuilder() + .addComponentInstance("inst1") + .addComponentInstance("inst2") + .addGroup(group1) + .addGroup(group2) + .build(); + Map<String, ToscaGroupTemplate> groups = groupExportParser.getGroups(resource); + assertThat(groups.values()) + .extracting("members") + .containsExactlyInAnyOrder(singletonList("inst1"), singletonList("inst2")); + } + + @SafeVarargs + private final GroupDefinition getGroup(String name, String type, Pair<String, String>... members) { + GroupDefinitionBuilder groupBuilder = GroupDefinitionBuilder.create() + .setName(name) + .setType(type); + Stream.of(members).forEach(member -> groupBuilder.addMember(member.getKey(), member.getValue())); + return groupBuilder.build(); + } + + private List<GroupDefinition> genOneGroup() { + List<GroupDefinition> group = new ArrayList<>(); + GroupDefinitionBuilder groupBuilder = GroupDefinitionBuilder.create() + .setName(GROUP_DEFINITION_NAME) + .setInvariantUUID(GROUP_DEFINITION_INVARIANT_UUID) + .setGroupUUID(GROUP_DEFINITION_GROUP_UUID) + .setVersion(GROUP_DEFINITION_VERSION) + .setType(GROUP_DEFINITION_TYPE); + + GroupDefinition groupDefinition = groupBuilder.build(); + + Map<String, List<CapabilityDefinition>> capabilities = genCapabilities(); + groupDefinition.setCapabilities(capabilities); + + group.add(groupDefinition); + return group; + } + + private Map<String, List<CapabilityDefinition>> genCapabilities() { + + Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>(); + List<CapabilityDefinition> capabilityDefinitions = new ArrayList<>(); + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + + List<ComponentInstanceProperty> capabilityProperties = new ArrayList<>(); + ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(); + componentInstanceProperty.setName(COMPONENT_INSTANCE_PROPERTY_NAME); + componentInstanceProperty.setValue(COMPONENT_INSTANCE_PROPERTY_VALUE); + + capabilityProperties.add(componentInstanceProperty); + capabilityDefinition.setProperties(capabilityProperties); + capabilityDefinition.setName(CAPABILITIE_NAME); + + capabilityDefinitions.add(capabilityDefinition); + capabilities.put("JustSoneName", capabilityDefinitions); + return capabilities; + } + +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InputAnnotationConvertToToscaTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InputAnnotationConvertToToscaTest.java new file mode 100644 index 0000000000..467dce5c72 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InputAnnotationConvertToToscaTest.java @@ -0,0 +1,107 @@ +package org.openecomp.sdc.be.tosca; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.elements.Annotation; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; +import org.openecomp.sdc.be.model.DataTypeDefinition; +import org.openecomp.sdc.be.model.InputDefinition; +import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; +import org.openecomp.sdc.be.tosca.model.ToscaInput; +import org.openecomp.sdc.be.tosca.model.ToscaProperty; +import org.openecomp.sdc.be.tosca.utils.InputConverter; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class InputAnnotationConvertToToscaTest { + private InputConverter inputConverter; + private PropertyDefinition property , property1 , property2,property3; + private InputDefinition inputDefinition; + Map<String, DataTypeDefinition> dataTypes; + + @Before + public void setUp(){ + property = new PropertyDefinition(); + property.setName("myProperty"); + property.setType(ToscaPropertyType.STRING.getType()); + property.setValue("this is property string"); + property.setDescription("propertyDescription"); + SchemaDefinition schemaDefinition = new SchemaDefinition(); + schemaDefinition.setProperty(property); + + + property1 = new PropertyDefinition(); + property1.setName("otherProperty"); + property1.setType(ToscaPropertyType.INTEGER.getType()); + property1.setValue("2"); + + property1.setSchema(schemaDefinition); + + + property2 = new PropertyDefinition(); + property2.setName("annotationProperty"); + property2.setType(ToscaPropertyType.FLOAT.getType()); + property2.setValue("3.14"); + + property3 = new PropertyDefinition(); + property3.setName("anotherAnnotationProperty"); + property3.setType(ToscaPropertyType.BOOLEAN.getType()); + property3.setValue("True"); + + dataTypes = new HashMap(); + DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(); + + List<PropertyDefinition> properties = new ArrayList(); + properties.add(property1); + + dataTypeDefinition.setProperties(properties); + dataTypes.put("nameProperty", dataTypeDefinition); + + List<Annotation> annotationList = new ArrayList<>(); + Annotation annotation = new Annotation(); + annotation.setName("Annotation1"); + annotation.setDescription("description1"); + + List<PropertyDataDefinition> propertiesAnnotation = new ArrayList(); + propertiesAnnotation.add(property2); + propertiesAnnotation.add(property3); + annotation.setProperties(propertiesAnnotation); + annotationList.add(annotation); + inputDefinition = new InputDefinition(); + inputDefinition.setName("inputName1"); + inputDefinition.setSchema(schemaDefinition); + inputDefinition.setAnnotations(annotationList); + + } + @Test + public void ConvertAnnotationParseOneInput(){ + + ArrayList<InputDefinition> inputDefList = new ArrayList<> (); + inputDefList.add(inputDefinition); + inputConverter = new InputConverter(); + Map<String, ToscaProperty> resultInputs ; + resultInputs = inputConverter.convertInputs(inputDefList,dataTypes); + //verify one Input only + assertEquals(1,resultInputs.size()); + ToscaInput toscaInput =(ToscaInput) resultInputs.get("inputName1"); + Map<String, Object> propertyMap = toscaInput.getAnnotations().get("Annotation1").getProperties(); + assertEquals(2,propertyMap.size()); + double pi = (double)propertyMap.get("annotationProperty"); + Assert.assertEquals(3.14,pi,0.01); + boolean annotationVal = (boolean)propertyMap.get("anotherAnnotationProperty"); + assertTrue(annotationVal); + assertEquals("propertyDescription", toscaInput.getEntry_schema().getDescription()); + assertEquals("string", toscaInput.getEntry_schema().getType() ); + } + + +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java new file mode 100644 index 0000000000..ff589d9baa --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java @@ -0,0 +1,156 @@ +package org.openecomp.sdc.be.tosca; + +import fj.data.Either; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundException; +import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.GroupDefinition; +import org.openecomp.sdc.be.model.PolicyDefinition; +import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; +import org.openecomp.sdc.be.tosca.model.ToscaMetadata; +import org.openecomp.sdc.be.tosca.model.ToscaPolicyTemplate; + +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class PolicyExportParserImplTest { + + private static final String[] POLICY_KEYS = {"policy_key_1","policy_key_2"}; + private static final String[] VERSIONS = {"version_1","version_1"}; + private static final String[] POLICY_NAMES = {"name_1","name_2"}; + private static final String[] POLICY_UUIDS = {"policyUUID_1","policyUUID_2"}; + private static final String[] INVARIANT_UUIDS = {"invariantUUID_1","invariantUUID_2"}; + private static final String[] POLICY_TYPE_NAMES = {"policyTypeName_1","policyTypeName_2"}; + private static final String[] POLICY_COMPONENT_INSTANCES = {"policyComponentInstanceId"}; + private static final String POLICY_COMPONENT_INSTANCES_NAME = "policyComponentInstanceName"; + private static final String[] POLICY_GROUPS = {"policyGroupId"}; + private static final String POLICY_GROUP_NAME = "PolicyGroupName"; + + private PolicyExportParser policiyExportParser; + + @Mock + private ApplicationDataTypeCache dataTypeCache; + + @Mock + private Component component; + + @Test + public void failToGetAllDataTypes() { + + when(dataTypeCache.getAll()).thenReturn(Either.right(null)); + assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> policiyExportParser = new PolicyExportParserImpl(dataTypeCache)); + } + + @Test + public void noPoliciesInComponent() { + + when(dataTypeCache.getAll()).thenReturn(Either.left(null)); + when(component.getPolicies()).thenReturn(null); + policiyExportParser = new PolicyExportParserImpl(dataTypeCache); + Map<String, ToscaPolicyTemplate> policies = policiyExportParser.getPolicies(component); + assertThat(policies).isEqualTo(null); + } + + @Test + public void onePoliciesInComponent() { + + List<Integer> constIndexes = Arrays.asList(new Integer[] {0}); + testPoliciesInComponent(constIndexes); + } + + @Test + public void twoPoliciesInComponent() { + + List<Integer> constIndexes = Arrays.asList(new Integer[] {0,1}); + testPoliciesInComponent(constIndexes); + } + + private void testPoliciesInComponent(List<Integer> constIndexes) { + when(dataTypeCache.getAll()).thenReturn(Either.left(null)); + Map<String, PolicyDefinition> policiesToAdd = getPolicies(constIndexes); + + when(component.getPolicies()).thenReturn(policiesToAdd); + when(component.getComponentInstances()).thenReturn(getComponentInstances()); + when(component.getGroups()).thenReturn(getGroups()); + policiyExportParser = new PolicyExportParserImpl(dataTypeCache); + + Map<String, ToscaPolicyTemplate> policies = policiyExportParser.getPolicies(component); + + for(Integer i : constIndexes) { + + + ToscaPolicyTemplate toscaPolicyTemplate = policies.get(POLICY_NAMES[i]); + ToscaMetadata metadata = (ToscaMetadata) toscaPolicyTemplate.getMetadata(); + + assertThat(metadata.getInvariantUUID()).isEqualTo(INVARIANT_UUIDS[i]); + assertThat(metadata.getUUID()).isEqualTo(POLICY_UUIDS[i]); + assertThat(metadata.getName()).isEqualTo(POLICY_NAMES[i]); + assertThat(metadata.getVersion()).isEqualTo(VERSIONS[i]); + + String type = toscaPolicyTemplate.getType(); + assertThat(type).isEqualTo(POLICY_TYPE_NAMES[i]); + + List<String> targets = toscaPolicyTemplate.getTargets(); + assertThat(targets.get(0)).isEqualTo(POLICY_COMPONENT_INSTANCES_NAME); + assertThat(targets.get(1)).isEqualTo(POLICY_GROUP_NAME); + } + } + + private List<GroupDefinition> getGroups() { + List<GroupDefinition> groups = new ArrayList<>(); + GroupDefinition groupDefinition = new GroupDefinition(); + groupDefinition.setUniqueId(POLICY_GROUPS[0]); + groupDefinition.setName(POLICY_GROUP_NAME); + groups.add(groupDefinition); + return groups; + } + + private List<ComponentInstance> getComponentInstances() { + List<ComponentInstance> componentInstances = new ArrayList<>(); + ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setUniqueId(POLICY_COMPONENT_INSTANCES[0]); + componentInstance.setName(POLICY_COMPONENT_INSTANCES_NAME); + componentInstances.add(componentInstance); + return componentInstances; + } + + private Map<String, PolicyDefinition> getPolicies(List<Integer> indexes) { + Map<String, PolicyDefinition> policies = new HashMap<>(); + + for (int index : indexes) { + + PolicyDefinition policyDefinition = new PolicyDefinition(); + + // Set type + policyDefinition.setPolicyTypeName(POLICY_TYPE_NAMES[index]); + + // Set Metadata + policyDefinition.setInvariantUUID(INVARIANT_UUIDS[index]); + policyDefinition.setPolicyUUID(POLICY_UUIDS[index]); + policyDefinition.setName(POLICY_NAMES[index]); + policyDefinition.setVersion(VERSIONS[index]); + + // Set targets + policyDefinition.setTargets(getTargers()); + + policies.put(POLICY_KEYS[index],policyDefinition); + } + return policies; + } + + private Map<PolicyTargetType, List<String>> getTargers() { + Map<PolicyTargetType, List<String>> targets = new HashMap<>(); + targets.put(PolicyTargetType.COMPONENT_INSTANCES, Arrays.asList(POLICY_COMPONENT_INSTANCES)); + targets.put(PolicyTargetType.GROUPS, Arrays.asList(POLICY_GROUPS)); + return targets; + } +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java index 18e2ec9fa0..a06ba84b4e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java @@ -1,18 +1,6 @@ package org.openecomp.sdc.be.tosca; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import fj.data.Either; import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder; @@ -24,7 +12,10 @@ import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.tosca.model.ToscaNodeType; import org.openecomp.sdc.be.tosca.model.ToscaProperty; -import fj.data.Either; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.*; public class PropertyConvertorTest { private PropertyDefinition property; @@ -156,14 +147,14 @@ public class PropertyConvertorTest { public void testConvertToToscaObject() { dataTypes.put(ToscaPropertyType.Root.getType(), new DataTypeDefinition()); - PropertyConvertor.getInstance().convertToToscaObject(ToscaPropertyType.Root.getType(), "", "innerType", dataTypes); + PropertyConvertor.getInstance().convertToToscaObject(ToscaPropertyType.Root.getType(), "", "innerType", dataTypes,true); } @Test public void testConvertToToscaObjectWhenPropertyTypeAndInnerTypeNull() { dataTypes.put(ToscaPropertyType.Root.getType(), new DataTypeDefinition()); - PropertyConvertor.getInstance().convertToToscaObject(null, "value", null, dataTypes); + PropertyConvertor.getInstance().convertToToscaObject(null, "value", null, dataTypes,true); } @Test @@ -172,7 +163,7 @@ public class PropertyConvertorTest { def.setName("integer"); dataTypes.put("type", def); - PropertyConvertor.getInstance().convertToToscaObject("type", "value", "innerType", dataTypes); + PropertyConvertor.getInstance().convertToToscaObject("type", "value", "innerType", dataTypes,true); } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java index 05f872f44c..839095f1ca 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java @@ -20,8 +20,8 @@ package org.openecomp.sdc.be.tosca; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.yaml.snakeyaml.Yaml; import java.io.FileInputStream; import java.io.IOException; @@ -31,8 +31,8 @@ import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; -import org.yaml.snakeyaml.Yaml; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class SchemaFiles { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java index 92819ca012..49599777c3 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java @@ -9,6 +9,7 @@ import java.util.function.Supplier; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Triple; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -19,9 +20,7 @@ import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.model.ArtifactDefinition; @@ -35,7 +34,6 @@ import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.GroupInstance; -import org.openecomp.sdc.be.model.GroupProperty; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.RelationshipInfo; @@ -50,7 +48,6 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.tosca.model.SubstitutionMapping; import org.openecomp.sdc.be.tosca.model.ToscaCapability; -import org.openecomp.sdc.be.tosca.model.ToscaGroupTemplate; import org.openecomp.sdc.be.tosca.model.ToscaMetadata; import org.openecomp.sdc.be.tosca.model.ToscaNodeTemplate; import org.openecomp.sdc.be.tosca.model.ToscaNodeType; @@ -60,6 +57,7 @@ import org.openecomp.sdc.be.tosca.model.ToscaTopolgyTemplate; import fj.data.Either; import mockit.Deencapsulation; +import org.openecomp.sdc.be.tosca.utils.InputConverter; public class ToscaExportHandlerTest extends BeConfDependentTest { @@ -73,7 +71,16 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { ToscaOperationFacade toscaOperationFacade; @Mock - CapabiltyRequirementConvertor capabiltyRequirementConvertor; + CapabilityRequirementConverter capabiltyRequirementConvertor; + + @Mock + InputConverter inputConverter; + + @Mock + GroupExportParser groupExportParser; + + @Mock + GroupExportParserImpl groupExportParserImpl; @Before public void setUpMock() throws Exception { @@ -130,14 +137,14 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Either<ToscaRepresentation, ToscaError> result; Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); - Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Resource.class), + Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class), Mockito.any(Resource.class), Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); // default test when component is Resource result = testSubject.exportComponent(component); component = getNewService(); - Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Service.class), + Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Service.class), Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(TitanOperationStatus.NOT_FOUND)); @@ -158,7 +165,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { result = testSubject.exportComponentInterface(component); Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); - Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Resource.class), + Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Resource.class), Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); // default test when convertInterfaceNodeType is left @@ -208,6 +215,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode); } + @Ignore("need to solve problem with groupExportParser injection") @Test public void testConvertToscaTemplateWhenComponentContainsGroup() { Component component = getNewResource(); @@ -237,10 +245,17 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); + Mockito.when(inputConverter.convertInputs(Mockito.any(List.class),Mockito.any(Map.class))) + .thenReturn(new HashMap<>()); + + Mockito.when(groupExportParser.getGroups(component)) + .thenReturn(null); + // test component contains group result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode); } + @Ignore("need to solve problem with groupExportParser injection") @Test public void testConvertToscaTemplateWhenComponentIsService() throws Exception { Component component = getNewService(); @@ -270,28 +285,13 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); + Mockito.when(inputConverter.convertInputs(Mockito.any(List.class),Mockito.any(Map.class))) + .thenReturn(new HashMap<>()); // test component contains group result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode); } @Test - public void testFillInputs() throws Exception { - Component component = new Resource(); - ToscaTopolgyTemplate topologyTemplate = new ToscaTopolgyTemplate(); - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - Either<ToscaTopolgyTemplate, ToscaError> result; - - InputDefinition input = new InputDefinition(); - - List<InputDefinition> inputs = new ArrayList<>(); - inputs.add(input); - component.setInputs(inputs); - - // default test - result = Deencapsulation.invoke(testSubject, "fillInputs", component, topologyTemplate, dataTypes); - } - - @Test public void testConvertMetadata_1() throws Exception { Component component = getNewResource(); @@ -378,7 +378,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.when(dataTypeCache.getAll()).thenReturn(Either.right(TitanOperationStatus.ALREADY_EXIST)); // default test - result = Deencapsulation.invoke(testSubject, "convertNodeType", component, toscaNode, nodeTypes); + result = Deencapsulation.invoke(testSubject, "convertNodeType",new HashMap<>(), component, toscaNode, nodeTypes); } @Test @@ -393,13 +393,13 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); - Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Resource.class), + Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class), Mockito.any(Resource.class), Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); // default test - result = Deencapsulation.invoke(testSubject, "convertInterfaceNodeType", component, toscaNode, nodeTypes); + result = Deencapsulation.invoke(testSubject, "convertInterfaceNodeType",new HashMap<>(), component, toscaNode, nodeTypes); } - + @Ignore("need to fix change in injected class.") @Test public void testConvertReqCapAndTypeName() throws Exception { Component component = new Resource(); @@ -410,19 +410,19 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Either<ToscaTemplate, ToscaError> result; Mockito.when( - capabiltyRequirementConvertor.convertCapabilities(Mockito.any(Resource.class), Mockito.any(Map.class))) + capabiltyRequirementConvertor.convertCapabilities(Mockito.any(Map.class),Mockito.any(Resource.class), Mockito.any(Map.class))) .thenReturn(new HashMap<>()); - Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Resource.class), + Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Resource.class), Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); // default test - result = Deencapsulation.invoke(testSubject, "convertReqCapAndTypeName", component, toscaNode, nodeTypes, + result = Deencapsulation.invoke(testSubject, "convertReqCapAndTypeName",new HashMap<>(), component, toscaNode, nodeTypes, toscaNodeType, dataTypes); component = new Service(); - Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Service.class), + Mockito.when(capabiltyRequirementConvertor.convertRequirements(Mockito.any(Map.class),Mockito.any(Service.class), Mockito.any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); // test when component is service @@ -430,6 +430,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { toscaNodeType, dataTypes); } + @Ignore @Test public void testConvertNodeTemplates() throws Exception { Component component = getNewResource(); @@ -476,7 +477,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class), Mockito.any(ComponentInstance.class))).thenReturn(Either.left(component)); - Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilties( + Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities( Mockito.any(ComponentInstance.class), Mockito.any(Map.class), Mockito.any(ToscaNodeTemplate.class))) .thenReturn(Either.left(new ToscaNodeTemplate())); @@ -539,7 +540,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class), Mockito.any(ComponentInstance.class))).thenReturn(Either.left(component)); - Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilties( + Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities( Mockito.any(ComponentInstance.class), Mockito.any(Map.class), Mockito.any(ToscaNodeTemplate.class))) .thenReturn(Either.left(new ToscaNodeTemplate())); @@ -583,7 +584,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.when(capabiltyRequirementConvertor.getOriginComponent(Mockito.any(Map.class), Mockito.any(ComponentInstance.class))).thenReturn(Either.left(component)); - Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilties( + Mockito.when(capabiltyRequirementConvertor.convertComponentInstanceCapabilities( Mockito.any(ComponentInstance.class), Mockito.any(Map.class), Mockito.any(ToscaNodeTemplate.class))) .thenReturn(Either.right(ToscaError.GENERAL_ERROR)); @@ -688,7 +689,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { // default test Deencapsulation.invoke(testSubject, "addComponentInstanceInputs", dataTypes, componentInstancesInputs, - componentInstance, instanceUniqueId, props); + instanceUniqueId, props); } @Test @@ -709,7 +710,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { // default test Deencapsulation.invoke(testSubject, "addPropertiesOfComponentInstance", componentInstancesProperties, dataTypes, - componentInstance, instanceUniqueId, props); + instanceUniqueId, props); } @Test @@ -725,75 +726,10 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { ((Resource) componentOfInstance).setProperties(properties); // default test - Deencapsulation.invoke(testSubject, "addPropertiesOfParentComponent", dataTypes, componentInstance, + Deencapsulation.invoke(testSubject, "addPropertiesOfParentComponent", dataTypes, componentOfInstance, props); } - @Test - public void testConvertAndAddValue() throws Exception { - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - ComponentInstance componentInstance = new ComponentInstance(); - Map<String, Object> props = new HashMap<>(); - PropertyDefinition prop = new PropertyDefinition(); - Supplier<String> supplier = () -> ""; - - // default test - Deencapsulation.invoke(testSubject, "convertAndAddValue", dataTypes, componentInstance, props, prop, supplier); - } - - @Test - public void testConvertValue() throws Exception { - Map<String, DataTypeDefinition> dataTypes = new HashMap<>(); - ComponentInstance componentInstance = new ComponentInstance(); - Supplier<String> supplier = () -> ""; - PropertyDefinition input = new PropertyDefinition(); - SchemaDefinition schema = new SchemaDefinition(); - schema.setProperty(new PropertyDataDefinition()); - input.setSchema(schema); - Object result; - - // default test - result = Deencapsulation.invoke(testSubject, "convertValue", dataTypes, componentInstance, input, supplier); - - } - - @Test - public void testConvertGroupInstance() throws Exception { - - GroupInstance groupInstance = new GroupInstance(); - groupInstance.setType("type"); - ToscaGroupTemplate result; - - // default test - - result = Deencapsulation.invoke(testSubject, "convertGroupInstance", groupInstance); - } - - @Test - public void testFillGroupProperties() throws Exception { - List<GroupProperty> groupProps = new ArrayList<>(); - GroupProperty property = new GroupProperty(); - property.setName("isBase"); - groupProps.add(property); - Map<String, Object> result; - - // test when property name is 'isBase' - result = Deencapsulation.invoke(testSubject, "fillGroupProperties", groupProps); - - groupProps.get(0).setName("name"); - groupProps.get(0).setType("integer"); - groupProps.get(0).setValue("123"); - - // test when property name isn't 'isBase' and value type is integer - result = Deencapsulation.invoke(testSubject, "fillGroupProperties", groupProps); - - groupProps.get(0).setType("boolean"); - groupProps.get(0).setValue("false"); - - // test when property name isn't 'isBase' and value type is boolean - result = Deencapsulation.invoke(testSubject, "fillGroupProperties", groupProps); - - } @Test public void testCreateNodeType() throws Exception { @@ -1043,7 +979,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList, rel, toscaRequirements, componentCache); } - + @Ignore("need to fix change in injected class.") @Test public void testAddRequirmentsWithBuildAndAddRequirements() { ComponentInstance fromInstance = new ComponentInstance(); @@ -1093,14 +1029,14 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent)); Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(Mockito.any(Map.class), - Mockito.any(Component.class), Mockito.any(List.class), Mockito.anyString())) + Mockito.any(Component.class), Mockito.any(List.class), Mockito.anyString(),Mockito.anyString())) .thenReturn(Either.right(false)); // default test result = Deencapsulation.invoke(testSubject, "addRequirement", fromInstance, fromOriginComponent, instancesList, rel, toscaRequirements, componentCache); } - + @Ignore("need to fix change in injected class.") @Test public void testBuildAndAddRequirement() throws Exception { List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>(); @@ -1118,16 +1054,17 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { reqAndRelationshipPair.setRequirement("req"); Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(new HashMap<>(), toOriginComponent, - new ArrayList<>(), "cap")).thenReturn(Either.left("buildCapNameRes")); + new ArrayList<>(),Mockito.anyString(), "cap")).thenReturn(Either.left("buildCapNameRes")); Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(new HashMap<>(), fromOriginComponent, - new ArrayList<>(), "req")).thenReturn(Either.right(false)); + new ArrayList<>(),Mockito.anyString(), "req")).thenReturn(Either.right(false)); // default test result = Deencapsulation.invoke(testSubject, "buildAndAddRequirement", toscaRequirements, fromOriginComponent, toOriginComponent, capability, requirement, reqAndRelationshipPair, toInstance, componentCache); } + @Ignore("need to fix change in injected class.") @Test public void testBuildAndAddRequirementBuildSubtitutedNameReturnsValueTwice() { List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>(); @@ -1145,7 +1082,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { reqAndRelationshipPair.setRequirement("req"); Mockito.when(capabiltyRequirementConvertor.buildSubstitutedName(Mockito.anyMap(), Mockito.any(Resource.class), - Mockito.anyList(), Mockito.anyString())).thenReturn(Either.left("buildCapNameRes")); + Mockito.anyList(), Mockito.anyString(),Mockito.anyString())).thenReturn(Either.left("buildCapNameRes")); // default test result = Deencapsulation.invoke(testSubject, "buildAndAddRequirement", toscaRequirements, fromOriginComponent, @@ -1225,7 +1162,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { result = Deencapsulation.invoke(testSubject, "convertCapabilities", component, substitutionMappings, componentCache); } - + @Ignore("need to fix change in injected class.") @Test public void testConvertCapabilities_1() throws Exception { Component component = new Resource(); @@ -1236,7 +1173,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Map<String, ToscaCapability> capabilities = new HashMap<>(); capabilities.put("key", new ToscaCapability()); - Mockito.when(capabiltyRequirementConvertor.convertCapabilities(component, dataTypes)).thenReturn(capabilities); + Mockito.when(capabiltyRequirementConvertor.convertCapabilities(Mockito.any(Map.class), component, dataTypes)).thenReturn(capabilities); // default test result = Deencapsulation.invoke(testSubject, "convertCapabilities", component, nodeType, dataTypes); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java new file mode 100644 index 0000000000..efc89a9f9d --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java @@ -0,0 +1,120 @@ +package org.openecomp.sdc.be.tosca; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.junit.Test; +import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; +import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +public class ToscaExportUtilsTest { + private static final Logger log = LoggerFactory.getLogger(ToscaExportUtilsTest.class); + @javax.annotation.Resource + private ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + @Autowired + private ToscaExportHandler exportUtils; + @Autowired + private ComponentInstanceOperation componentInstanceOperation; + + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + + @Test + public void testExportService() { + /* Resource resource1 = ResourceTestUtils.prepareResource(0); + resource1.setResourceType(ResourceTypeEnum.VF); + Either<Resource, ResponseFormat> createResource1 = resourceBusinessLogic.createResource(resource1, getAdminUser(), null, null); + assertTrue(createResource1.isLeft()); + Resource certifiedVFC1 = changeResourceStateToCertify(createResource1.left().value()); + + Resource resource2 = ResourceTestUtils.prepareResource(1); + resource2.setResourceType(ResourceTypeEnum.VF); + Either<Resource, ResponseFormat> createResource2 = resourceBusinessLogic.createResource(resource2, getAdminUser(), null, null); + assertTrue(createResource2.isLeft()); + Resource certifiedVFC2 = changeResourceStateToCertify(createResource2.left().value()); + + Service service = ResourceTestUtils.prepareService(0); + Either<Service, ResponseFormat> createService = serviceBusinessLogic.createService(service, getAdminUser()); + assertTrue(createService.isLeft()); + + // add VFC instance to VF + ComponentInstance vfcResourceInstance1 = new ComponentInstance(); + vfcResourceInstance1.setDescription("VFC instance 1"); + vfcResourceInstance1.setName(certifiedVFC1.getName()); + vfcResourceInstance1.setComponentUid(certifiedVFC1.getUniqueId()); + + Either<ComponentInstance, ResponseFormat> createResourceVfcInstance1 = serviceInstanceBusinessLogic.createComponentInstance(ComponentTypeEnum.SERVICE_PARAM_NAME, createService.left().value().getUniqueId(), adminUser.getAttuid(), + vfcResourceInstance1); + assertTrue(createResourceVfcInstance1.isLeft()); + + ComponentInstance vfcResourceInstance2 = new ComponentInstance(); + vfcResourceInstance2.setDescription("VFC instance 2"); + vfcResourceInstance2.setName(certifiedVFC2.getName()); + vfcResourceInstance2.setComponentUid(certifiedVFC2.getUniqueId()); + Either<ComponentInstance, ResponseFormat> createResourceVfcInstance2 = serviceInstanceBusinessLogic.createComponentInstance(ComponentTypeEnum.SERVICE_PARAM_NAME, createService.left().value().getUniqueId(), adminUser.getAttuid(), + vfcResourceInstance2); + assertTrue(createResourceVfcInstance2.isLeft()); + + Either<Service, ResponseFormat> serviceFetch = serviceBusinessLogic.getService(createService.left().value().getUniqueId(), adminUser); + assertTrue(serviceFetch.isLeft()); + + List<ComponentInstance> componentInstances = serviceFetch.left().value().getComponentInstances(); + String ciname1 = null; + String ciname2 = null; + + for (ComponentInstance ci : componentInstances) { + if (ci.getComponentUid().equals(certifiedVFC1.getUniqueId())) { + ciname1 = ci.getName(); + } + if (ci.getComponentUid().equals(certifiedVFC2.getUniqueId())) { + ciname2 = ci.getName(); + } + } + + Either<ToscaRepresentation, ToscaError> result = exportUtils.exportComponent(serviceFetch.left().value()); + assertTrue(result.isLeft()); + + String mainYaml = result.left().value().getMainYaml(); + assertNotNull(mainYaml); + + YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter(); + assertTrue(yamlToObjectConverter.isValidYaml(mainYaml.getBytes())); + log.debug(mainYaml); + + Yaml yaml = new Yaml(); + + InputStream inputStream = new ByteArrayInputStream(mainYaml.getBytes()); + Map<String, Object> load = (Map<String, Object>) yaml.load(inputStream); + Map<String, Object> imports = (Map<String, Object>) load.get("imports"); + assertNotNull(imports); + assertEquals("Validate imports size in yml", 2, imports.size()); + + Map<String, Object> metadata = (Map<String, Object>) load.get("metadata"); + assertNotNull(metadata); + validateMetadata(metadata, serviceFetch.left().value(), false); + + Map<String, Object> vf1 = (Map<String, Object>) imports.get(certifiedVFC1.getName()); + String fileName = (String) vf1.get(ToscaExportHandler.IMPORTS_FILE_KEY); + ArtifactDefinition artifactDefinition = certifiedVFC1.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE); + assertEquals("Validate 1 file name", artifactDefinition.getArtifactName(), fileName); + + Map<String, Object> topology_template = (Map<String, Object>) load.get("topology_template"); + Map<String, Object> node_templates = (Map<String, Object>) topology_template.get("node_templates"); + Map<String, Object> inst1 = (Map<String, Object>) node_templates.get(ciname1); + Map<String, Object> inst2 = (Map<String, Object>) node_templates.get(ciname2); + + Map<String, Object> inst1MD = (Map<String, Object>) inst1.get("metadata"); + Map<String, Object> inst2MD = (Map<String, Object>) inst2.get("metadata"); + + validateMetadata(inst1MD, certifiedVFC1, true); + + Map<String, Object> vf2 = (Map<String, Object>) imports.get(certifiedVFC2.getName()); + fileName = (String) vf2.get(ToscaExportHandler.IMPORTS_FILE_KEY); + artifactDefinition = certifiedVFC2.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE); + assertEquals("Validate 2 file name", artifactDefinition.getArtifactName(), fileName); + + validateMetadata(inst2MD, certifiedVFC2, true);*/ + } + +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java deleted file mode 100644 index fad85b2fd8..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.openecomp.sdc.be.tosca; - -import java.util.List; - -import org.apache.commons.lang3.tuple.Triple; -import org.junit.Test; -import org.openecomp.sdc.be.model.Component; - - -public class ToscaRepresentationTest { - - private ToscaRepresentation createTestSubject() { - return new ToscaRepresentation(); - } - - - @Test - public void testGetMainYaml() throws Exception { - ToscaRepresentation testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMainYaml(); - } - - - @Test - public void testSetMainYaml() throws Exception { - ToscaRepresentation testSubject; - String mainYaml = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setMainYaml(mainYaml); - } - - - @Test - public void testGetDependencies() throws Exception { - ToscaRepresentation testSubject; - List<Triple<String, String, Component>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDependencies(); - } - - - @Test - public void testSetDependencies() throws Exception { - ToscaRepresentation testSubject; - List<Triple<String, String, Component>> dependencies = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDependencies(dependencies); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java deleted file mode 100644 index 0c7d5cf5ce..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.openecomp.sdc.be.tosca; - -import java.util.Map; - -import org.junit.Test; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.Resource; - -public class ToscaUtilsTest { - - @Test - public void testIsComplexVfc() throws Exception { - Component component = new Resource(); - component.setComponentType(ComponentTypeEnum.RESOURCE); - boolean result; - - // default test - ToscaUtils.isComplexVfc(component); - } - - - @Test - public void testObjectToMap() throws Exception { - Object objectToConvert = null; - Object obj = new Object(); - Map<String, Object> result; - - // default test - ToscaUtils.objectToMap(objectToConvert, obj.getClass()); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java deleted file mode 100644 index f57d17d164..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import org.junit.Test; - - -public class EntrySchemaTest { - - private EntrySchema createTestSubject() { - return new EntrySchema(); - } - - - @Test - public void testGetType() throws Exception { - EntrySchema testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - EntrySchema testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testGetDescription() throws Exception { - EntrySchema testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - EntrySchema testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java deleted file mode 100644 index 661b8ca446..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.Map; - -import org.junit.Test; - - -public class SubstitutionMappingTest { - - private SubstitutionMapping createTestSubject() { - return new SubstitutionMapping(); - } - - - @Test - public void testGetNode_type() throws Exception { - SubstitutionMapping testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNode_type(); - } - - - @Test - public void testSetNode_type() throws Exception { - SubstitutionMapping testSubject; - String node_type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setNode_type(node_type); - } - - - @Test - public void testGetCapabilities() throws Exception { - SubstitutionMapping testSubject; - Map<String, String[]> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilities(); - } - - - @Test - public void testSetCapabilities() throws Exception { - SubstitutionMapping testSubject; - Map<String, String[]> capabilities = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilities(capabilities); - } - - - @Test - public void testGetRequirements() throws Exception { - SubstitutionMapping testSubject; - Map<String, String[]> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequirements(); - } - - - @Test - public void testSetRequirements() throws Exception { - SubstitutionMapping testSubject; - Map<String, String[]> requirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequirements(requirements); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java deleted file mode 100644 index ba4526a68d..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - - -public class ToscaCapabilityTest { - - private ToscaCapability createTestSubject() { - return new ToscaCapability(); - } - - - @Test - public void testGetValid_source_types() throws Exception { - ToscaCapability testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getValid_source_types(); - } - - - @Test - public void testSetValid_source_types() throws Exception { - ToscaCapability testSubject; - List<String> valid_source_types = null; - - // default test - testSubject = createTestSubject(); - testSubject.setValid_source_types(valid_source_types); - } - - - @Test - public void testGetType() throws Exception { - ToscaCapability testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - ToscaCapability testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testGetDescription() throws Exception { - ToscaCapability testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - ToscaCapability testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } - - - @Test - public void testGetOccurrences() throws Exception { - ToscaCapability testSubject; - List<Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOccurrences(); - } - - - @Test - public void testSetOccurrences() throws Exception { - ToscaCapability testSubject; - List<Object> occurrences = null; - - // default test - testSubject = createTestSubject(); - testSubject.setOccurrences(occurrences); - } - - - @Test - public void testGetProperties() throws Exception { - ToscaCapability testSubject; - Map<String, ToscaProperty> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - - @Test - public void testSetProperties() throws Exception { - ToscaCapability testSubject; - Map<String, ToscaProperty> properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java deleted file mode 100644 index a62c480505..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - - -public class ToscaGroupTemplateTest { - - private ToscaGroupTemplate createTestSubject() { - return new ToscaGroupTemplate(); - } - - - @Test - public void testGetType() throws Exception { - ToscaGroupTemplate testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - ToscaGroupTemplate testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testGetMembers() throws Exception { - ToscaGroupTemplate testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMembers(); - } - - - @Test - public void testSetMembers() throws Exception { - ToscaGroupTemplate testSubject; - List<String> members = null; - - // default test - testSubject = createTestSubject(); - testSubject.setMembers(members); - } - - - @Test - public void testGetMetadata() throws Exception { - ToscaGroupTemplate testSubject; - IToscaMetadata result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMetadata(); - } - - - @Test - public void testSetMetadata() throws Exception { - ToscaGroupTemplate testSubject; - IToscaMetadata metadata = null; - - // default test - testSubject = createTestSubject(); - testSubject.setMetadata(metadata); - } - - - @Test - public void testGetProperties() throws Exception { - ToscaGroupTemplate testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - - @Test - public void testSetProperties() throws Exception { - ToscaGroupTemplate testSubject; - Map<String, Object> properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java index f3159dde83..a7ff7853de 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java @@ -1,9 +1,9 @@ package org.openecomp.sdc.be.tosca.model; -import java.util.Map; - import org.junit.Test; +import java.util.Map; + public class ToscaInterfaceDefinitionTest { private ToscaInterfaceDefinition createTestSubject() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java index e6f1f96e89..9be5ccde2f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.tosca.model; -import java.util.Map; - import org.junit.Assert; import org.junit.Test; +import java.util.Map; + public class ToscaInterfaceNodeTypeTest { private ToscaInterfaceNodeType createTestSubject() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java index 3aadeafd96..e7a63d78fb 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.tosca.model; -import java.util.Map; - import org.junit.Assert; import org.junit.Test; +import java.util.Map; + public class ToscaLifecycleOperationDefinitionTest { private ToscaLifecycleOperationDefinition createTestSubject() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java deleted file mode 100644 index b7b7ba6514..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java +++ /dev/null @@ -1,385 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import org.junit.Test; - - -public class ToscaMetadataTest { - - private ToscaMetadata createTestSubject() { - return new ToscaMetadata(); - } - - - @Test - public void testGetName() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getName(); - } - - - @Test - public void testSetName() throws Exception { - ToscaMetadata testSubject; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setName(name); - } - - - @Test - public void testGetInvariantUUID() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInvariantUUID(); - } - - - @Test - public void testSetInvariantUUID() throws Exception { - ToscaMetadata testSubject; - String invariantUUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setInvariantUUID(invariantUUID); - } - - - @Test - public void testGetUUID() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUUID(); - } - - - @Test - public void testSetUUID() throws Exception { - ToscaMetadata testSubject; - String uUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setUUID(uUID); - } - - - @Test - public void testGetDescription() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - ToscaMetadata testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } - - - @Test - public void testGetType() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - ToscaMetadata testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testGetCategory() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCategory(); - } - - - @Test - public void testSetCategory() throws Exception { - ToscaMetadata testSubject; - String category = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setCategory(category); - } - - - @Test - public void testGetSubcategory() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSubcategory(); - } - - - @Test - public void testSetSubcategory() throws Exception { - ToscaMetadata testSubject; - String subcategory = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setSubcategory(subcategory); - } - - - @Test - public void testGetResourceVendor() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVendor(); - } - - - @Test - public void testSetResourceVendor() throws Exception { - ToscaMetadata testSubject; - String resourceVendor = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVendor(resourceVendor); - } - - - @Test - public void testGetResourceVendorRelease() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVendorRelease(); - } - - - @Test - public void testSetResourceVendorRelease() throws Exception { - ToscaMetadata testSubject; - String resourceVendorRelease = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVendorRelease(resourceVendorRelease); - } - - - @Test - public void testGetResourceVendorModelNumber() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVendorModelNumber(); - } - - - @Test - public void testSetResourceVendorModelNumber() throws Exception { - ToscaMetadata testSubject; - String resourceVendorModelNumber = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVendorModelNumber(resourceVendorModelNumber); - } - - - @Test - public void testGetServiceType() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceType(); - } - - - @Test - public void testSetServiceType() throws Exception { - ToscaMetadata testSubject; - String serviceType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceType(serviceType); - } - - - @Test - public void testGetServiceRole() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceRole(); - } - - - @Test - public void testSetServiceRole() throws Exception { - ToscaMetadata testSubject; - String serviceRole = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceRole(serviceRole); - } - - - @Test - public void testIsEcompGeneratedNaming() throws Exception { - ToscaMetadata testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isEcompGeneratedNaming(); - } - - - @Test - public void testSetEcompGeneratedNaming() throws Exception { - ToscaMetadata testSubject; - Boolean ecompGeneratedNaming = null; - - // default test - testSubject = createTestSubject(); - testSubject.setEcompGeneratedNaming(ecompGeneratedNaming); - } - - - @Test - public void testIsNamingPolicy() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isNamingPolicy(); - } - - - @Test - public void testSetNamingPolicy() throws Exception { - ToscaMetadata testSubject; - String namingPolicy = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setNamingPolicy(namingPolicy); - } - - - @Test - public void testGetServiceEcompNaming() throws Exception { - ToscaMetadata testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceEcompNaming(); - } - - - @Test - public void testSetServiceEcompNaming() throws Exception { - ToscaMetadata testSubject; - Boolean serviceEcompNaming = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceEcompNaming(serviceEcompNaming); - } - - - @Test - public void testGetVersion() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVersion(); - } - - - @Test - public void testSetVersion() throws Exception { - ToscaMetadata testSubject; - String version = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setVersion(version); - } - - - @Test - public void testGetCustomizationUUID() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCustomizationUUID(); - } - - - @Test - public void testSetCustomizationUUID() throws Exception { - ToscaMetadata testSubject; - String customizationUUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setCustomizationUUID(customizationUUID); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java deleted file mode 100644 index 4dab33ce14..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - - -public class ToscaNodeTemplateTest { - - private ToscaNodeTemplate createTestSubject() { - return new ToscaNodeTemplate(); - } - - - @Test - public void testGetType() throws Exception { - ToscaNodeTemplate testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - ToscaNodeTemplate testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testGetProperties() throws Exception { - ToscaNodeTemplate testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - - @Test - public void testSetProperties() throws Exception { - ToscaNodeTemplate testSubject; - Map<String, Object> properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } - - - @Test - public void testGetRequirements() throws Exception { - ToscaNodeTemplate testSubject; - List<Map<String, ToscaTemplateRequirement>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequirements(); - } - - - @Test - public void testSetRequirements() throws Exception { - ToscaNodeTemplate testSubject; - List<Map<String, ToscaTemplateRequirement>> requirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequirements(requirements); - } - - - @Test - public void testGetCapabilities() throws Exception { - ToscaNodeTemplate testSubject; - Map<String, ToscaTemplateCapability> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilities(); - } - - - @Test - public void testSetCapabilities() throws Exception { - ToscaNodeTemplate testSubject; - Map<String, ToscaTemplateCapability> capabilities = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilities(capabilities); - } - - - @Test - public void testGetMetadata() throws Exception { - ToscaNodeTemplate testSubject; - ToscaMetadata result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMetadata(); - } - - - @Test - public void testSetMetadata() throws Exception { - ToscaNodeTemplate testSubject; - ToscaMetadata metadata = null; - - // default test - testSubject = createTestSubject(); - testSubject.setMetadata(metadata); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java deleted file mode 100644 index 3bd04f1b92..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - - -public class ToscaNodeTypeTest { - - private ToscaNodeType createTestSubject() { - return new ToscaNodeType(); - } - - - @Test - public void testGetProperties() throws Exception { - ToscaNodeType testSubject; - Map<String, ToscaProperty> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - - @Test - public void testSetProperties() throws Exception { - ToscaNodeType testSubject; - Map<String, ToscaProperty> properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } - - - @Test - public void testGetCapabilities() throws Exception { - ToscaNodeType testSubject; - Map<String, ToscaCapability> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilities(); - } - - - @Test - public void testSetCapabilities() throws Exception { - ToscaNodeType testSubject; - Map<String, ToscaCapability> capabilities = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilities(capabilities); - } - - - @Test - public void testGetRequirements() throws Exception { - ToscaNodeType testSubject; - List<Map<String, ToscaRequirement>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequirements(); - } - - - @Test - public void testSetRequirements() throws Exception { - ToscaNodeType testSubject; - List<Map<String, ToscaRequirement>> requirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequirements(requirements); - } - - - @Test - public void testGetDerived_from() throws Exception { - ToscaNodeType testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDerived_from(); - } - - - @Test - public void testSetDerived_from() throws Exception { - ToscaNodeType testSubject; - String derived_from = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDerived_from(derived_from); - } - - - @Test - public void testGetDescription() throws Exception { - ToscaNodeType testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - ToscaNodeType testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } - - - @Test - public void testGetMetadata() throws Exception { - ToscaNodeType testSubject; - ToscaMetadata result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMetadata(); - } - - - @Test - public void testSetMetadata() throws Exception { - ToscaNodeType testSubject; - ToscaMetadata metadata = null; - - // default test - testSubject = createTestSubject(); - testSubject.setMetadata(metadata); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java deleted file mode 100644 index 52806cc6e6..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import org.junit.Test; - - -public class ToscaPropertyTest { - - private ToscaProperty createTestSubject() { - return new ToscaProperty(); - } - - - @Test - public void testGetEntry_schema() throws Exception { - ToscaProperty testSubject; - EntrySchema result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEntry_schema(); - } - - - @Test - public void testSetEntry_schema() throws Exception { - ToscaProperty testSubject; - EntrySchema entry_schema = null; - - // default test - testSubject = createTestSubject(); - testSubject.setEntry_schema(entry_schema); - } - - - @Test - public void testGetType() throws Exception { - ToscaProperty testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - ToscaProperty testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testGetDefaultp() throws Exception { - ToscaProperty testSubject; - Object result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDefaultp(); - } - - - @Test - public void testSetDefaultp() throws Exception { - ToscaProperty testSubject; - Object defaultp = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDefaultp(defaultp); - } - - - @Test - public void testGetDescription() throws Exception { - ToscaProperty testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - ToscaProperty testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } - - - @Test - public void testGetRequired() throws Exception { - ToscaProperty testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequired(); - } - - - @Test - public void testSetRequired() throws Exception { - ToscaProperty testSubject; - Boolean required = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequired(required); - } - - - @Test - public void testGetStatus() throws Exception { - ToscaProperty testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getStatus(); - } - - - @Test - public void testSetStatus() throws Exception { - ToscaProperty testSubject; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setStatus(status); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java deleted file mode 100644 index 9f93675252..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - - -public class ToscaRequirementTest { - - private ToscaRequirement createTestSubject() { - return new ToscaRequirement(); - } - - - @Test - public void testGetOccurrences() throws Exception { - ToscaRequirement testSubject; - List<Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOccurrences(); - } - - - @Test - public void testSetOccurrences() throws Exception { - ToscaRequirement testSubject; - List<Object> occurrences = null; - - // default test - testSubject = createTestSubject(); - testSubject.setOccurrences(occurrences); - } - - - @Test - public void testToMap() throws Exception { - ToscaRequirement testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toMap(); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java deleted file mode 100644 index 224c3084ad..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - - -public class ToscaTemplateCapabilityTest { - - private ToscaTemplateCapability createTestSubject() { - return new ToscaTemplateCapability(); - } - - - @Test - public void testGetValid_source_types() throws Exception { - ToscaTemplateCapability testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getValid_source_types(); - } - - - @Test - public void testSetValid_source_types() throws Exception { - ToscaTemplateCapability testSubject; - List<String> valid_source_types = null; - - // default test - testSubject = createTestSubject(); - testSubject.setValid_source_types(valid_source_types); - } - - - @Test - public void testGetProperties() throws Exception { - ToscaTemplateCapability testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - - @Test - public void testSetProperties() throws Exception { - ToscaTemplateCapability testSubject; - Map<String, Object> properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java deleted file mode 100644 index a29be8a56f..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.Map; - -import org.junit.Test; - - -public class ToscaTemplateRequirementTest { - - private ToscaTemplateRequirement createTestSubject() { - return new ToscaTemplateRequirement(); - } - - - @Test - public void testGetCapability() throws Exception { - ToscaTemplateRequirement testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapability(); - } - - - @Test - public void testSetCapability() throws Exception { - ToscaTemplateRequirement testSubject; - String capability = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setCapability(capability); - } - - - @Test - public void testGetNode() throws Exception { - ToscaTemplateRequirement testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNode(); - } - - - @Test - public void testSetNode() throws Exception { - ToscaTemplateRequirement testSubject; - String node = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setNode(node); - } - - - @Test - public void testGetRelationship() throws Exception { - ToscaTemplateRequirement testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationship(); - } - - - @Test - public void testSetRelationship() throws Exception { - ToscaTemplateRequirement testSubject; - String relationship = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationship(relationship); - } - - - @Test - public void testToMap() throws Exception { - ToscaTemplateRequirement testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toMap(); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java deleted file mode 100644 index 613c7ed457..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - - -public class ToscaTemplateTest { - - private ToscaTemplate createTestSubject() { - return new ToscaTemplate(""); - } - - - @Test - public void testGetNode_types() throws Exception { - ToscaTemplate testSubject; - Map<String, ToscaNodeType> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNode_types(); - } - - - @Test - public void testSetNode_types() throws Exception { - ToscaTemplate testSubject; - Map<String, ToscaNodeType> node_types = null; - - // default test - testSubject = createTestSubject(); - testSubject.setNode_types(node_types); - } - - - @Test - public void testGetImports() throws Exception { - ToscaTemplate testSubject; - List<Map<String, Map<String, String>>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getImports(); - } - - - @Test - public void testSetImports() throws Exception { - ToscaTemplate testSubject; - List<Map<String, Map<String, String>>> imports = null; - - // default test - testSubject = createTestSubject(); - testSubject.setImports(imports); - } - - - @Test - public void testGetTosca_definitions_version() throws Exception { - ToscaTemplate testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTosca_definitions_version(); - } - - - @Test - public void testSetTosca_definitions_version() throws Exception { - ToscaTemplate testSubject; - String tosca_definitions_version = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setTosca_definitions_version(tosca_definitions_version); - } - - - @Test - public void testGetMetadata() throws Exception { - ToscaTemplate testSubject; - ToscaMetadata result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMetadata(); - } - - - @Test - public void testSetMetadata() throws Exception { - ToscaTemplate testSubject; - ToscaMetadata metadata = null; - - // default test - testSubject = createTestSubject(); - testSubject.setMetadata(metadata); - } - - - @Test - public void testGetTopology_template() throws Exception { - ToscaTemplate testSubject; - ToscaTopolgyTemplate result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTopology_template(); - } - - - @Test - public void testSetTopology_template() throws Exception { - ToscaTemplate testSubject; - ToscaTopolgyTemplate topology_template = null; - - // default test - testSubject = createTestSubject(); - testSubject.setTopology_template(topology_template); - } - - - - - - -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java deleted file mode 100644 index 5b5ac82572..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import java.util.Map; - -import org.junit.Test; - - -public class ToscaTopolgyTemplateTest { - - private ToscaTopolgyTemplate createTestSubject() { - return new ToscaTopolgyTemplate(); - } - - - @Test - public void testGetNode_templates() throws Exception { - ToscaTopolgyTemplate testSubject; - Map<String, ToscaNodeTemplate> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNode_templates(); - } - - - @Test - public void testSetNode_templates() throws Exception { - ToscaTopolgyTemplate testSubject; - Map<String, ToscaNodeTemplate> node_templates = null; - - // default test - testSubject = createTestSubject(); - testSubject.setNode_templates(node_templates); - } - - - @Test - public void testGetGroups() throws Exception { - ToscaTopolgyTemplate testSubject; - Map<String, ToscaGroupTemplate> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getGroups(); - } - - - - - @Test - public void testGetSubstitution_mappings() throws Exception { - ToscaTopolgyTemplate testSubject; - SubstitutionMapping result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSubstitution_mappings(); - } - - - @Test - public void testSetSubstitution_mappings() throws Exception { - ToscaTopolgyTemplate testSubject; - SubstitutionMapping substitution_mapping = null; - - // default test - testSubject = createTestSubject(); - testSubject.setSubstitution_mappings(substitution_mapping); - } - - - @Test - public void testGetInputs() throws Exception { - ToscaTopolgyTemplate testSubject; - Map<String, ToscaProperty> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInputs(); - } - - - @Test - public void testSetInputs() throws Exception { - ToscaTopolgyTemplate testSubject; - Map<String, ToscaProperty> inputs = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInputs(inputs); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java deleted file mode 100644 index 62fb750108..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.openecomp.sdc.be.tosca.model; - -import org.junit.Test; - - -public class VfModuleToscaMetadataTest { - - private VfModuleToscaMetadata createTestSubject() { - return new VfModuleToscaMetadata(); - } - - - @Test - public void testSetName() throws Exception { - VfModuleToscaMetadata testSubject; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setName(name); - } - - - @Test - public void testSetInvariantUUID() throws Exception { - VfModuleToscaMetadata testSubject; - String invariantUUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setInvariantUUID(invariantUUID); - } - - - @Test - public void testSetUUID() throws Exception { - VfModuleToscaMetadata testSubject; - String uUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setUUID(uUID); - } - - - @Test - public void testSetVersion() throws Exception { - VfModuleToscaMetadata testSubject; - String version = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setVersion(version); - } - - - @Test - public void testGetVfModuleModelName() throws Exception { - VfModuleToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVfModuleModelName(); - } - - - @Test - public void testGetVfModuleModelInvariantUUID() throws Exception { - VfModuleToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVfModuleModelInvariantUUID(); - } - - - @Test - public void testGetVfModuleModelUUID() throws Exception { - VfModuleToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVfModuleModelUUID(); - } - - - @Test - public void testGetVfModuleModelVersion() throws Exception { - VfModuleToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVfModuleModelVersion(); - } - - - @Test - public void testGetVfModuleModelCustomizationUUID() throws Exception { - VfModuleToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVfModuleModelCustomizationUUID(); - } - - - @Test - public void testSetCustomizationUUID() throws Exception { - VfModuleToscaMetadata testSubject; - String customizationUUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setCustomizationUUID(customizationUUID); - } -}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java index 67b27f678f..bebfbd19d8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java @@ -16,9 +16,6 @@ package org.openecomp.sdc.be.tosca.utils; -import java.util.HashMap; -import java.util.Map; - import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -35,10 +32,8 @@ import org.openecomp.sdc.be.tosca.ToscaRepresentation; import org.openecomp.sdc.be.tosca.model.ToscaNodeType; import org.openecomp.sdc.be.tosca.model.ToscaTemplate; -/** - * @author KATYR - * @since April 12, 2018 - */ +import java.util.HashMap; +import java.util.Map; public class InterfacesOperationsToscaUtilTest { @@ -47,8 +42,7 @@ public class InterfacesOperationsToscaUtilTest { new DummyConfigurationManager(); } - - @Test + @Test() public void addInterfaceTypeElement() { Component component = new Resource(); component.setNormalizedName("normalizedComponentName"); @@ -61,7 +55,7 @@ public class InterfacesOperationsToscaUtilTest { final Map<String, Object> interfaceTypeElement = InterfacesOperationsToscaUtil.addInterfaceTypeElement(component); - ToscaExportHandler handler = new ToscaExportHandler(); + ToscaExportHandler handler = new ToscaExportHandler(null,null,null,null,null,null); ToscaTemplate template = new ToscaTemplate("test"); template.setInterface_types(interfaceTypeElement); final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template); @@ -84,7 +78,7 @@ public class InterfacesOperationsToscaUtilTest { ToscaNodeType nodeType = new ToscaNodeType(); InterfacesOperationsToscaUtil.addInterfaceDefinitionElement(component, nodeType); - ToscaExportHandler handler = new ToscaExportHandler(); + ToscaExportHandler handler = new ToscaExportHandler(null,null,null,null,null,null); ToscaTemplate template = new ToscaTemplate("test"); Map<String, ToscaNodeType> nodeTypes = new HashMap<>(); nodeTypes.put("test", nodeType); @@ -114,7 +108,7 @@ public class InterfacesOperationsToscaUtilTest { ToscaNodeType nodeType = new ToscaNodeType(); InterfacesOperationsToscaUtil.addInterfaceDefinitionElement(component, nodeType); - ToscaExportHandler handler = new ToscaExportHandler(); + ToscaExportHandler handler = new ToscaExportHandler(null,null,null,null,null,null); ToscaTemplate template = new ToscaTemplate("test"); Map<String, ToscaNodeType> nodeTypes = new HashMap<>(); nodeTypes.put("test", nodeType); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java index 338143ef23..66983d7d3a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java @@ -15,11 +15,6 @@ */ package org.openecomp.sdc.be.tosca.utils; -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.util.HashMap; - import org.junit.BeforeClass; import org.junit.Test; import org.openecomp.sdc.be.DummyConfigurationManager; @@ -29,6 +24,11 @@ import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.Resource; +import java.io.File; +import java.util.HashMap; + +import static org.junit.Assert.assertEquals; + public class OperationArtifactUtilTest { @BeforeClass |