aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be-plugins/etsi-nfv-nsd-csar-plugin
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
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')
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java30
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java8
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java2
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java2
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java5
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java6
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java28
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java67
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java4
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java130
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java8
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java52
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java8
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java2
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java5
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java29
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java8
-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
28 files changed, 195 insertions, 438 deletions
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java
index ed3a7fc4ee..38f03f12f5 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.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.builder;
import java.time.ZonedDateTime;
@@ -30,19 +30,18 @@ import java.util.TreeSet;
* Builder for the manifest (.mf) file in a NSD CSAR
*/
public class NsdCsarManifestBuilder {
+
static final String METADATA = "metadata";
static final String SOURCE = "Source";
static final String COMPATIBLE_SPECIFICATION_VERSIONS = "compatible_specification_versions";
+ static final String NSD_RELEASE_DATE_TIME = "nsd_release_date_time";
+ static final String ATTRIBUTE_SEPARATOR = ": ";
private static final String NSD_DESIGNER = "nsd_designer";
private static final String NSD_FILE_STRUCTURE_VERSION = "nsd_file_structure_version";
- static final String NSD_RELEASE_DATE_TIME = "nsd_release_date_time";
private static final String NSD_NAME = "nsd_name";
private static final String NSD_INVARIANT_ID = "nsd_invariant_id";
- static final String ATTRIBUTE_SEPARATOR = ": ";
private static final String NEW_LINE = "\n";
- private static final DateTimeFormatter RFC_3339_DATE_TIME_FORMATTER =
- DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
-
+ private static final DateTimeFormatter RFC_3339_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
private final MetadataHeader metadataHeader;
private final Set<String> sources;
private final Set<String> compatibleSpecificationVersions;
@@ -137,21 +136,13 @@ public class NsdCsarManifestBuilder {
appendEntry(metadataBuilder, NSD_FILE_STRUCTURE_VERSION, metadataHeader.fileStructureVersion);
final StringBuilder sourceBuilder = new StringBuilder();
sources.forEach(source -> appendEntry(sourceBuilder, SOURCE, source));
-
final StringBuilder compatibleSpecificationVersionsBuilder = new StringBuilder();
if (!compatibleSpecificationVersions.isEmpty()) {
- compatibleSpecificationVersionsBuilder.append(COMPATIBLE_SPECIFICATION_VERSIONS)
- .append(ATTRIBUTE_SEPARATOR)
- .append(String.join(",", compatibleSpecificationVersions))
- .append(NEW_LINE);
+ compatibleSpecificationVersionsBuilder.append(COMPATIBLE_SPECIFICATION_VERSIONS).append(ATTRIBUTE_SEPARATOR)
+ .append(String.join(",", compatibleSpecificationVersions)).append(NEW_LINE);
}
-
final StringBuilder builder = new StringBuilder();
-
- builder.append(metadataBuilder)
- .append(compatibleSpecificationVersionsBuilder)
- .append(NEW_LINE)
- .append(sourceBuilder);
+ builder.append(metadataBuilder).append(compatibleSpecificationVersionsBuilder).append(NEW_LINE).append(sourceBuilder);
return builder.toString();
}
@@ -167,17 +158,16 @@ public class NsdCsarManifestBuilder {
private void appendEntry(final StringBuilder builder, final String entry, final String value) {
if (value != null) {
- builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value)
- .append(NEW_LINE);
+ builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value).append(NEW_LINE);
}
}
private class MetadataHeader {
+
private String fileStructureVersion;
private String nsdName;
private String nsdReleaseDateTime;
private String designer;
private String invariantId;
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java
index e709993b45..64f0b9f1df 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.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.builder;
/**
@@ -30,10 +30,8 @@ public class NsdToscaMetadataBuilder {
public static final String ENTRY_DEFINITIONS = "Entry-Definitions";
public static final String ETSI_ENTRY_CHANGE_LOG = "ETSI-Entry-Change-Log";
public static final String ETSI_ENTRY_MANIFEST = "ETSI-Entry-Manifest";
-
private static final String ATTRIBUTE_SEPARATOR = ": ";
private static final String NEW_LINE = "\n";
-
private final StringBuilder builder = new StringBuilder();
private String csarVersion;
private String createdBy;
@@ -125,9 +123,7 @@ public class NsdToscaMetadataBuilder {
private void appendEntry(final String entry, final String value) {
if (value != null) {
- builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value)
- .append(NEW_LINE);
+ builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value).append(NEW_LINE);
}
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java
index 2483b2ebe0..d7b70fe6dd 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.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.exception;
/**
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java
index e4f966fea3..45038e3c33 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.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.exception;
/**
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java
index c1c792e443..fb08f56ac2 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,15 +17,14 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.factory;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsdCsarGenerator;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsdCsarGeneratorImpl;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.VnfDescriptorGenerator;
-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.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Component;
@@ -51,5 +51,4 @@ public class EtsiNfvNsdCsarGeneratorFactory {
return etsiNfvNsdCsarGeneratorObjectProvider
.getObject(nsDescriptorConfig, vnfDescriptorGenerator, nsDescriptorGeneratorFactory, artifactCassandraDao);
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java
index 5563078964..10dee994e7 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.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.factory;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.NsDescriptorGenerator;
@@ -42,8 +42,6 @@ public class NsDescriptorGeneratorFactory {
}
public NsDescriptorGenerator create() {
- return nsDescriptorGeneratorProvider
- .getObject(toscaExportHandler, toscaTemplateYamlGeneratorProvider);
+ return nsDescriptorGeneratorProvider.getObject(toscaExportHandler, toscaTemplateYamlGeneratorProvider);
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java
index ff20a3e70b..90359a550d 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.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.openecomp.sdc.common.api.ArtifactTypeEnum.ETSI_PACKAGE;
@@ -39,11 +39,10 @@ import org.slf4j.LoggerFactory;
@org.springframework.stereotype.Component("etsiNfvNsCsarEntryGenerator")
public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
- private static final Logger LOGGER = LoggerFactory.getLogger(EtsiNfvNsCsarEntryGenerator.class);
static final String ETSI_NS_COMPONENT_CATEGORY = "ETSI NFV Network Service";
static final String NSD_FILE_PATH_FORMAT = "Artifacts/%s/%s.csar";
static final String ETSI_VERSION_METADATA = "ETSI Version";
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(EtsiNfvNsCsarEntryGenerator.class);
private final EtsiNfvNsdCsarGeneratorFactory etsiNfvNsdCsarGeneratorFactory;
public EtsiNfvNsCsarEntryGenerator(final EtsiNfvNsdCsarGeneratorFactory etsiNfvNsdCsarGeneratorFactory) {
@@ -51,8 +50,8 @@ public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
}
/**
- * Generates a Network Service CSAR based on a SERVICE component of category {@link
- * EtsiNfvNsCsarEntryGenerator#ETSI_NS_COMPONENT_CATEGORY} and wraps it in a SDC CSAR entry.
+ * Generates a Network Service CSAR based on a SERVICE component of category {@link EtsiNfvNsCsarEntryGenerator#ETSI_NS_COMPONENT_CATEGORY} and
+ * wraps it in a SDC CSAR entry.
*
* @param component the component to create the NS CSAR from
* @return an entry to be added in the Component CSAR by SDC
@@ -64,31 +63,24 @@ public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
LOGGER.debug("Ignoring NSD CSAR generation for component '{}' as it is not a SERVICE", componentName);
return Collections.emptyMap();
}
-
- final boolean isEOTemplate = component.getCategories().stream()
- .anyMatch(category -> ETSI_NS_COMPONENT_CATEGORY.equals(category.getName()));
+ final boolean isEOTemplate = component.getCategories().stream().anyMatch(category -> ETSI_NS_COMPONENT_CATEGORY.equals(category.getName()));
if (!isEOTemplate) {
- LOGGER.debug("Ignoring NSD CSAR generation for component '{}' as it does not belong to the category '{}'",
- componentName, ETSI_NS_COMPONENT_CATEGORY);
+ LOGGER.debug("Ignoring NSD CSAR generation for component '{}' as it does not belong to the category '{}'", componentName,
+ ETSI_NS_COMPONENT_CATEGORY);
return Collections.emptyMap();
}
-
final byte[] nsdCsar;
try {
final EtsiVersion etsiVersion = getComponentEtsiVersion(component);
- final EtsiNfvNsdCsarGenerator etsiNfvNsdCsarGenerator =
- etsiNfvNsdCsarGeneratorFactory.create(etsiVersion);
+ final EtsiNfvNsdCsarGenerator etsiNfvNsdCsarGenerator = etsiNfvNsdCsarGeneratorFactory.create(etsiVersion);
nsdCsar = etsiNfvNsdCsarGenerator.generateNsdCsar(component);
} catch (final NsdException e) {
- LOGGER.error("Could not create NSD CSAR entry for component '{}'"
- , component.getName(), e);
+ LOGGER.error("Could not create NSD CSAR entry for component '{}'", component.getName(), e);
return Collections.emptyMap();
} catch (final Exception e) {
- LOGGER.error("Could not create NSD CSAR entry for component '{}'. An unexpected exception occurred"
- , component.getName(), e);
+ LOGGER.error("Could not create NSD CSAR entry for component '{}'. An unexpected exception occurred", component.getName(), e);
return Collections.emptyMap();
}
-
return createEntry(component.getNormalizedName(), nsdCsar);
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java
index f9ee55eecf..072c4c5a89 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.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 org.openecomp.sdc.be.model.Component;
@@ -34,5 +34,4 @@ public interface EtsiNfvNsdCsarGenerator {
* @return the CSAR package content
*/
byte[] generateNsdCsar(Component component) throws NsdException;
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java
index efc6ade92d..e7d30197d7 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.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.openecomp.sdc.common.api.ArtifactTypeEnum.ETSI_PACKAGE;
@@ -71,22 +71,18 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(EtsiNfvNsdCsarGeneratorImpl.class);
-
private static final String MANIFEST_EXT = "mf";
private static final String SLASH = "/";
private static final String DOT = ".";
private static final String DOT_YAML = DOT + "yaml";
-
private static final String DEFINITION = "Definitions";
private static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
-
private final VnfDescriptorGenerator vnfDescriptorGenerator;
private final NsDescriptorGeneratorFactory nsDescriptorGeneratorFactory;
private final ArtifactCassandraDao artifactCassandraDao;
private final NsDescriptorConfig nsDescriptorConfig;
- public EtsiNfvNsdCsarGeneratorImpl(final NsDescriptorConfig nsDescriptorConfig,
- final VnfDescriptorGenerator vnfDescriptorGenerator,
+ public EtsiNfvNsdCsarGeneratorImpl(final NsDescriptorConfig nsDescriptorConfig, final VnfDescriptorGenerator vnfDescriptorGenerator,
final NsDescriptorGeneratorFactory nsDescriptorGeneratorFactory,
final ArtifactCassandraDao artifactCassandraDao) {
this.nsDescriptorConfig = nsDescriptorConfig;
@@ -100,19 +96,14 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (component == null) {
throw new NsdException("Could not generate the NSD CSAR, invalid component argument");
}
-
loadComponentArtifacts(component);
loadComponentInstancesArtifacts(component);
-
final String componentName = component.getName();
-
try {
LOGGER.debug("Starting NSD CSAR generation for component '{}'", componentName);
final Map<String, byte[]> nsdCsarFiles = new HashMap<>();
-
final List<VnfDescriptor> vnfDescriptorList = generateVnfPackages(component);
vnfDescriptorList.forEach(vnfPackage -> nsdCsarFiles.putAll(vnfPackage.getDefinitionFiles()));
-
final String nsdFileName = getNsdFileName(component);
final EtsiVersion etsiVersion = nsDescriptorConfig.getNsVersion();
final Nsd nsd = generateNsd(component, vnfDescriptorList);
@@ -120,13 +111,10 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
nsdCsarFiles.put(TOSCA_META_PATH, buildToscaMetaContent(nsdFileName).getBytes());
addEtsiSolNsdTypes(etsiVersion, nsdCsarFiles);
for (final String referencedFile : nsd.getArtifactReferences()) {
- getReferencedArtifact(component, referencedFile).ifPresent(
- artifactDefinition -> nsdCsarFiles.put(referencedFile, artifactDefinition.getPayloadData())
- );
+ getReferencedArtifact(component, referencedFile)
+ .ifPresent(artifactDefinition -> nsdCsarFiles.put(referencedFile, artifactDefinition.getPayloadData()));
}
- nsdCsarFiles
- .put(getManifestPath(nsdFileName), getManifestFileContent(nsd, etsiVersion, nsdCsarFiles.keySet()).getBytes());
-
+ nsdCsarFiles.put(getManifestPath(nsdFileName), getManifestFileContent(nsd, etsiVersion, nsdCsarFiles.keySet()).getBytes());
final byte[] csar = buildCsarPackage(nsdCsarFiles);
LOGGER.debug("Successfully generated NSD CSAR package");
return csar;
@@ -147,8 +135,7 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (artifactPayload.isPresent()) {
artifactDefinition.setPayload(artifactPayload.get());
} else {
- LOGGER.warn("Could not load component '{}' artifact '{}'",
- component.getName(), artifactDefinition.getArtifactName());
+ LOGGER.warn("Could not load component '{}' artifact '{}'", component.getName(), artifactDefinition.getArtifactName());
}
}
});
@@ -164,15 +151,14 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (MapUtils.isEmpty(deploymentArtifacts)) {
continue;
}
- deploymentArtifacts.values().stream()
- .filter(artifactDefinition -> StringUtils.isNotEmpty(artifactDefinition.getEsId()))
+ deploymentArtifacts.values().stream().filter(artifactDefinition -> StringUtils.isNotEmpty(artifactDefinition.getEsId()))
.forEach(artifactDefinition -> {
final Optional<byte[]> artifactPayload = loadArtifactPayload(artifactDefinition.getEsId());
if (artifactPayload.isPresent()) {
artifactDefinition.setPayload(artifactPayload.get());
} else {
- LOGGER.warn("Could not load component '{}' instance '{}' artifact '{}'",
- component.getName(), componentInstance.getName(), artifactDefinition.getArtifactName());
+ LOGGER.warn("Could not load component '{}' instance '{}' artifact '{}'", component.getName(), componentInstance.getName(),
+ artifactDefinition.getArtifactName());
}
});
}
@@ -184,34 +170,27 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
LOGGER.warn("Could not find any instance in service '{}'", component.getName());
return Collections.emptyList();
}
-
final List<VnfDescriptor> vnfDescriptorList = new ArrayList<>();
for (final ComponentInstance componentInstance : componentInstanceList) {
final String componentInstanceName = componentInstance.getName();
final ArtifactDefinition onboardedCsarArtifact = findOnboardedCsar(componentInstance).orElse(null);
if (onboardedCsarArtifact == null) {
- LOGGER.warn(
- "Unable to generate VNF Package for component instance '{}', no onboarded package present",
- componentInstanceName);
+ LOGGER.warn("Unable to generate VNF Package for component instance '{}', no onboarded package present", componentInstanceName);
continue;
}
final Optional<VnfDescriptor> vnfPackage;
try {
vnfPackage = vnfDescriptorGenerator.generate(componentInstanceName, onboardedCsarArtifact);
} catch (final Exception e) {
- final String errorMsg =
- String.format("Could not generate VNF package for component instance %s", componentInstanceName);
+ final String errorMsg = String.format("Could not generate VNF package for component instance %s", componentInstanceName);
throw new NsdException(errorMsg, e);
}
if (vnfPackage.isPresent()) {
vnfDescriptorList.add(vnfPackage.get());
} else {
- LOGGER.warn(
- "Unable to generate VNF Package for component instance '{}', no onboarded package present",
- componentInstanceName);
+ LOGGER.warn("Unable to generate VNF Package for component instance '{}', no onboarded package present", componentInstanceName);
}
}
-
return vnfDescriptorList;
}
@@ -220,23 +199,15 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (artifactDefinitionMap == null || artifactDefinitionMap.isEmpty()) {
return Optional.empty();
}
- return artifactDefinitionMap.values()
- .stream()
- .filter(artifactDefinition -> {
- final String artifactType = (String) artifactDefinition
- .getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE);
- return ONBOARDED_PACKAGE.getType().equals(artifactType) || ETSI_PACKAGE.getType().equals(artifactType);
- })
- .findFirst();
+ return artifactDefinitionMap.values().stream().filter(artifactDefinition -> {
+ final String artifactType = (String) artifactDefinition.getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE);
+ return ONBOARDED_PACKAGE.getType().equals(artifactType) || ETSI_PACKAGE.getType().equals(artifactType);
+ }).findFirst();
}
- private void addEtsiSolNsdTypes(final EtsiVersion etsiVersion,
- final Map<String, byte[]> nsdCsarFileMap) {
- final EtsiVersion currentVersion = etsiVersion == null ?
- EtsiVersion.getDefaultVersion() : etsiVersion;
-
+ private void addEtsiSolNsdTypes(final EtsiVersion etsiVersion, final Map<String, byte[]> nsdCsarFileMap) {
+ final EtsiVersion currentVersion = etsiVersion == null ? EtsiVersion.getDefaultVersion() : etsiVersion;
final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
-
try {
final Resource[] resources =
resolver.getResources(String.format("classpath:etsi-nfv-types/%s/*.*", currentVersion.getVersion()));
@@ -388,3 +359,5 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
}
}
+
+
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java
index d36757cf48..726a5e190c 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.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 java.util.List;
@@ -31,7 +31,7 @@ public interface NsDescriptorGenerator {
/**
* Generates the TOSCA Network Service Descriptor (NSD) based on a SERVICE SDC component and its VNF instances.
*
- * @param component the SERVICE component
+ * @param component the SERVICE component
* @param vnfDescriptorList the VNF instances
* @return a NSD representation
*/
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
index 2a2e2b008a..62f8e25590 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.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 com.google.common.collect.ImmutableMap;
@@ -63,15 +63,14 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(NsDescriptorGeneratorImpl.class);
private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1";
private static final String NS_TOSCA_TYPE = "tosca.nodes.nfv.NS";
- private static final List<Map<String, Map<String, String>>> DEFAULT_IMPORTS = ConfigurationManager
- .getConfigurationManager().getConfiguration().getDefaultImports();
+ private static final List<Map<String, Map<String, String>>> DEFAULT_IMPORTS = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getDefaultImports();
private static final List<String> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE = Arrays
.asList("cds_model_name", "cds_model_version", "skip_post_instantiation_configuration", "controller_actor");
private static final List<String> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TEMPLATE = Arrays
- .asList("nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming", "availability_zone_max_count",
- "min_instances", "max_instances", "multi_stage_design", "sdnc_model_name", "sdnc_model_version",
- "sdnc_artifact_name", "skip_post_instantiation_configuration", "controller_actor");
-
+ .asList("nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming", "availability_zone_max_count", "min_instances", "max_instances",
+ "multi_stage_design", "sdnc_model_name", "sdnc_model_version", "sdnc_artifact_name", "skip_post_instantiation_configuration",
+ "controller_actor");
private final ToscaExportHandler toscaExportHandler;
private final ObjectProvider<ToscaTemplateYamlGenerator> toscaTemplateYamlGeneratorProvider;
@@ -81,19 +80,16 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
this.toscaTemplateYamlGeneratorProvider = toscaTemplateYamlGeneratorProvider;
}
- public Optional<Nsd> generate(final Component component,
- final List<VnfDescriptor> vnfDescriptorList) throws NsdException {
+ public Optional<Nsd> generate(final Component component, final List<VnfDescriptor> vnfDescriptorList) throws NsdException {
if (!ComponentTypeEnum.SERVICE.equals(component.getComponentType())) {
return Optional.empty();
}
-
final ToscaTemplate toscaTemplate = createNetworkServiceDescriptor(component, vnfDescriptorList);
final ToscaNodeType nsNodeType = toscaTemplate.getNode_types().values().stream()
.filter(toscaNodeType -> NS_TOSCA_TYPE.equals(toscaNodeType.getDerived_from())).findFirst().orElse(null);
if (nsNodeType == null) {
return Optional.empty();
}
-
return Optional.of(buildNsd(toscaTemplate, nsNodeType));
}
@@ -103,8 +99,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
nsd.setVersion(getProperty(nsNodeType, Nsd.VERSION_PROPERTY));
nsd.setName(getProperty(nsNodeType, Nsd.NAME_PROPERTY));
nsd.setInvariantId(getProperty(nsNodeType, Nsd.INVARIANT_ID_PROPERTY));
- final ToscaTemplateYamlGenerator yamlParserProvider =
- toscaTemplateYamlGeneratorProvider.getObject(toscaTemplate);
+ final ToscaTemplateYamlGenerator yamlParserProvider = toscaTemplateYamlGeneratorProvider.getObject(toscaTemplate);
final byte[] contents = yamlParserProvider.parseToYamlString().getBytes();
nsd.setContents(contents);
final List<String> interfaceImplementations = getInterfaceImplementations(toscaTemplate);
@@ -117,14 +112,10 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
return Collections.emptyList();
}
final List<String> interfaceImplementations = new ArrayList<>();
- final Collection<ToscaNodeTemplate> nodeTemplates =
- template.getTopology_template().getNode_templates().values();
- nodeTemplates.stream()
- .filter(toscaNodeTemplate -> toscaNodeTemplate.getInterfaces() != null)
- .forEach(toscaNodeTemplate ->
- toscaNodeTemplate.getInterfaces().values().forEach(interfaceInstance ->
- interfaceImplementations.addAll(getInterfaceImplementations(interfaceInstance))
- ));
+ final Collection<ToscaNodeTemplate> nodeTemplates = template.getTopology_template().getNode_templates().values();
+ nodeTemplates.stream().filter(toscaNodeTemplate -> toscaNodeTemplate.getInterfaces() != null).forEach(
+ toscaNodeTemplate -> toscaNodeTemplate.getInterfaces().values()
+ .forEach(interfaceInstance -> interfaceImplementations.addAll(getInterfaceImplementations(interfaceInstance))));
return interfaceImplementations;
}
@@ -142,78 +133,58 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
private String getProperty(final ToscaNodeType nodeType, final String propertyName) {
final ToscaProperty toscaProperty = nodeType.getProperties().get(propertyName);
-
- final String errorMsg =
- String.format("Property '%s' must be defined and must have a valid values constraint", propertyName);
+ final String errorMsg = String.format("Property '%s' must be defined and must have a valid values constraint", propertyName);
final String returnValueOnError = "unknown";
if (toscaProperty == null || CollectionUtils.isEmpty(toscaProperty.getConstraints())) {
LOGGER.error(errorMsg);
return returnValueOnError;
}
-
final ToscaPropertyConstraint toscaPropertyConstraint = toscaProperty.getConstraints().get(0);
if (ConstraintType.VALID_VALUES != toscaPropertyConstraint.getConstraintType()) {
LOGGER.error(errorMsg);
return returnValueOnError;
}
-
- final ToscaPropertyConstraintValidValues validValuesConstraint =
- (ToscaPropertyConstraintValidValues) toscaPropertyConstraint;
+ final ToscaPropertyConstraintValidValues validValuesConstraint = (ToscaPropertyConstraintValidValues) toscaPropertyConstraint;
final List<String> validValues = validValuesConstraint.getValidValues();
- if(CollectionUtils.isEmpty(validValues)) {
+ if (CollectionUtils.isEmpty(validValues)) {
LOGGER.error(errorMsg);
return returnValueOnError;
}
-
return validValues.get(0);
}
- private ToscaTemplate createNetworkServiceDescriptor(final Component component,
- final List<VnfDescriptor> vnfDescriptorList)
- throws NsdException {
-
+ private ToscaTemplate createNetworkServiceDescriptor(final Component component, final List<VnfDescriptor> vnfDescriptorList) throws NsdException {
final ToscaTemplate componentToscaTemplate = parseToToscaTemplate(component);
final ToscaTemplate componentToscaTemplateInterface = exportComponentInterfaceAsToscaTemplate(component);
-
- final Entry<String, ToscaNodeType> firstNodeTypeEntry =
- componentToscaTemplateInterface.getNode_types()
- .entrySet().stream().findFirst().orElse(null);
+ final Entry<String, ToscaNodeType> firstNodeTypeEntry = componentToscaTemplateInterface.getNode_types().entrySet().stream().findFirst()
+ .orElse(null);
if (firstNodeTypeEntry == null) {
throw new NsdException("Could not find abstract Service type");
}
-
final String nsNodeTypeName = firstNodeTypeEntry.getKey();
final ToscaNodeType nsNodeType = firstNodeTypeEntry.getValue();
-
final Map<String, ToscaNodeType> nodeTypeMap = new HashMap<>();
nodeTypeMap.put(nsNodeTypeName, createEtsiSolNsNodeType(nsNodeType));
-
if (componentToscaTemplate.getNode_types() == null) {
componentToscaTemplate.setNode_types(nodeTypeMap);
} else {
componentToscaTemplate.getNode_types().putAll(nodeTypeMap);
}
-
setPropertiesForNodeTemplates(componentToscaTemplate);
removeCapabilitiesFromNodeTemplates(componentToscaTemplate);
removeOnapPropertiesFromInputs(componentToscaTemplate);
handleSubstitutionMappings(componentToscaTemplate, nsNodeTypeName);
-
final Map<String, ToscaNodeTemplate> nodeTemplates = new HashMap<>();
- nodeTemplates.put(nsNodeTypeName, createNodeTemplateForNsNodeType(nsNodeTypeName,
- componentToscaTemplateInterface.getNode_types().get(nsNodeTypeName)));
-
+ nodeTemplates.put(nsNodeTypeName,
+ createNodeTemplateForNsNodeType(nsNodeTypeName, componentToscaTemplateInterface.getNode_types().get(nsNodeTypeName)));
if (componentToscaTemplate.getTopology_template().getNode_templates() == null) {
componentToscaTemplate.getTopology_template().setNode_templates(nodeTemplates);
} else {
setNodeTemplateTypesForVnfs(componentToscaTemplate, vnfDescriptorList);
componentToscaTemplate.getTopology_template().getNode_templates().putAll(nodeTemplates);
}
-
removeOnapMetaData(componentToscaTemplate);
-
setDefaultImportsForEtsiSolNsNsd(componentToscaTemplate, vnfDescriptorList);
-
return componentToscaTemplate;
}
@@ -228,8 +199,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
componentToscaTemplate.getTopology_template().setSubstitution_mappings(substitutionMapping);
}
- private void setNodeTemplateTypesForVnfs(final ToscaTemplate template,
- final List<VnfDescriptor> vnfDescriptorList) {
+ private void setNodeTemplateTypesForVnfs(final ToscaTemplate template, final List<VnfDescriptor> vnfDescriptorList) {
if (CollectionUtils.isEmpty(vnfDescriptorList)) {
return;
}
@@ -237,11 +207,9 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
if (MapUtils.isEmpty(nodeTemplateMap)) {
return;
}
- nodeTemplateMap.forEach((key, toscaNodeTemplate) ->
- vnfDescriptorList.stream()
- .filter(vnfDescriptor -> key.equals(vnfDescriptor.getName())).findFirst()
- .ifPresent(vnfDescriptor -> toscaNodeTemplate.setType(vnfDescriptor.getNodeType()))
- );
+ nodeTemplateMap.forEach(
+ (key, toscaNodeTemplate) -> vnfDescriptorList.stream().filter(vnfDescriptor -> key.equals(vnfDescriptor.getName())).findFirst()
+ .ifPresent(vnfDescriptor -> toscaNodeTemplate.setType(vnfDescriptor.getNodeType())));
}
private void setPropertiesForNodeTemplates(final ToscaTemplate template) {
@@ -257,10 +225,9 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
final Map<String, Object> editedPropertyMap = new HashMap<>();
for (final Entry<String, Object> property : propertyMap.entrySet()) {
- if (!PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TEMPLATE.contains(property.getKey())
- && propertyIsDefinedInNodeType(property.getKey())) {
- editedPropertyMap
- .put(property.getKey().substring(property.getKey().indexOf('_') + 1), property.getValue());
+ if (!PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TEMPLATE.contains(property.getKey()) && propertyIsDefinedInNodeType(
+ property.getKey())) {
+ editedPropertyMap.put(property.getKey().substring(property.getKey().indexOf('_') + 1), property.getValue());
}
}
if (editedPropertyMap.isEmpty()) {
@@ -270,14 +237,14 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
}
}
-
+
private void removeCapabilitiesFromNodeTemplates(final ToscaTemplate template) {
final Map<String, ToscaNodeTemplate> nodeTemplateMap = template.getTopology_template().getNode_templates();
if (MapUtils.isEmpty(nodeTemplateMap)) {
return;
}
for (final Entry<String, ToscaNodeTemplate> nodeTemplate : nodeTemplateMap.entrySet()) {
- nodeTemplate.getValue().setCapabilities(null);
+ nodeTemplate.getValue().setCapabilities(null);
}
}
@@ -285,8 +252,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
final ToscaTopolgyTemplate topologyTemplate = template.getTopology_template();
final Map<String, ToscaProperty> inputMap = topologyTemplate.getInputs();
if (MapUtils.isNotEmpty(inputMap)) {
- inputMap.entrySet()
- .removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
+ inputMap.entrySet().removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
}
if (MapUtils.isEmpty(inputMap)) {
topologyTemplate.setInputs(null);
@@ -302,8 +268,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
nodeTemplateMap.values().forEach(toscaNodeTemplate -> toscaNodeTemplate.setMetadata(null));
}
- private void setDefaultImportsForEtsiSolNsNsd(final ToscaTemplate template,
- final List<VnfDescriptor> vnfDescriptorList) {
+ private void setDefaultImportsForEtsiSolNsNsd(final ToscaTemplate template, final List<VnfDescriptor> vnfDescriptorList) {
final List<Map<String, Map<String, String>>> importEntryMap = new ArrayList<>();
final Map<String, Map<String, String>> defaultImportEntryMap = generateDefaultImportEntry();
if (MapUtils.isNotEmpty(defaultImportEntryMap)) {
@@ -318,22 +283,17 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
importEntryMap.add(vnfdImportVnfdEntry);
}
}
-
template.setImports(importEntryMap);
}
private Map<String, Map<String, String>> generateDefaultImportEntry() {
- return ImmutableMap.of("etsi_nfv_sol001_nsd_types",
- ImmutableMap.of("file", "etsi_nfv_sol001_nsd_types.yaml")
- );
+ return ImmutableMap.of("etsi_nfv_sol001_nsd_types", ImmutableMap.of("file", "etsi_nfv_sol001_nsd_types.yaml"));
}
private ToscaNodeType createEtsiSolNsNodeType(final ToscaNodeType nsNodeType) {
final ToscaNodeType toscaNodeType = new ToscaNodeType();
toscaNodeType.setDerived_from(NS_TOSCA_TYPE);
-
final Map<String, ToscaProperty> propertiesInNsNodeType = nsNodeType.getProperties();
-
for (final Entry<String, ToscaProperty> property : propertiesInNsNodeType.entrySet()) {
final ToscaProperty toscaProperty = property.getValue();
if (toscaProperty.getDefaultp() != null) {
@@ -342,36 +302,29 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
toscaProperty.setConstraints(Collections.singletonList(constraint));
}
}
-
- propertiesInNsNodeType.entrySet()
- .removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
+ propertiesInNsNodeType.entrySet().removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
toscaNodeType.setProperties(propertiesInNsNodeType);
-
return toscaNodeType;
}
private boolean propertyIsDefinedInNodeType(final String propertyName) {
// This will achieve what we want for now, but will look into a more generic solution which would involve
+
// checking the node_type definition in the VNFD
return !propertyName.equals("additional_parameters");
}
-
- private ToscaNodeTemplate createNodeTemplateForNsNodeType(final String nodeType,
- final ToscaNodeType toscaNodeType) {
+ private ToscaNodeTemplate createNodeTemplateForNsNodeType(final String nodeType, final ToscaNodeType toscaNodeType) {
final ToscaNodeTemplate nodeTemplate = new ToscaNodeTemplate();
nodeTemplate.setType(nodeType);
-
final Map<String, ToscaProperty> properties = toscaNodeType.getProperties();
final Map<String, Object> nodeTemplateProperties = new HashMap<>();
for (final Entry<String, ToscaProperty> property : properties.entrySet()) {
nodeTemplateProperties.put(property.getKey(), property.getValue().getDefaultp());
}
-
if (!nodeTemplateProperties.isEmpty()) {
nodeTemplate.setProperties(nodeTemplateProperties);
}
-
final Map<String, Object> interfaces = toscaNodeType.getInterfaces();
if (interfaces != null) {
for (final Entry<String, Object> nodeInterface : interfaces.entrySet()) {
@@ -381,37 +334,30 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
nodeTemplate.setInterfaces(interfaces);
}
-
return nodeTemplate;
}
private ToscaTemplate parseToToscaTemplate(final Component component) throws NsdException {
final Either<ToscaTemplate, ToscaError> toscaTemplateRes = toscaExportHandler.convertToToscaTemplate(component);
if (toscaTemplateRes.isRight()) {
- String errorMsg = String.format("Could not parse component '%s' to tosca template. Error '%s'",
- component.getName(), toscaTemplateRes.right().value().name());
+ String errorMsg = String
+ .format("Could not parse component '%s' to tosca template. Error '%s'", component.getName(), toscaTemplateRes.right().value().name());
throw new NsdException(errorMsg);
}
-
return toscaTemplateRes.left().value();
}
-
private ToscaTemplate exportComponentInterfaceAsToscaTemplate(final Component component) throws NsdException {
if (null == DEFAULT_IMPORTS) {
throw new NsdException("Could not load default CSAR imports from configuration");
}
-
final ToscaTemplate toscaTemplate = new ToscaTemplate(TOSCA_VERSION);
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
final Either<ToscaTemplate, ToscaError> toscaTemplateRes = toscaExportHandler
.convertInterfaceNodeType(new HashMap<>(), component, toscaTemplate, new HashMap<>(), false);
if (toscaTemplateRes.isRight()) {
- throw new NsdException(String.format("Could not create abstract service from component '%s'",
- component.getName()));
+ throw new NsdException(String.format("Could not create abstract service from component '%s'", component.getName()));
}
-
return toscaTemplateRes.left().value();
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java
index c4599d7cf4..e66adf3d06 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.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 java.util.Optional;
@@ -32,12 +32,10 @@ public interface VnfDescriptorGenerator {
/**
* Generates the a VNF Descriptor based on the ONBOARDED_PACKAGE artifact.
*
- * @param name the name of the VNF package
+ * @param name the name of the VNF package
* @param onboardedPackageArtifact the onboarded package for the VNF
* @return a representation of the VNF package
* @throws VnfDescriptorException when a problem happens during the generation
*/
- Optional<VnfDescriptor> generate(final String name, final ArtifactDefinition onboardedPackageArtifact)
- throws VnfDescriptorException;
-
+ Optional<VnfDescriptor> generate(final String name, final ArtifactDefinition onboardedPackageArtifact) throws VnfDescriptorException;
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java
index 8cf54d129a..902911b817 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.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 java.io.FileNotFoundException;
@@ -60,22 +60,22 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
private static final String DEFINITIONS_DIRECTORY = "Definitions";
private static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
- public Optional<VnfDescriptor> generate(final String name,
- final ArtifactDefinition onboardedPackageArtifact)
- throws VnfDescriptorException {
+ private static boolean isACsarArtifact(final ArtifactDefinition definition) {
+ return definition.getPayloadData() != null && definition.getArtifactName() != null && CSAR
+ .equalsIgnoreCase(FilenameUtils.getExtension(definition.getArtifactName()));
+ }
+
+ public Optional<VnfDescriptor> generate(final String name, final ArtifactDefinition onboardedPackageArtifact) throws VnfDescriptorException {
if (!isACsarArtifact(onboardedPackageArtifact)) {
return Optional.empty();
}
-
final FileContentHandler fileContentHandler;
try {
fileContentHandler = FileUtils.getFileContentMapFromZip(onboardedPackageArtifact.getPayloadData());
} catch (final ZipException e) {
- final String errorMsg = String
- .format("Could not unzip artifact '%s' content", onboardedPackageArtifact.getArtifactName());
+ final String errorMsg = String.format("Could not unzip artifact '%s' content", onboardedPackageArtifact.getArtifactName());
throw new VnfDescriptorException(errorMsg, e);
}
-
if (MapUtils.isEmpty(fileContentHandler.getFiles())) {
return Optional.empty();
}
@@ -83,9 +83,7 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
try {
mainDefinitionFile = getMainFilePathFromMetaFile(fileContentHandler).orElse(null);
} catch (final IOException e) {
- final String errorMsg = String
- .format("Could not read main definition file of artifact '%s'",
- onboardedPackageArtifact.getArtifactName());
+ final String errorMsg = String.format("Could not read main definition file of artifact '%s'", onboardedPackageArtifact.getArtifactName());
throw new VnfDescriptorException(errorMsg, e);
}
LOGGER.debug("found main file: {}", mainDefinitionFile);
@@ -95,30 +93,19 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
final VnfDescriptor vnfDescriptor = new VnfDescriptor();
vnfDescriptor.setName(name);
final String vnfdFileName = FilenameUtils.getName(mainDefinitionFile);
-
vnfDescriptor.setVnfdFileName(vnfdFileName);
vnfDescriptor.setDefinitionFiles(getFiles(fileContentHandler, mainDefinitionFile));
vnfDescriptor.setNodeType(getNodeType(getFileContent(fileContentHandler, mainDefinitionFile)));
-
return Optional.of(vnfDescriptor);
}
- private static boolean isACsarArtifact(final ArtifactDefinition definition) {
- return definition.getPayloadData() != null && definition.getArtifactName() != null && CSAR
- .equalsIgnoreCase(FilenameUtils.getExtension(definition.getArtifactName()));
- }
-
private Map<String, byte[]> getFiles(final FileContentHandler fileContentHandler, final String filePath) {
final Map<String, byte[]> files = new HashMap<>();
-
final byte[] fileContent = fileContentHandler.getFileContent(filePath);
-
if (fileContent != null) {
final String mainYmlFile = new String(fileContent);
LOGGER.debug("file content: {}", mainYmlFile);
-
- files.put(appendDefinitionDirPath(filePath.substring(filePath.lastIndexOf(SLASH) + 1)),
- getVnfdWithoutTopologyTemplate(fileContent));
+ files.put(appendDefinitionDirPath(filePath.substring(filePath.lastIndexOf(SLASH) + 1)), getVnfdWithoutTopologyTemplate(fileContent));
final List<Object> imports = getImportFilesPath(mainYmlFile);
LOGGER.info("found imports {}", imports);
for (final Object importObject : imports) {
@@ -135,15 +122,13 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
private String getFileContent(final FileContentHandler fileContentHandler, final String filePath) {
final byte[] fileContent = fileContentHandler.getFileContent(filePath);
-
if (fileContent != null) {
return new String(fileContent);
}
return null;
}
- private Optional<String> getMainFilePathFromMetaFile(final FileContentHandler fileContentHandler)
- throws IOException {
+ private Optional<String> getMainFilePathFromMetaFile(final FileContentHandler fileContentHandler) throws IOException {
final Map<String, String> metaFileContent = getMetaFileContent(fileContentHandler);
final String mainFile = metaFileContent.get(NsdToscaMetadataBuilder.ENTRY_DEFINITIONS);
if (mainFile != null) {
@@ -153,16 +138,13 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
return Optional.empty();
}
- private Map<String, String> getMetaFileContent(final FileContentHandler fileContentHandler)
- throws IOException {
+ private Map<String, String> getMetaFileContent(final FileContentHandler fileContentHandler) throws IOException {
final InputStream inputStream = fileContentHandler.getFileContentAsStream(TOSCA_META_PATH);
if (inputStream == null) {
throw new FileNotFoundException("Unable find " + TOSCA_META_PATH + " file");
}
final List<String> lines = IOUtils.readLines(inputStream, StandardCharsets.UTF_8);
-
- return lines.stream().map(str -> str.split(COLON))
- .collect(Collectors.toMap(str -> str[0], str -> str.length > 1 ? str[1] : EMPTY_STRING));
+ return lines.stream().map(str -> str.split(COLON)).collect(Collectors.toMap(str -> str[0], str -> str.length > 1 ? str[1] : EMPTY_STRING));
}
private String appendDefinitionDirPath(final String filename) {
@@ -171,9 +153,7 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
private List<Object> getImportFilesPath(final String mainYmlFile) {
final Map<Object, Object> fileContentMap = new YamlUtil().yamlToObject(mainYmlFile, Map.class);
-
final Object importsObject = fileContentMap.get("imports");
-
if (importsObject instanceof List) {
return (List<Object>) importsObject;
}
@@ -184,19 +164,15 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
final Yaml yaml = new Yaml();
final Map<String, Object> toscaFileContent = (Map<String, Object>) yaml.load(new String(vnfdFileContent));
toscaFileContent.remove("topology_template");
-
return yaml.dumpAsMap(toscaFileContent).getBytes();
}
private String getNodeType(final String mainYmlFile) {
final Map<Object, Object> fileContentMap = new YamlUtil().yamlToObject(mainYmlFile, Map.class);
-
final Object nodeTypesObject = fileContentMap.get("node_types");
- if (nodeTypesObject instanceof Map
- && ((Map<String, Object>) nodeTypesObject).size() == 1) {
+ if (nodeTypesObject instanceof Map && ((Map<String, Object>) nodeTypesObject).size() == 1) {
return ((Map<String, Object>) nodeTypesObject).keySet().iterator().next();
}
return null;
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java
index d447dc428d..180337d1d5 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.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 lombok.AllArgsConstructor;
@@ -29,10 +29,7 @@ import org.apache.commons.lang.StringUtils;
@Getter
@AllArgsConstructor
public enum EtsiVersion {
- VERSION_2_5_1("2.5.1"),
- VERSION_2_7_1("2.7.1"),
- VERSION_3_3_1("3.3.1");
-
+ VERSION_2_5_1("2.5.1"), VERSION_2_7_1("2.7.1"), VERSION_3_3_1("3.3.1");
private final String version;
public static EtsiVersion convertOrNull(final String etsiVersion) {
@@ -48,7 +45,6 @@ public enum EtsiVersion {
if (VERSION_3_3_1.getVersion().equals(etsiVersion)) {
return VERSION_3_3_1;
}
-
return null;
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java
index d17b48d158..d17b03f7c4 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.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 lombok.Getter;
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java
index 40e499c8c7..f24a0442ba 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.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 java.util.Comparator;
@@ -32,19 +32,16 @@ public class NsDescriptorVersionComparator implements Comparator<EtsiVersion> {
} else if (Integer.parseInt(v1[0]) < Integer.parseInt(v2[0])) {
return -1;
}
-
if (Integer.parseInt(v1[1]) > Integer.parseInt(v2[1])) {
return 1;
} else if (Integer.parseInt(v1[1]) < Integer.parseInt(v2[1])) {
return -1;
}
-
if (Integer.parseInt(v1[2]) > Integer.parseInt(v2[2])) {
return 1;
} else if (Integer.parseInt(v1[2]) < Integer.parseInt(v2[2])) {
return -1;
}
-
return 0;
}
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java
index a8de728702..f1e0faa871 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.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.model;
import java.util.ArrayList;
@@ -31,7 +31,6 @@ public class Nsd {
public static final String VERSION_PROPERTY = "version";
public static final String NAME_PROPERTY = "name";
public static final String INVARIANT_ID_PROPERTY = "invariant_id";
-
private String designer;
private String version;
private String name;
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java
index 53615effb6..88a2364386 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.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.model;
import java.util.HashMap;
@@ -63,5 +63,4 @@ public class VnfDescriptor {
public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java
index 822d6dc82b..cb8928f372 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.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 java.util.ArrayList;
@@ -49,64 +49,50 @@ public class NsdTemplateRepresenter extends Representer {
}
@Override
- protected NodeTuple representJavaBeanProperty(final Object javaBean, final Property property,
- final Object propertyValue, final Tag customTag) {
+ protected NodeTuple representJavaBeanProperty(final Object javaBean, final Property property, final Object propertyValue, final Tag customTag) {
if (propertyValue == null) {
return null;
}
-
if (ignoredPropertySet.contains(property.getName())) {
return null;
}
-
if (javaBean instanceof ToscaTemplate) {
return handleToscaTemplate(javaBean, property, propertyValue, customTag);
}
-
if (javaBean instanceof ToscaPropertyConstraintValidValues) {
return handleToscaPropertyConstraintValidValues(javaBean, property, propertyValue, customTag);
}
-
if (javaBean instanceof ToscaProperty) {
return handleToscaProperty(javaBean, property, propertyValue, customTag);
}
-
return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
}
- private NodeTuple handleToscaProperty(final Object javaBean, final Property property,
- final Object propertyValue, final Tag customTag) {
+ private NodeTuple handleToscaProperty(final Object javaBean, final Property property, final Object propertyValue, final Tag customTag) {
final NodeTuple nodeTuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
if ("_defaultp_".equals(property.getName())) {
return new NodeTuple(representData("default"), nodeTuple.getValueNode());
}
-
return nodeTuple;
}
- private NodeTuple handleToscaPropertyConstraintValidValues(final Object javaBean, final Property property,
- final Object propertyValue, final Tag customTag) {
+ private NodeTuple handleToscaPropertyConstraintValidValues(final Object javaBean, final Property property, final Object propertyValue,
+ final Tag customTag) {
final NodeTuple nodeTuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
if ("validValues".equals(property.getName())) {
final String validValuesEntryName = ToscaPropertyConstraintValidValues.getEntryToscaName("validValues");
return new NodeTuple(representData(validValuesEntryName), nodeTuple.getValueNode());
}
-
return nodeTuple;
}
- private NodeTuple handleToscaTemplate(final Object javaBean, final Property property,
- final Object propertyValueObj, final Tag customTag) {
+ private NodeTuple handleToscaTemplate(final Object javaBean, final Property property, final Object propertyValueObj, final Tag customTag) {
if ("imports".equals(property.getName())) {
- final List<Map<String, Map<String, String>>> importsList =
- (List<Map<String, Map<String, String>>>) propertyValueObj;
-
+ final List<Map<String, Map<String, String>>> importsList = (List<Map<String, Map<String, String>>>) propertyValueObj;
final List<Map<String, String>> newImportList = new ArrayList<>();
importsList.forEach(importMap -> importMap.forEach((key, value) -> newImportList.add(value)));
-
return super.representJavaBeanProperty(javaBean, property, newImportList, customTag);
}
-
return super.representJavaBeanProperty(javaBean, property, propertyValueObj, customTag);
}
@@ -115,7 +101,6 @@ public class NsdTemplateRepresenter extends Representer {
if (!classTags.containsKey(javaBean.getClass())) {
addClassTag(javaBean.getClass(), Tag.MAP);
}
-
return super.representJavaBean(properties, javaBean);
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java
index 4c2cd87184..b73b52954b 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.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 org.openecomp.sdc.be.tosca.model.ToscaTemplate;
@@ -69,5 +69,4 @@ public class ToscaTemplateYamlGenerator {
representer.addClassTag(toscaTemplate.getClass(), Tag.MAP);
representer.setPropertyUtils(new UnsortedPropertyUtils());
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java
index b93db62088..6c70e93f07 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.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 java.beans.IntrospectionException;
@@ -30,10 +30,8 @@ import org.yaml.snakeyaml.introspector.PropertyUtils;
public class UnsortedPropertyUtils extends PropertyUtils {
@Override
- protected Set<Property> createPropertySet(final Class clazz, final BeanAccess beanAccess)
- throws IntrospectionException {
-
+ protected Set<Property> createPropertySet(final Class clazz, final BeanAccess beanAccess) throws IntrospectionException {
final Collection<Property> fields = getPropertiesMap(clazz, BeanAccess.FIELD).values();
return new LinkedHashSet<>(fields);
}
-} \ 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/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
+}