summaryrefslogtreecommitdiffstats
path: root/catalog-be-plugins/etsi-nfv-nsd-csar-plugin
diff options
context:
space:
mode:
authorstasys10 <stasys.jurgaitis@est.tech>2022-02-03 16:16:07 +0000
committerMichael Morris <michael.morris@est.tech>2022-02-09 17:37:38 +0000
commit8549cdded4f452a52aea32be1c97c820fa79b5af (patch)
treee790f44d574eacc69f28eaf57678390decf803ca /catalog-be-plugins/etsi-nfv-nsd-csar-plugin
parent2dca3ece8e8438cb15bbaa962d3adc8d729ed785 (diff)
Add new category to NSD plugin
Issue-ID: SDC-3870 Signed-off-by: stasys10 <stasys.jurgaitis@est.tech> Change-Id: Ibb46b401f635192a680eb472eb8d7f3fb3380f57
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/generator/EtsiNfvNsCsarEntryGenerator.java13
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java45
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGeneratorTest.java4
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/test/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImplTest.java4
4 files changed, 56 insertions, 10 deletions
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 9a7312b0fb..4640492441 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
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.CategoriesToGenerateNsd;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.plugins.CsarEntryGenerator;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.exception.NsdException;
@@ -39,7 +40,6 @@ import org.slf4j.LoggerFactory;
@org.springframework.stereotype.Component("etsiNfvNsCsarEntryGenerator")
public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
- static final String ETSI_NS_COMPONENT_CATEGORY = "ETSI NFV Network Service";
static final String NSD_FILE_PATH_FORMAT = "Artifacts/%s/%s.%s";
static final String SIGNED_CSAR_EXTENSION = "zip";
static final String UNSIGNED_CSAR_EXTENSION = "csar";
@@ -52,8 +52,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 that has category configured in
+ * {@link CategoriesToGenerateNsd } enum 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
@@ -65,10 +65,11 @@ 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 ->
+ CategoriesToGenerateNsd.hasCategoryName(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 any of the categories '{}'",
+ componentName, CategoriesToGenerateNsd.getCategories());
return Collections.emptyMap();
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java
new file mode 100644
index 0000000000..864d63d4bd
--- /dev/null
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+@Getter
+@AllArgsConstructor
+public enum CategoriesToGenerateNsd {
+ ETSI_NS_COMPONENT_CATEGORY ("ETSI NFV Network Service"),
+ ETSI_NS_COMPONENT_CATEGORY_FOR_ETSI_MODEL("ETSI NFV Network Service For ETSI Model");
+
+ private final String categoryName;
+
+ public static boolean hasCategoryName(String categoryNameToCheck) {
+ return Arrays.stream(CategoriesToGenerateNsd.values()).anyMatch(CategoriesToGenerateNsd ->
+ CategoriesToGenerateNsd.getCategoryName().equals(categoryNameToCheck));
+ }
+
+ public static String getCategories(){
+ return Arrays.stream(CategoriesToGenerateNsd.values()).map(CategoriesToGenerateNsd::getCategoryName)
+ .collect(Collectors.joining(", "));
+ }
+}
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 6cf6e06443..d52bf5c7f0 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
@@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsCsarEntryGenerator.ETSI_NS_COMPONENT_CATEGORY;
+import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.CategoriesToGenerateNsd;
import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsCsarEntryGenerator.ETSI_VERSION_METADATA;
import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsCsarEntryGenerator.NSD_FILE_PATH_FORMAT;
import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsCsarEntryGenerator.UNSIGNED_CSAR_EXTENSION;
@@ -124,7 +124,7 @@ class EtsiNfvNsCsarEntryGeneratorTest {
when(service.getCategorySpecificMetadata()).thenReturn(categorySpecificMetadataMap);
final List<CategoryDefinition> categoryDefinitionList = new ArrayList<>();
final CategoryDefinition nsComponentCategoryDefinition = new CategoryDefinition();
- nsComponentCategoryDefinition.setName(ETSI_NS_COMPONENT_CATEGORY);
+ nsComponentCategoryDefinition.setName(CategoriesToGenerateNsd.ETSI_NS_COMPONENT_CATEGORY.getCategoryName());
categoryDefinitionList.add(nsComponentCategoryDefinition);
when(service.getCategories()).thenReturn(categoryDefinitionList);
}
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 31798efe2e..163b6bbfee 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
@@ -26,7 +26,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsCsarEntryGenerator.ETSI_NS_COMPONENT_CATEGORY;
+import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.CategoriesToGenerateNsd;
import static org.openecomp.sdc.common.api.ArtifactTypeEnum.ONBOARDED_PACKAGE;
import fj.data.Either;
@@ -136,7 +136,7 @@ class EtsiNfvNsdCsarGeneratorImplTest {
final List<CategoryDefinition> categoryDefinitionList = new ArrayList<>();
final CategoryDefinition nsComponentCategoryDefinition = new CategoryDefinition();
- nsComponentCategoryDefinition.setName(ETSI_NS_COMPONENT_CATEGORY);
+ nsComponentCategoryDefinition.setName(CategoriesToGenerateNsd.ETSI_NS_COMPONENT_CATEGORY.getCategoryName());
categoryDefinitionList.add(nsComponentCategoryDefinition);
when(service.getCategories()).thenReturn(categoryDefinitionList);
}