summaryrefslogtreecommitdiffstats
path: root/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-02-16 12:44:30 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-02-16 12:46:21 +0000
commit7f418398a37283d68c0fc934e0e4a91f529fe466 (patch)
treedd62ac8b7803f9640bfb4a3a17bd4568006d9930 /catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java
parent70533b5c8fff3e9eb9e3b7bc6dd439d53036915a (diff)
Reformat catalog-be-plugins
Change-Id: Ic81316ca7bc69ef5ff775b56cbff156be1f945e8 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449
Diffstat (limited to 'catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java')
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilderTest.java25
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGeneratorTest.java19
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImplTest.java28
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImplTest.java83
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImplTest.java28
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersionComparatorTest.java4
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGeneratorTest.java40
7 files changed, 72 insertions, 155 deletions
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilderTest.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilderTest.java
index 8a1a4cffaa..1ff3a6d52b 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilderTest.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilderTest.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,10 +17,11 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.builder;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.builder.NsdCsarManifestBuilder.ATTRIBUTE_SEPARATOR;
import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.builder.NsdCsarManifestBuilder.COMPATIBLE_SPECIFICATION_VERSIONS;
import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.builder.NsdCsarManifestBuilder.METADATA;
@@ -30,7 +32,6 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
-
class NsdCsarManifestBuilderTest {
@Test
@@ -52,20 +53,12 @@ class NsdCsarManifestBuilderTest {
assertSource(manifest, source1);
assertSource(manifest, source2);
assertCompatibleSpecificationVersions(manifest, "1.0.0,1.0.1");
- final String expectedManifest = "metadata: \n"
- + "nsd_designer: designer\n"
- + "nsd_invariant_id: invariantId\n"
- + "nsd_name: name\n"
- + "nsd_file_structure_version: fileStructureVersion\n"
- + "compatible_specification_versions: 1.0.0,1.0.1\n"
- + "\n"
- + "Source: Definitions/aSource1.yaml\n"
- + "Source: Definitions/aSource2.yaml\n"
- + "";
+ final String expectedManifest = "metadata: \n" + "nsd_designer: designer\n" + "nsd_invariant_id: invariantId\n" + "nsd_name: name\n"
+ + "nsd_file_structure_version: fileStructureVersion\n" + "compatible_specification_versions: 1.0.0,1.0.1\n" + "\n"
+ + "Source: Definitions/aSource1.yaml\n" + "Source: Definitions/aSource2.yaml\n" + "";
assertEquals(expectedManifest, manifest);
}
-
@Test
void testMetadataReleaseDateTime() {
final NsdCsarManifestBuilder nsdCsarManifestBuilder = new NsdCsarManifestBuilder();
@@ -105,6 +98,4 @@ class NsdCsarManifestBuilderTest {
void assertSource(final String manifest, final String source) {
assertTrue(manifest.contains(SOURCE + ATTRIBUTE_SEPARATOR + source));
}
-
-
-} \ No newline at end of file
+}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGeneratorTest.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGeneratorTest.java
index 720ed77860..8ebd1df190 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGeneratorTest.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGeneratorTest.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -47,7 +47,9 @@ import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.EtsiVersion;
class EtsiNfvNsCsarEntryGeneratorTest {
-
+ private static final String SERVICE_NORMALIZED_NAME = "normalizedName";
+ private static final String CSAR_ENTRY_EMPTY_ASSERT = "Csar Entries should be empty";
+ private static final EtsiVersion nsdVersion = EtsiVersion.VERSION_2_5_1;
@Mock
private EtsiNfvNsdCsarGeneratorFactory etsiNfvNsdCsarGeneratorFactory;
@Mock
@@ -57,10 +59,6 @@ class EtsiNfvNsCsarEntryGeneratorTest {
@InjectMocks
private EtsiNfvNsCsarEntryGenerator etsiNfvNsCsarEntryGenerator;
- private static final String SERVICE_NORMALIZED_NAME = "normalizedName";
- private static final String CSAR_ENTRY_EMPTY_ASSERT = "Csar Entries should be empty";
- private static final EtsiVersion nsdVersion = EtsiVersion.VERSION_2_5_1;
-
@BeforeEach
void setUp() {
MockitoAnnotations.initMocks(this);
@@ -72,9 +70,7 @@ class EtsiNfvNsCsarEntryGeneratorTest {
mockServiceComponent();
final byte[] expectedNsdCsar = new byte[5];
when(etsiNfvNsdCsarGenerator.generateNsdCsar(service)).thenReturn(expectedNsdCsar);
-
final Map<String, byte[]> entryMap = etsiNfvNsCsarEntryGenerator.generateCsarEntries(service);
-
assertThat("Csar Entries should contain only one entry", entryMap.size(), is(1));
assertThat("Csar Entries should contain the expected entry", entryMap,
hasEntry(String.format(NSD_FILE_PATH_FORMAT, ETSI_PACKAGE, SERVICE_NORMALIZED_NAME), expectedNsdCsar));
@@ -85,7 +81,6 @@ class EtsiNfvNsCsarEntryGeneratorTest {
mockServiceComponent();
when(etsiNfvNsdCsarGenerator.generateNsdCsar(service)).thenThrow(new NsdException(""));
final Map<String, byte[]> entryMap = etsiNfvNsCsarEntryGenerator.generateCsarEntries(service);
-
assertThat(CSAR_ENTRY_EMPTY_ASSERT, entryMap, is(anEmptyMap()));
}
@@ -94,7 +89,6 @@ class EtsiNfvNsCsarEntryGeneratorTest {
mockServiceComponent();
when(etsiNfvNsdCsarGenerator.generateNsdCsar(service)).thenThrow(new RuntimeException());
final Map<String, byte[]> entryMap = etsiNfvNsCsarEntryGenerator.generateCsarEntries(service);
-
assertThat(CSAR_ENTRY_EMPTY_ASSERT, entryMap, is(anEmptyMap()));
}
@@ -102,7 +96,6 @@ class EtsiNfvNsCsarEntryGeneratorTest {
void componentNullOrNotAServiceTest() {
Map<String, byte[]> entryMap = etsiNfvNsCsarEntryGenerator.generateCsarEntries(service);
assertThat(CSAR_ENTRY_EMPTY_ASSERT, entryMap, is(anEmptyMap()));
-
entryMap = etsiNfvNsCsarEntryGenerator.generateCsarEntries(null);
assertThat(CSAR_ENTRY_EMPTY_ASSERT, entryMap, is(anEmptyMap()));
}
@@ -123,15 +116,13 @@ class EtsiNfvNsCsarEntryGeneratorTest {
when(service.getName()).thenReturn("anyName");
when(service.getComponentType()).thenReturn(ComponentTypeEnum.SERVICE);
when(service.getNormalizedName()).thenReturn(SERVICE_NORMALIZED_NAME);
-
final Map<String, String> categorySpecificMetadataMap = new HashMap<>();
categorySpecificMetadataMap.put(ETSI_VERSION_METADATA, nsdVersion.getVersion());
when(service.getCategorySpecificMetadata()).thenReturn(categorySpecificMetadataMap);
-
final List<CategoryDefinition> categoryDefinitionList = new ArrayList<>();
final CategoryDefinition nsComponentCategoryDefinition = new CategoryDefinition();
nsComponentCategoryDefinition.setName(ETSI_NS_COMPONENT_CATEGORY);
categoryDefinitionList.add(nsComponentCategoryDefinition);
when(service.getCategories()).thenReturn(categoryDefinitionList);
}
-} \ No newline at end of file
+}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImplTest.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImplTest.java
index ce66d2e0c3..b498c45d1f 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImplTest.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImplTest.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -49,14 +49,15 @@ import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.exception.NsdException;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.exception.VnfDescriptorException;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.factory.NsDescriptorGeneratorFactory;
-import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.NsDescriptorConfig;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.EtsiVersion;
+import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.NsDescriptorConfig;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.model.Nsd;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.model.VnfDescriptor;
import org.openecomp.sdc.be.resources.data.DAOArtifactData;
class EtsiNfvNsdCsarGeneratorImplTest {
+ private static final String SERVICE_NORMALIZED_NAME = "normalizedName";
@Mock
private VnfDescriptorGenerator vnfDescriptorGenerator;
@Mock
@@ -67,17 +68,14 @@ class EtsiNfvNsdCsarGeneratorImplTest {
private ArtifactCassandraDao artifactCassandraDao;
@Mock
private Service service;
-
private EtsiNfvNsdCsarGeneratorImpl etsiNfvNsdCsarGenerator;
- private static final String SERVICE_NORMALIZED_NAME = "normalizedName";
-
@BeforeEach
void setUp() {
MockitoAnnotations.initMocks(this);
final EtsiVersion version2_5_1 = EtsiVersion.VERSION_2_5_1;
- etsiNfvNsdCsarGenerator = new EtsiNfvNsdCsarGeneratorImpl(new NsDescriptorConfig(version2_5_1),
- vnfDescriptorGenerator, nsDescriptorGeneratorFactory, artifactCassandraDao);
+ etsiNfvNsdCsarGenerator = new EtsiNfvNsdCsarGeneratorImpl(new NsDescriptorConfig(version2_5_1), vnfDescriptorGenerator,
+ nsDescriptorGeneratorFactory, artifactCassandraDao);
when(nsDescriptorGeneratorFactory.create()).thenReturn(nsDescriptorGeneratorImpl);
}
@@ -99,16 +97,12 @@ class EtsiNfvNsdCsarGeneratorImplTest {
when(service.getComponentType()).thenReturn(ComponentTypeEnum.SERVICE);
final String componentInstance1Name = "componentInstance1";
final ComponentInstance componentInstance1 = mockServiceComponentInstance(componentInstance1Name);
- final ArtifactDefinition instanceArtifact1 = mockComponentInstanceArtifact(componentInstance1,
- "instanceArtifact1");
-
+ final ArtifactDefinition instanceArtifact1 = mockComponentInstanceArtifact(componentInstance1, "instanceArtifact1");
final VnfDescriptor vnfDescriptor1 = new VnfDescriptor();
final List<VnfDescriptor> vnfDescriptorList = Collections.singletonList(vnfDescriptor1);
final Nsd nsd = new Nsd();
- when(vnfDescriptorGenerator.generate(componentInstance1Name, instanceArtifact1))
- .thenReturn(Optional.of(vnfDescriptor1));
+ when(vnfDescriptorGenerator.generate(componentInstance1Name, instanceArtifact1)).thenReturn(Optional.of(vnfDescriptor1));
when(nsDescriptorGeneratorImpl.generate(service, vnfDescriptorList)).thenReturn(Optional.of(nsd));
-
final List<CategoryDefinition> categoryDefinitionList = new ArrayList<>();
final CategoryDefinition nsComponentCategoryDefinition = new CategoryDefinition();
nsComponentCategoryDefinition.setName(ETSI_NS_COMPONENT_CATEGORY);
@@ -144,15 +138,12 @@ class EtsiNfvNsdCsarGeneratorImplTest {
final List<ComponentInstance> componentInstanceList = new ArrayList<>();
componentInstanceList.add(componentInstance);
when(service.getComponentInstances()).thenReturn(componentInstanceList);
-
return componentInstance;
}
- private ArtifactDefinition mockComponentInstanceArtifact(final ComponentInstance componentInstance,
- final String instanceArtifactId) {
+ private ArtifactDefinition mockComponentInstanceArtifact(final ComponentInstance componentInstance, final String instanceArtifactId) {
final Map<String, ArtifactDefinition> deploymentArtifactMap = new HashMap<>();
when(componentInstance.getDeploymentArtifacts()).thenReturn(deploymentArtifactMap);
-
final ArtifactDefinition instanceArtifact1 = mockArtifactDefinition(instanceArtifactId);
instanceArtifact1.setToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE, ONBOARDED_PACKAGE.getType());
deploymentArtifactMap.put(instanceArtifactId, instanceArtifact1);
@@ -166,7 +157,6 @@ class EtsiNfvNsdCsarGeneratorImplTest {
private ArtifactDefinition mockArtifactDefinition(final String artifactId) {
final ArtifactDefinition artifact = new ArtifactDefinition();
artifact.setEsId(artifactId);
-
return artifact;
}
-} \ No newline at end of file
+}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImplTest.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImplTest.java
index 59fa445eaf..19cfefaba3 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImplTest.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImplTest.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -70,10 +70,6 @@ class NsDescriptorGeneratorImplTest {
private static final String VNFD_AMF_NODE_NAME = "vnfd_amf";
private static final String VIRTUAL_LINK_REQUIREMENT_NAME = "virtual_link";
-
- @Mock
- private ToscaExportHandler toscaExportHandler;
-
private final ObjectProvider<ToscaTemplateYamlGenerator> toscaTemplateYamlGeneratorProvider = new ObjectProvider<>() {
@Override
public ToscaTemplateYamlGenerator getObject(Object... args) {
@@ -95,7 +91,8 @@ class NsDescriptorGeneratorImplTest {
return null;
}
};
-
+ @Mock
+ private ToscaExportHandler toscaExportHandler;
private NsDescriptorGeneratorImpl nsDescriptorGenerator;
@BeforeEach
@@ -112,7 +109,6 @@ class NsDescriptorGeneratorImplTest {
nodeImportEntry.put("file", "nodes.yml");
importMap.put("nodes", nodeImportEntry);
defaultImports.add(importMap);
-
final ConfigurationSource configurationSource = mock(ConfigurationSource.class);
final Configuration configuration = new Configuration();
configuration.setDefaultImports(defaultImports);
@@ -130,7 +126,6 @@ class NsDescriptorGeneratorImplTest {
final ToscaTemplate componentToscaTemplate = new ToscaTemplate("");
final ToscaTopolgyTemplate componentToscaTopologyTemplate = new ToscaTopolgyTemplate();
componentToscaTemplate.setTopology_template(componentToscaTopologyTemplate);
-
final HashMap<String, ToscaNodeTemplate> nodeTemplateMap = new HashMap<>();
final ToscaNodeTemplate vnfAmfNodeTemplate = new ToscaNodeTemplate();
vnfAmfNodeTemplate.setType("com.ericsson.resource.abstract.Ericsson.AMF");
@@ -139,46 +134,38 @@ class NsDescriptorGeneratorImplTest {
//a property that wont be excluded
vnfAmfNodeTemplate.setProperties(ImmutableMap.of("will_not_be_excluded", new ToscaProperty()));
nodeTemplateMap.put(VNFD_AMF_NODE_NAME, vnfAmfNodeTemplate);
-
final Map<String, ToscaTemplateCapability> vnfAmfCapabilities = new HashMap<>();
vnfAmfCapabilities.put("myCapability", new ToscaTemplateCapability());
- vnfAmfNodeTemplate.setCapabilities(vnfAmfCapabilities);
+ vnfAmfNodeTemplate.setCapabilities(vnfAmfCapabilities);
componentToscaTopologyTemplate.setNode_templates(nodeTemplateMap);
-
final SubstitutionMapping substitutionMapping = mock(SubstitutionMapping.class);
Map<String, String[]> requirements = new HashMap<>();
String[] requirementAssignment = {"VNF1", VIRTUAL_LINK_REQUIREMENT_NAME};
requirements.put(VIRTUAL_LINK_REQUIREMENT_NAME, requirementAssignment);
- when(substitutionMapping.getRequirements()).thenReturn(requirements);
- Map<String, String[]> capabilities = new HashMap<>();
+ when(substitutionMapping.getRequirements()).thenReturn(requirements);
+ Map<String, String[]> capabilities = new HashMap<>();
String[] capabilitiesAssignment = {"VNF1", "capability1"};
capabilities.put("capability", capabilitiesAssignment);
- when(substitutionMapping.getCapabilities()).thenReturn(capabilities);
- componentToscaTopologyTemplate.setSubstitution_mappings(substitutionMapping);
-
+ when(substitutionMapping.getCapabilities()).thenReturn(capabilities);
+ componentToscaTopologyTemplate.setSubstitution_mappings(substitutionMapping);
final ToscaTemplate componentInterfaceToscaTemplate = new ToscaTemplate("");
final String designerPropertyValue = "designerValue";
final String versionPropertyValue = "versionValue";
final String namePropertyValue = "nameValue";
final String invariantIdPropertyValue = "invariantIdValue";
- final ToscaNodeType interfaceToscaNodeType = createDefaultInterfaceToscaNodeType(designerPropertyValue,
- versionPropertyValue, namePropertyValue, invariantIdPropertyValue);
+ final ToscaNodeType interfaceToscaNodeType = createDefaultInterfaceToscaNodeType(designerPropertyValue, versionPropertyValue,
+ namePropertyValue, invariantIdPropertyValue);
final String nsNodeTypeName = "nsNodeTypeName";
componentInterfaceToscaTemplate.setNode_types(ImmutableMap.of(nsNodeTypeName, interfaceToscaNodeType));
-
-
when(toscaExportHandler.convertToToscaTemplate(component)).thenReturn(Either.left(componentToscaTemplate));
when(toscaExportHandler.convertInterfaceNodeType(any(), any(), any(), any(), anyBoolean()))
.thenReturn(Either.left(componentInterfaceToscaTemplate));
-
final List<VnfDescriptor> vnfDescriptorList = new ArrayList<>();
VnfDescriptor vnfDescriptor1 = new VnfDescriptor();
vnfDescriptor1.setName(VNFD_AMF_NODE_NAME);
vnfDescriptor1.setVnfdFileName("vnfd_amf.yaml");
vnfDescriptor1.setNodeType("com.ericsson.resource.abstract.Ericsson.AMF");
-
vnfDescriptorList.add(vnfDescriptor1);
-
//when
final Nsd nsd = nsDescriptorGenerator.generate(component, vnfDescriptorList).orElse(null);
//then
@@ -187,48 +174,31 @@ class NsDescriptorGeneratorImplTest {
assertThat("Nsd version should be as expected", nsd.getVersion(), is(versionPropertyValue));
assertThat("Nsd name should be as expected", nsd.getName(), is(namePropertyValue));
assertThat("Nsd invariantId should be as expected", nsd.getInvariantId(), is(invariantIdPropertyValue));
-
final Map<String, Object> toscaTemplateYaml = readYamlAsMap(nsd.getContents());
- @SuppressWarnings("unchecked")
- final Map<String, Object> topologyTemplate = (Map<String, Object>) toscaTemplateYaml.get("topology_template");
+ @SuppressWarnings("unchecked") final Map<String, Object> topologyTemplate = (Map<String, Object>) toscaTemplateYaml.get("topology_template");
assertThat("topology_template should not be empty", topologyTemplate, is(not(anEmptyMap())));
- @SuppressWarnings("unchecked")
- final Map<String, Object> substitutionMappings =
- (Map<String, Object>) topologyTemplate.get("substitution_mappings");
+ @SuppressWarnings("unchecked") final Map<String, Object> substitutionMappings = (Map<String, Object>) topologyTemplate
+ .get("substitution_mappings");
assertThat("substitution_mappings should not be empty", substitutionMappings, is(not(anEmptyMap())));
- assertThat("substitution_mappings->node_type should not be null",
- substitutionMappings.get("node_type"), is(notNullValue()));
- assertThat("substitution_mappings->node_type should be as expected",
- substitutionMappings.get("node_type"), is(nsNodeTypeName));
-
+ assertThat("substitution_mappings->node_type should not be null", substitutionMappings.get("node_type"), is(notNullValue()));
+ assertThat("substitution_mappings->node_type should be as expected", substitutionMappings.get("node_type"), is(nsNodeTypeName));
final Map<String, List<String>> subMappingRequirements = (Map<String, List<String>>) substitutionMappings.get("requirements");
assertThat(subMappingRequirements.get(VIRTUAL_LINK_REQUIREMENT_NAME).get(0), is("VNF1"));
assertThat(subMappingRequirements.get(VIRTUAL_LINK_REQUIREMENT_NAME).get(1), is(VIRTUAL_LINK_REQUIREMENT_NAME));
final Map<String, List<String>> subMappingCapabilities = (Map<String, List<String>>) substitutionMappings.get("capabilities");
assertThat(subMappingCapabilities.get("capability").get(0), is("VNF1"));
assertThat(subMappingCapabilities.get("capability").get(1), is("capability1"));
-
- @SuppressWarnings("unchecked")
- final Map<String, Object> nodeTemplates =
- (Map<String, Object>) topologyTemplate.get("node_templates");
- @SuppressWarnings("unchecked")
- final Map<String, Object> nodeTemplate =
- (Map<String, Object>) nodeTemplates.get(VNFD_AMF_NODE_NAME);
- assertThat("capabilities should be null",
- nodeTemplate.get("capabilities"), is(nullValue()));
+ @SuppressWarnings("unchecked") final Map<String, Object> nodeTemplates = (Map<String, Object>) topologyTemplate.get("node_templates");
+ @SuppressWarnings("unchecked") final Map<String, Object> nodeTemplate = (Map<String, Object>) nodeTemplates.get(VNFD_AMF_NODE_NAME);
+ assertThat("capabilities should be null", nodeTemplate.get("capabilities"), is(nullValue()));
}
- private ToscaNodeType createDefaultInterfaceToscaNodeType(final String designerPropertyValue,
- final String versionPropertyValue,
- final String namePropertyValue,
- final String invariantIdPropertyValue) {
+ private ToscaNodeType createDefaultInterfaceToscaNodeType(final String designerPropertyValue, final String versionPropertyValue,
+ final String namePropertyValue, final String invariantIdPropertyValue) {
final ToscaNodeType interfaceToscaNodeType = new ToscaNodeType();
- interfaceToscaNodeType.setProperties(
- ImmutableMap.of("designer", createToscaProperty(designerPropertyValue),
- "version", createToscaProperty(versionPropertyValue),
- "name", createToscaProperty(namePropertyValue),
- "invariant_id", createToscaProperty(invariantIdPropertyValue))
- );
+ interfaceToscaNodeType.setProperties(ImmutableMap
+ .of("designer", createToscaProperty(designerPropertyValue), "version", createToscaProperty(versionPropertyValue), "name",
+ createToscaProperty(namePropertyValue), "invariant_id", createToscaProperty(invariantIdPropertyValue)));
return interfaceToscaNodeType;
}
@@ -240,8 +210,7 @@ class NsDescriptorGeneratorImplTest {
private ToscaProperty createToscaProperty(final String value) {
final ToscaProperty toscaProperty = new ToscaProperty();
- final ToscaPropertyConstraint toscaPropertyConstraint =
- new ToscaPropertyConstraintValidValues(ImmutableList.of(value));
+ final ToscaPropertyConstraint toscaPropertyConstraint = new ToscaPropertyConstraintValidValues(ImmutableList.of(value));
toscaProperty.setConstraints(ImmutableList.of(toscaPropertyConstraint));
return toscaProperty;
}
@@ -250,7 +219,7 @@ class NsDescriptorGeneratorImplTest {
private Map<String, Object> readYamlAsMap(final byte[] yamlContents) throws IOException {
final Yaml yaml = new Yaml();
try (final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(yamlContents)) {
- return (Map<String, Object>) yaml.load(byteArrayInputStream);
+ return (Map<String, Object>) yaml.load(byteArrayInputStream);
}
}
-} \ No newline at end of file
+}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImplTest.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImplTest.java
index e223fda962..3c3254924c 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImplTest.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImplTest.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -48,30 +48,23 @@ class VnfDescriptorGeneratorImplTest {
artifactDefinition.setPayload(onboardedPackage);
artifactDefinition.setArtifactName("vnf-onboarded-csar.csar");
final String vnfDescriptorName = "vnf-onboarded-csar";
- final VnfDescriptor vnfDescriptor = vnfDescriptorGenerator
- .generate(vnfDescriptorName, artifactDefinition).orElse(null);
+ final VnfDescriptor vnfDescriptor = vnfDescriptorGenerator.generate(vnfDescriptorName, artifactDefinition).orElse(null);
final String expectedNodeType = "com.ericsson.resource.abstract.Ericsson.AMF";
final String expectedVnfdFileName = "vnfd_amf.yaml";
assertThat("Vnf Descriptor should be present", vnfDescriptor, is(notNullValue()));
- assertThat("Vnf Descriptor should have the expected name", vnfDescriptor.getName(),
- is(vnfDescriptorName));
- assertThat("Vnf Descriptor should have the expected node type", vnfDescriptor.getNodeType(),
- is(expectedNodeType));
- assertThat("Vnf Descriptor should have the expected vnfd file name", vnfDescriptor.getVnfdFileName(),
- is(expectedVnfdFileName));
- assertThat("Vnf Descriptor should contain the expected definition files count",
- vnfDescriptor.getDefinitionFiles().size(), is(2));
- assertThat("Vnf Descriptor should contain the expected definition entries",
- vnfDescriptor.getDefinitionFiles().keySet(), contains("Definitions/vnfd_amf.yaml",
- "Definitions/etsi_nfv_sol001_vnfd_2_5_1_types.yaml"));
+ assertThat("Vnf Descriptor should have the expected name", vnfDescriptor.getName(), is(vnfDescriptorName));
+ assertThat("Vnf Descriptor should have the expected node type", vnfDescriptor.getNodeType(), is(expectedNodeType));
+ assertThat("Vnf Descriptor should have the expected vnfd file name", vnfDescriptor.getVnfdFileName(), is(expectedVnfdFileName));
+ assertThat("Vnf Descriptor should contain the expected definition files count", vnfDescriptor.getDefinitionFiles().size(), is(2));
+ assertThat("Vnf Descriptor should contain the expected definition entries", vnfDescriptor.getDefinitionFiles().keySet(),
+ contains("Definitions/vnfd_amf.yaml", "Definitions/etsi_nfv_sol001_vnfd_2_5_1_types.yaml"));
}
private byte[] getResourceAsByteArray(final String filename) throws IOException {
try (final InputStream inputStream = readFileAsStream(filename)) {
return IOUtils.toByteArray(inputStream);
} catch (final IOException ex) {
- throw new IOException(
- String.format("Could not read the file \"%s\"", filename), ex);
+ throw new IOException(String.format("Could not read the file \"%s\"", filename), ex);
}
}
@@ -79,5 +72,4 @@ class VnfDescriptorGeneratorImplTest {
final Path path = Paths.get(testResourcesPath.toString(), fileName);
return new FileInputStream(path.toFile());
}
-
-} \ No newline at end of file
+}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersionComparatorTest.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersionComparatorTest.java
index 6225cea924..8e51eaf2f0 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersionComparatorTest.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersionComparatorTest.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -39,4 +39,4 @@ class EtsiVersionComparatorTest {
assertEquals(1, comparator.compare(VERSION_3_3_1, VERSION_2_7_1));
assertEquals(-1, comparator.compare(VERSION_2_7_1, VERSION_3_3_1));
}
-} \ No newline at end of file
+}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGeneratorTest.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGeneratorTest.java
index 5341598ad1..b5ec982e1b 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGeneratorTest.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGeneratorTest.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.tosca.yaml;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -40,24 +40,15 @@ class ToscaTemplateYamlGeneratorTest {
void testGenerateYamlWithImportsKey() {
//given
final ToscaTemplate toscaTemplate = new ToscaTemplate("tosca_simple_yaml_1_1");
- final List<Map<String, Map<String, String>>> importList =
- ImmutableList.of(
- ImmutableMap.of("etsi_nfv_sol001_nsd_2_7_1_types",
- ImmutableMap.of("file", "etsi_nfv_sol001_nsd_2_7_1_types.yaml")
- ),
- ImmutableMap.of("anotherImport",
- ImmutableMap.of("file", "anotherImport.yaml")
- )
- );
+ final List<Map<String, Map<String, String>>> importList = ImmutableList
+ .of(ImmutableMap.of("etsi_nfv_sol001_nsd_2_7_1_types", ImmutableMap.of("file", "etsi_nfv_sol001_nsd_2_7_1_types.yaml")),
+ ImmutableMap.of("anotherImport", ImmutableMap.of("file", "anotherImport.yaml")));
toscaTemplate.setImports(importList);
final ToscaTemplateYamlGenerator toscaTemplateYamlGenerator = new ToscaTemplateYamlGenerator(toscaTemplate);
//when
final String toscaTemplateYamlString = toscaTemplateYamlGenerator.parseToYamlString();
-
//then
- final String expectedImports = "imports:\n"
- + "- file: etsi_nfv_sol001_nsd_2_7_1_types.yaml\n"
- + "- file: anotherImport.yaml";
+ final String expectedImports = "imports:\n" + "- file: etsi_nfv_sol001_nsd_2_7_1_types.yaml\n" + "- file: anotherImport.yaml";
assertThat("Imports format should be as expected", toscaTemplateYamlString.contains(expectedImports), is(true));
}
@@ -65,17 +56,15 @@ class ToscaTemplateYamlGeneratorTest {
void testGenerateYamlWithToscaProperty() {
//given
final ToscaTemplate toscaTemplate = new ToscaTemplate("tosca_simple_yaml_1_1");
-
final Map<String, ToscaProperty> toscaPropertyMap = new HashMap<>();
final ToscaProperty toscaProperty = new ToscaProperty();
final String defaultpValue = "defaultpValue";
toscaProperty.setDefaultp(defaultpValue);
- ToscaPropertyConstraintValidValues toscaPropertyConstraintValidValues =
- new ToscaPropertyConstraintValidValues(Collections.singletonList(defaultpValue));
+ ToscaPropertyConstraintValidValues toscaPropertyConstraintValidValues = new ToscaPropertyConstraintValidValues(
+ Collections.singletonList(defaultpValue));
toscaProperty.setConstraints(Collections.singletonList(toscaPropertyConstraintValidValues));
final String propertyName = "aProperty";
toscaPropertyMap.put(propertyName, toscaProperty);
-
final Map<String, ToscaNodeType> toscaNodeMap = new HashMap<>();
final ToscaNodeType toscaNodeType = new ToscaNodeType();
toscaNodeType.setProperties(toscaPropertyMap);
@@ -84,15 +73,10 @@ class ToscaTemplateYamlGeneratorTest {
final ToscaTemplateYamlGenerator toscaTemplateYamlGenerator = new ToscaTemplateYamlGenerator(toscaTemplate);
//when
final String toscaTemplateYamlString = toscaTemplateYamlGenerator.parseToYamlString();
-
- final String expectedProperty = String.format("%s:\n"
- + " default: %s\n"
- + " constraints:\n"
- + " - valid_values:\n"
- + " - %s",
- propertyName, defaultpValue, defaultpValue);
+ final String expectedProperty = String
+ .format("%s:\n" + " default: %s\n" + " constraints:\n" + " - valid_values:\n" + " - %s", propertyName,
+ defaultpValue, defaultpValue);
//then
- assertThat("Property format should be as expected",
- toscaTemplateYamlString.contains(expectedProperty), is(true));
+ assertThat("Property format should be as expected", toscaTemplateYamlString.contains(expectedProperty), is(true));
}
-} \ No newline at end of file
+}