summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-08-30 15:18:40 +0100
committerMichael Morris <michael.morris@est.tech>2021-10-05 16:03:26 +0000
commit6ecc7c3e150f86528d36cdbaa94912b965619a70 (patch)
tree089180b4df1919c555f07ffd4107fec823f48ca1 /catalog-be
parent32312ca12dc40f724d248104c16df5e46a4bc5cc (diff)
Filter categories by model name
Issue-ID: SDC-3706 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I457151f09ce0ed2edfa09340e9e08a126e114002
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java29
-rw-r--r--catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml41
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java25
4 files changed, 71 insertions, 48 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java
index 12eb8379b2..35502aa573 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java
@@ -55,7 +55,7 @@ public class CategoriesImportManager {
@javax.annotation.Resource
private ComponentsUtils componentsUtils;
- public Either<Map<String, List<CategoryDefinition>>, ResponseFormat> createCategories(String categoriesTypesYml) {
+ public Either<Map<String, List<CategoryDefinition>>, ResponseFormat> createCategories(final String categoriesTypesYml) {
Map<String, List<CategoryDefinition>> allCategories = createCategoriesFromYml(categoriesTypesYml);
return createCategoriesByDao(allCategories);
}
@@ -72,7 +72,7 @@ public class CategoriesImportManager {
nodeTypeCategory, nodeTypeSubCategory, nodeTypeGroup);
List<CategoryDefinition> newCategoriesvalue = new ArrayList<>();
for (CategoryDefinition category : entry.getValue()) {
- Either<CategoryDefinition, ResponseFormat> createdCategoryRes = createCategorieDeo(entry, category, nodeTypeCategory);
+ Either<CategoryDefinition, ResponseFormat> createdCategoryRes = createCategoriesDao(entry, category, nodeTypeCategory);
if (createdCategoryRes.isRight()) {
return Either.right(createdCategoryRes.right().value());
}
@@ -99,7 +99,7 @@ public class CategoriesImportManager {
NodeTypeEnum nodeTypeGroup, CategoryDefinition category, CategoryDefinition newcategory,
List<SubCategoryDefinition> newsubcategories, List<SubCategoryDefinition> subcategories) {
for (SubCategoryDefinition subcategory : subcategories) {
- Either<SubCategoryDefinition, ResponseFormat> createdSubCategory = createSubCategorieDeo(entry, newcategory, subcategory,
+ Either<SubCategoryDefinition, ResponseFormat> createdSubCategory = createSubCategoriesDao(entry, newcategory, subcategory,
nodeTypeSubCategory);
if (createdSubCategory.isRight()) {
return false;
@@ -109,7 +109,7 @@ public class CategoriesImportManager {
if (groupings != null) {
List<GroupingDefinition> newgroupings = new ArrayList<>();
for (GroupingDefinition grouping : groupings) {
- Either<GroupingDefinition, ResponseFormat> createdGrouping = createGroupingDeo(entry, grouping, subcategory, category,
+ Either<GroupingDefinition, ResponseFormat> createdGrouping = createGroupingDao(entry, grouping, subcategory, category,
nodeTypeGroup);
if (createdGrouping.isRight()) {
return false;
@@ -123,7 +123,7 @@ public class CategoriesImportManager {
return true;
}
- private Either<GroupingDefinition, ResponseFormat> createGroupingDeo(Map.Entry<String, List<CategoryDefinition>> entry,
+ private Either<GroupingDefinition, ResponseFormat> createGroupingDao(Map.Entry<String, List<CategoryDefinition>> entry,
GroupingDefinition grouping, SubCategoryDefinition subcategory,
CategoryDefinition category, NodeTypeEnum nodeTypeGroup) {
log.debug("createGroupingDeo: creating grouping {}", grouping);
@@ -148,9 +148,9 @@ public class CategoriesImportManager {
return Either.left(createdGrouping.left().value());
}
- private Either<SubCategoryDefinition, ResponseFormat> createSubCategorieDeo(Map.Entry<String, List<CategoryDefinition>> entry,
- CategoryDefinition newcategory, SubCategoryDefinition subcategory,
- NodeTypeEnum nodeTypeSubCategory) {
+ private Either<SubCategoryDefinition, ResponseFormat> createSubCategoriesDao(Map.Entry<String, List<CategoryDefinition>> entry,
+ CategoryDefinition newcategory, SubCategoryDefinition subcategory,
+ NodeTypeEnum nodeTypeSubCategory) {
log.debug("createSubCategorieDeo: creating subcategory {}", subcategory);
Either<SubCategoryDefinition, ActionStatus> createdSubCategory = elementOperation
.createSubCategory(newcategory.getUniqueId(), subcategory, nodeTypeSubCategory);
@@ -170,8 +170,8 @@ public class CategoriesImportManager {
return Either.left(createdSubCategory.left().value());
}
- private Either<CategoryDefinition, ResponseFormat> createCategorieDeo(Map.Entry<String, List<CategoryDefinition>> entry,
- CategoryDefinition category, NodeTypeEnum nodeTypeCategory) {
+ private Either<CategoryDefinition, ResponseFormat> createCategoriesDao(Map.Entry<String, List<CategoryDefinition>> entry,
+ CategoryDefinition category, NodeTypeEnum nodeTypeCategory) {
log.debug("createCategorieDeo: creating category {}", category);
Either<CategoryDefinition, ActionStatus> createdCategory = elementOperation.createCategory(category, nodeTypeCategory);
if (createdCategory.isRight() && ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS == createdCategory.right().value()) {
@@ -187,8 +187,8 @@ public class CategoriesImportManager {
return Either.left(createdCategory.left().value());
}
- private Map<String, List<CategoryDefinition>> createCategoriesFromYml(String categoriesTypesYml) {
- Map<String, Object> toscaJson = (Map<String, Object>) new Yaml().load(categoriesTypesYml);
+ private Map<String, List<CategoryDefinition>> createCategoriesFromYml(final String categoriesTypesYml) {
+ Map<String, Object> toscaJson = new Yaml().load(categoriesTypesYml);
Map<String, List<CategoryDefinition>> allCategories = new HashMap<>();
Iterator<Entry<String, Object>> categoryEntryItr = toscaJson.entrySet().iterator();
while (categoryEntryItr.hasNext()) {
@@ -219,7 +219,7 @@ public class CategoriesImportManager {
return allCategories;
}
- private List<CategoryDefinition> createServiceCategories(Map<String, Object> categories) {
+ private List<CategoryDefinition> createServiceCategories(final Map<String, Object> categories) {
List<CategoryDefinition> categoriesDef = new ArrayList<>();
String catName = null;
List<String> icons = null;
@@ -232,6 +232,7 @@ public class CategoriesImportManager {
catDef.setIcons(icons);
String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(catName);
catDef.setNormalizedName(normalizedName);
+ catDef.setModels((List<String>) category.get("models"));
final Object useServiceSubstitutionForNestedServicesProperty = category.get("useServiceSubstitutionForNestedServices");
final boolean useServiceSubstitutionForNestedServices =
useServiceSubstitutionForNestedServicesProperty == null ? false : (Boolean) useServiceSubstitutionForNestedServicesProperty;
@@ -262,7 +263,7 @@ public class CategoriesImportManager {
return metadataKeyDefs;
}
- private List<CategoryDefinition> createResourceCategories(Map<String, Object> categoryPerType) {
+ private List<CategoryDefinition> createResourceCategories(final Map<String, Object> categoryPerType) {
List<CategoryDefinition> categroiesDef = new ArrayList<>();
for (Map.Entry<String, Object> entry : categoryPerType.entrySet()) {
Map<String, Object> category = (Map<String, Object>) entry.getValue();
diff --git a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
index 29b8585b3d..a013264bd8 100644
--- a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
+++ b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
@@ -2,24 +2,45 @@ services:
Mobility:
name: "Mobility"
icons: ['mobility']
+ models: [
+ "SDC AID"
+ ]
Network_L1_3:
name: "Network L1-3"
icons: ['network_l_1-3']
+ models: [
+ "SDC AID"
+ ]
Network_L4:
name: "Network L4+"
icons: ['network_l_4']
+ models: [
+ "SDC AID"
+ ]
VoIP_Call_Control:
name: "VoIP Call Control"
icons: ['call_controll']
+ models: [
+ "SDC AID"
+ ]
E2E_Service:
name: "E2E Service"
icons: ['network_l_1-3']
+ models: [
+ "SDC AID"
+ ]
Network_Service:
name: "Network Service"
icons: ['network_l_1-3']
+ models: [
+ "SDC AID"
+ ]
Partner_Domain_Service:
name: "Partner Domain Service"
icons: ['partner_domain_service']
+ models: [
+ "SDC AID"
+ ]
ETSI_NFV_Network_Service:
name: "ETSI NFV Network Service"
icons: ['etsi_nfv_network_service']
@@ -29,10 +50,14 @@ services:
validValues: [ '3.3.1', '2.7.1', '2.5.1' ]
default: '2.5.1'
mandatory: true
+ models: [
+ "ETSI SOL001 v2.5.1",
+ "SDC AID"
+ ]
resources:
NetworkLayer23:
name: "Network L2-3"
- subcategories:
+ subcategories:
Router:
name: "Router"
icons: ['router','vRouter']
@@ -50,13 +75,13 @@ resources:
icons: ['ucpe']
NetworkLayer4:
name: "Network L4+"
- subcategories:
+ subcategories:
Common_Network_Resources:
name: "Common Network Resources"
icons: ['network']
ApplicationLayer4:
name: "Application L4+"
- subcategories:
+ subcategories:
Border_Element:
name: "Border Element"
icons: ['borderElement']
@@ -83,7 +108,7 @@ resources:
icons: ['firewall']
Generic:
name: "Generic"
- subcategories:
+ subcategories:
Infrastructure:
name: "Infrastructure"
icons: ['connector']
@@ -161,16 +186,16 @@ resources:
icons: ['allotted_resource']
TunnelXConnect:
name: "TunnelXConn"
- icons: ['tunnel_x_connect']
+ icons: ['tunnel_x_connect']
BRG:
name: "BRG"
- icons: ['brg']
+ icons: ['brg']
IpMuxDemux:
name: "IP Mux Demux"
- icons: ['ip_mux_demux']
+ icons: ['ip_mux_demux']
ServiceAdmin:
name: "Service Admin"
- icons: ['service_admin']
+ icons: ['service_admin']
ContrailRoute:
name: "Contrail Route"
icons: ['contrail_route']
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java
index 1d96272716..a42f2ef650 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java
@@ -20,7 +20,18 @@
package org.openecomp.sdc.be.components.impl;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -37,19 +48,6 @@ import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Stream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
public class CategoriesImportManagerTest {
@InjectMocks
static CategoriesImportManager importManager = new CategoriesImportManager();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java
index 62db6e283b..0fa7ca8cb6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java
@@ -20,8 +20,19 @@
package org.openecomp.sdc.be.components.path;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.Lists;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.junit.Before;
import org.openecomp.sdc.be.components.BeConfDependentTest;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -31,9 +42,9 @@ import org.openecomp.sdc.be.components.path.utils.GraphTestUtils;
import org.openecomp.sdc.be.components.validation.service.ServiceValidator;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition;
@@ -57,18 +68,6 @@ import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public abstract class BaseForwardingPathTest extends BeConfDependentTest implements ForwardingPathTestUtils {