aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPolicyTemplate.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidationTest.java88
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java213
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java57
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java21
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/test/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapperTest.java22
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilderTest.java42
7 files changed, 383 insertions, 106 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPolicyTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPolicyTemplate.java
index 18f2b7f488..6d427e2b92 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPolicyTemplate.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPolicyTemplate.java
@@ -19,52 +19,20 @@
*/
package org.openecomp.sdc.be.tosca.model;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
import java.util.List;
import java.util.Map;
+@Getter
+@Setter
+@AllArgsConstructor
public class ToscaPolicyTemplate {
private String type;
private IToscaMetadata metadata;
private Map<String, Object> properties;
private List<String> targets;
-
- public ToscaPolicyTemplate(String type, IToscaMetadata metadata, Map<String, Object> properties, List<String> targets) {
- this.type = type;
- this.metadata = metadata;
- this.properties = properties;
- this.targets = targets;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public IToscaMetadata getMetadata() {
- return metadata;
- }
-
- public void setMetadata(IToscaMetadata metadata) {
- this.metadata = metadata;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public List<String> getTargets() {
- return targets;
- }
-
- public void setTargets(List<String> targets) {
- this.targets = targets;
- }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidationTest.java
index 82dde5e396..bcf815f09f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidationTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidationTest.java
@@ -22,12 +22,14 @@ package org.openecomp.sdc.be.components.validation;
import fj.data.Either;
import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.impl.utils.NodeFilterConstraintAction;
+import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
@@ -37,13 +39,15 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class NodeFilterValidationTest {
@@ -63,10 +67,34 @@ public class NodeFilterValidationTest {
@InjectMocks
private NodeFilterValidator nodeFilterValidator;
- @Before
+ @BeforeEach
public void setup() {
componentsUtils = Mockito.mock(ComponentsUtils.class);
MockitoAnnotations.initMocks(this);
+ new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be"));
+ }
+
+ @Test
+ public void testValidateComponentInstanceExist() {
+ Either<Boolean, ResponseFormat> either =
+ nodeFilterValidator.validateComponentInstanceExist(null, INNER_SERVICE);
+ assertTrue(either.isRight());
+ assertEquals("Error: Internal Server Error. Please try again later.", either.right().value().getText());
+ assertEquals(500, either.right().value().getStatus());
+
+ Service service = createService("booleanIncorrect");
+ either = nodeFilterValidator.validateComponentInstanceExist(service, INNER_SERVICE);
+ assertTrue(either.isRight());
+ assertEquals("Error: Internal Server Error. Please try again later.", either.right().value().getText());
+ assertEquals(500, either.right().value().getStatus());
+
+ List<ComponentInstance> list = new LinkedList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setUniqueId("uniqueId");
+ list.add(instance);
+ service.setComponentInstances(list);
+ either = nodeFilterValidator.validateComponentInstanceExist(service, "uniqueId");
+ assertTrue(either.isLeft());
}
@Test
@@ -76,8 +104,50 @@ public class NodeFilterValidationTest {
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "true")),
NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ assertTrue(either.isRight());
- Assert.assertFalse(either.isLeft());
+ either =
+ nodeFilterValidator.validateFilter(service, INNER_SERVICE,
+ Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "true")),
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.CAPABILITIES);
+ assertTrue(either.isRight());
+ }
+
+ @Test
+ public void testValidateComponentFilter() {
+ Service service = createService("booleanIncorrect");
+ String property = "Prop1: {equal: {get_property: ['test','test2']}}";
+ Either<Boolean, ResponseFormat> either =
+ nodeFilterValidator.validateComponentFilter(service, Collections.singletonList(property),
+ NodeFilterConstraintAction.ADD);
+ assertTrue(either.isRight());
+
+ property = "Prop1: {equal: {get_property: ['parentservice','Prop1']}}";
+ either =
+ nodeFilterValidator.validateComponentFilter(service, Collections.singletonList(property),
+ NodeFilterConstraintAction.ADD);
+ assertTrue(either.isLeft());
+
+ String staticStr = "Prop1: {equal: 1}";
+ either = nodeFilterValidator.validateComponentFilter(service, Collections.singletonList(staticStr),
+ NodeFilterConstraintAction.ADD);
+ assertTrue(either.isLeft());
+ assertTrue(either.left().value());
+
+ staticStr = "Prop1: {equal: 'true'}";
+ either = nodeFilterValidator.validateComponentFilter(service, Collections.singletonList(staticStr),
+ NodeFilterConstraintAction.ADD);
+ assertTrue(either.isRight());
+
+ staticStr = "Prop1: {greater_than: '3'}";
+ either = nodeFilterValidator.validateComponentFilter(service, Collections.singletonList(staticStr),
+ NodeFilterConstraintAction.ADD);
+ assertTrue(either.isRight());
+
+ staticStr = "test: {greater_than: '3'}";
+ either = nodeFilterValidator.validateComponentFilter(service, Collections.singletonList(staticStr),
+ NodeFilterConstraintAction.ADD);
+ assertTrue(either.isRight());
}
@Test
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java
index 81635e20e0..5aa742a540 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java
@@ -29,41 +29,58 @@
*/
package org.openecomp.sdc.be.model.jsonjanusgraph.utils;
-import java.util.ArrayList;
-import java.util.Arrays;
+
import java.util.HashMap;
-import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
-import org.mockito.junit.MockitoJUnitRunner;
+
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceOutput;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.RelationshipInfo;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.RelationshipTypeDefinition;
+import org.openecomp.sdc.be.model.RelationshipImpl;
+
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.Component;
+
+
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.NodeType;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-@RunWith(MockitoJUnitRunner.class)
+
+@ExtendWith(MockitoExtension.class)
public class ModelConverterTest {
@InjectMocks
private ModelConverter test;
@@ -74,7 +91,7 @@ public class ModelConverterTest {
Service service = new Service();
service.setComponentType(ComponentTypeEnum.SERVICE);
TopologyTemplate template = test.convertToToscaElement(service);
- assertThat(template.getToscaType()).isEqualTo(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE);
+ assertEquals(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE, template.getToscaType());
}
@Test
@@ -83,7 +100,7 @@ public class ModelConverterTest {
Resource resource = new Resource();
resource.setComponentType(ComponentTypeEnum.RESOURCE);
NodeType nodeType = test.convertToToscaElement(resource);
- assertThat(nodeType.getToscaType()).isEqualTo(ToscaElementTypeEnum.NODE_TYPE);
+ assertEquals(ToscaElementTypeEnum.NODE_TYPE, nodeType.getToscaType());
}
@Test
@@ -92,7 +109,20 @@ public class ModelConverterTest {
TopologyTemplate topologyTemplate = new TopologyTemplate();
topologyTemplate.setComponentType(ComponentTypeEnum.SERVICE);
Component component = test.convertFromToscaElement(topologyTemplate);
- assertThat(component.getToscaType()).isEqualTo(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue());
+ assertEquals(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue(), component.getToscaType());
+
+ topologyTemplate.setComponentType(ComponentTypeEnum.PRODUCT);
+ component = test.convertFromToscaElement(topologyTemplate);
+ assertEquals(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue(), component.getToscaType());
+
+ NodeType nodeType = new NodeType();
+ nodeType.setComponentType(ComponentTypeEnum.RESOURCE);
+ topologyTemplate.setToscaType(ToscaElementTypeEnum.NODE_TYPE);
+ component = test.convertFromToscaElement(nodeType);
+ assertEquals(ToscaElementTypeEnum.NODE_TYPE.getValue(), component.getToscaType());
+
+ topologyTemplate.setComponentType(ComponentTypeEnum.RESOURCE_INSTANCE);
+ assertNull(test.convertFromToscaElement(topologyTemplate));
}
@Test
@@ -107,7 +137,7 @@ public class ModelConverterTest {
topologyTemplate.setComponentType(ComponentTypeEnum.SERVICE);
Component component = test.convertFromToscaElement(topologyTemplate);
- assertThat(component.getToscaType()).isEqualTo(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue());
+ assertEquals(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue(), component.getToscaType());
}
@Test
@@ -116,7 +146,7 @@ public class ModelConverterTest {
TopologyTemplate topologyTemplate = new TopologyTemplate();
topologyTemplate.setComponentType(ComponentTypeEnum.RESOURCE);
Component component = test.convertFromToscaElement(topologyTemplate);
- assertThat(component.getToscaType()).isEqualTo(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue());
+ assertEquals(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue(), component.getToscaType());
}
@Test
@@ -125,7 +155,7 @@ public class ModelConverterTest {
topologyTemplate.setComponentType(ComponentTypeEnum.RESOURCE);
topologyTemplate.setResourceType(ResourceTypeEnum.PNF);
Resource resource = test.convertFromToscaElement(topologyTemplate);
- assertSame(ResourceTypeEnum.PNF, resource.getResourceType());
+ assertEquals(ResourceTypeEnum.PNF, resource.getResourceType());
}
@Test
@@ -168,9 +198,14 @@ public class ModelConverterTest {
@Test
public void testIsAtomicComponent() {
Resource component = new Resource();
+ component.setComponentType(ComponentTypeEnum.SERVICE);
+ assertFalse(test.isAtomicComponent(component));
+
component.setComponentType(ComponentTypeEnum.RESOURCE);
- boolean result = test.isAtomicComponent(component);
- assertTrue(result);
+ assertTrue(test.isAtomicComponent(component));
+
+ ResourceTypeEnum resourceType = null;
+ assertFalse(test.isAtomicComponent(resourceType));
}
@Test
@@ -178,8 +213,140 @@ public class ModelConverterTest {
{
VertexTypeEnum result;
Resource component = new Resource();
+ component.setComponentType(ComponentTypeEnum.SERVICE);
+ assertEquals("topology_template", test.getVertexType(component).getName());
component.setComponentType(ComponentTypeEnum.RESOURCE);
- result = test.getVertexType(component);
- assertThat(result.getName()).isEqualTo("node_type");
+ assertEquals("node_type", test.getVertexType(component).getName());
+
+ assertEquals(VertexTypeEnum.TOPOLOGY_TEMPLATE, test.getVertexType("Service"));
+ assertEquals(VertexTypeEnum.NODE_TYPE, test.getVertexType("VFC"));
+ }
+
+ @Test
+ public void testConvertRelation()
+ {
+ RelationshipTypeDefinition relationshipDef = new RelationshipTypeDefinition();
+ relationshipDef.setFromId("formId");
+ relationshipDef.setToId("toId");
+ relationshipDef.setOriginUI(true);
+ RequirementCapabilityRelDef result = ModelConverter.convertRelation(relationshipDef);
+
+ assertEquals("formId", result.getFromNode());
+ assertEquals("toId", result.getToNode());
+ assertEquals(true, result.isOriginUI());
+ assertEquals(1, result.getRelationships().size());
+ }
+
+ @Test
+ public void testConvertRelationToToscaRelation()
+ {
+ RequirementCapabilityRelDef reqCap = new RequirementCapabilityRelDef();
+ reqCap.setOriginUI(true);
+ reqCap.setFromNode("fromNode");
+ reqCap.setToNode("toNode");
+ List<CapabilityRequirementRelationship> list = new LinkedList<>();
+ CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
+ RelationshipInfo info = new RelationshipInfo();
+ info.setCapabilityOwnerId("capOwnerId");
+ info.setId("id");
+ info.setCapabilityUid("capUid");
+ info.setRequirementOwnerId("reqOwnerId");
+ info.setRequirementUid("reqUid");
+ info.setRequirement("req");
+ info.setCapability("cap");
+ RelationshipImpl relationshipImpl = new RelationshipImpl();
+ relationshipImpl.setType("type");
+ info.setRelationships(relationshipImpl);
+ relationship.setRelation(info);
+ list.add(relationship);
+ reqCap.setRelationships(list);
+
+ List<RelationshipInstDataDefinition> result = ModelConverter.convertRelationToToscaRelation(reqCap);
+ assertEquals(1, result.size());
+ assertEquals("capOwnerId", result.get(0).getCapabilityOwnerId());
+ assertEquals("id", result.get(0).getUniqueId());
+ assertEquals("capUid", result.get(0).getCapabilityId());
+ assertEquals("reqOwnerId", result.get(0).getRequirementOwnerId());
+ assertEquals("reqUid", result.get(0).getRequirementId());
+ assertEquals("req", result.get(0).getRequirement());
+ assertEquals("cap", result.get(0).getCapability());
+ assertEquals("type", result.get(0).getType());
+ assertEquals(true, result.get(0).isOriginUI());
+ assertEquals("fromNode", result.get(0).getFromId());
+ assertEquals("toNode", result.get(0).getToId());
+ }
+
+ @Test
+ public void testConvertToMapOfMapCapabilityPropertiesonvertRelation()
+ {
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ MapCapabilityProperty result = ModelConverter.convertToMapOfMapCapabilityProperties(capabilities, "ownerId", true);
+ assertNotNull(result);
+ assertEquals(0, result.getMapToscaDataDefinition().size());
+
+ List<CapabilityDefinition> list = new LinkedList<>();
+ CapabilityDefinition capDef = new CapabilityDefinition();
+ List<ComponentInstanceProperty> properties = new LinkedList<>();
+ ComponentInstanceProperty property = new ComponentInstanceProperty();
+ properties.add(property);
+ capDef.setProperties(properties);
+ list.add(capDef);
+ capabilities.put("test", list);
+ result = ModelConverter.convertToMapOfMapCapabilityProperties(capabilities, "ownerId", true);
+ assertEquals(1, result.getMapToscaDataDefinition().size());
+ }
+
+ @Test
+ public void testBuildCapabilityPropertyKey()
+ {
+ CapabilityDefinition capDef = new CapabilityDefinition();
+ capDef.setOwnerId("owner");
+ String result = ModelConverter.buildCapabilityPropertyKey(true,"type","name", "capId", capDef);
+
+ assertEquals("capId#owner#type#name", result);
+ }
+
+ @Test
+ public void testConvertToMapOfMapCapabiltyProperties()
+ {
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ List<CapabilityDefinition> list = new LinkedList<>();
+ CapabilityDefinition capDef = new CapabilityDefinition();
+ List<ComponentInstanceProperty> properties = new LinkedList<>();
+ ComponentInstanceProperty property = new ComponentInstanceProperty();
+ properties.add(property);
+ capDef.setProperties(properties);
+ list.add(capDef);
+ capabilities.put("test", list);
+
+ MapCapabilityProperty result = ModelConverter.convertToMapOfMapCapabiltyProperties(capabilities, "ownerId", true);
+
+ assertEquals(1, result.getMapToscaDataDefinition().size());
+ assertNotNull(result.getMapToscaDataDefinition().get("ownerId#ownerId#test#null"));
+ }
+
+ @Test
+ public void testGetCapabilitiesMapFromMapObject()
+ {
+ assertNull(ModelConverter.getCapabilitiesMapFromMapObject(null, null));
+
+ Map<String, ListCapabilityDataDefinition> toscaCapabilities = new HashMap<>();
+ Map<String, MapPropertiesDataDefinition> toscaCapPropMap = new HashMap<>();
+ ListCapabilityDataDefinition dataDefList = new ListCapabilityDataDefinition();
+ List<CapabilityDataDefinition> capDataDefList = new LinkedList<>();
+ CapabilityDataDefinition capDataDef = new CapabilityDataDefinition();
+ capDataDef.setName("test");
+ capDataDefList.add(capDataDef);
+ dataDefList.setListToscaDataDefinition(capDataDefList);
+ MapPropertiesDataDefinition dataDefMap = new MapPropertiesDataDefinition();
+ Map<String, PropertyDataDefinition> propDataMap = new HashMap<>();
+ PropertyDataDefinition propertyDataDefinition = new PropertyDataDefinition();
+ propDataMap.put("propMap", propertyDataDefinition);
+ dataDefMap.setMapToscaDataDefinition(propDataMap);
+ toscaCapabilities.put("prop", dataDefList);
+ toscaCapPropMap.put("prop#test", dataDefMap);
+
+ Map<String, List<CapabilityDefinition>> result = ModelConverter.getCapabilitiesMapFromMapObject(toscaCapabilities, toscaCapPropMap);
+ assertEquals(1, result.size());
}
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java
index 0eaf10b0db..5a0c95cae0 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java
@@ -20,29 +20,58 @@
package org.openecomp.sdc.be.model.tosca.converters;
-import org.junit.Test;
+import fj.data.Either;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class ListConverterTest {
- private ListConverter createTestSubject() {
- return new ListConverter();
- }
+ private ListConverter listConverter = ListConverter.getInstance();
+ private Map<String, DataTypeDefinition> dataTypesMap = new HashMap<>();
-
@Test
- public void testGetInstance() throws Exception {
- ListConverter result;
+ public void testConvertWithErrorResult() throws Exception {
+ Either<String, Boolean> result = listConverter.convertWithErrorResult(null, null, dataTypesMap);
+ assertNull(result.left().value());
- // default test
- result = ListConverter.getInstance();
- }
+ result = listConverter.convertWithErrorResult("[]", "error", dataTypesMap);
+ assertTrue(result.isRight());
+
+ result = listConverter.convertWithErrorResult("[\"test\":1]", "json", dataTypesMap);
+ assertTrue(result.isRight());
+
+ result = listConverter.convertWithErrorResult("[\"\"]", "string", dataTypesMap);
+ assertEquals("[]", result.left().value());
+ result = listConverter.convertWithErrorResult("[\"test\"]", "string", dataTypesMap);
+ assertEquals("[\"test\"]", result.left().value());
-
+ result = listConverter.convertWithErrorResult("[1, 0x01, 0o01]", "integer", dataTypesMap);
+ assertEquals("[1,1,1]", result.left().value());
-
-
+ result = listConverter.convertWithErrorResult("[0.1]", "float", dataTypesMap);
+ assertEquals("[0.1]", result.left().value());
-
+ result = listConverter.convertWithErrorResult("[true]", "boolean", dataTypesMap);
+ assertEquals("[true]", result.left().value());
+ result = listConverter.convertWithErrorResult("[{\"test\":1}]", "json", dataTypesMap);
+ assertEquals("[{\"test\":1}]", result.left().value());
+
+ result = listConverter.convertWithErrorResult("[1.1]", "version", dataTypesMap);
+ assertEquals("[1.1]", result.left().value());
+ }
+
+ @Test
+ public void testConvert() throws Exception {
+ assertEquals("[0.1]", listConverter.convertWithErrorResult("[0.1]", "float", dataTypesMap).left().value());
+ assertNull(listConverter.convert("[]", "error", dataTypesMap));
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java
index 7bff3d5b77..703533d8af 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java
@@ -19,10 +19,15 @@
*/
package org.openecomp.sdcrests.wrappers;
+import lombok.Getter;
+import lombok.Setter;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+@Getter
+@Setter
public class GenericCollectionWrapper<T> implements Serializable {
private static final long serialVersionUID = 1L;
@@ -47,22 +52,6 @@ public class GenericCollectionWrapper<T> implements Serializable {
}
}
- public List<T> getResults() {
- return results;
- }
-
- public void setResults(List<T> results) {
- this.results = results;
- }
-
- public int getListCount() {
- return listCount;
- }
-
- public void setListCount(int listCount) {
- this.listCount = listCount;
- }
-
/**
* Add boolean.
*
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/test/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapperTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/test/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapperTest.java
index 86d0257eeb..231c834294 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/test/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapperTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/test/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapperTest.java
@@ -19,16 +19,28 @@
*/
package org.openecomp.sdcrests.wrappers;
+import org.junit.jupiter.api.Test;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import java.util.LinkedList;
+import java.util.List;
public class GenericCollectionWrapperTest {
@Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(GenericCollectionWrapper.class, hasValidGettersAndSetters());
+ public void addTest() {
+ GenericCollectionWrapper wrapper = new GenericCollectionWrapper(new LinkedList());
+ assertTrue(wrapper.add("test"));
+ assertEquals(1, wrapper.getResults().size());
+ assertEquals(1, wrapper.getListCount());
+
+ List<Integer> list = new LinkedList<>();
+ list.add(1);
+ GenericCollectionWrapper wrapper2 = new GenericCollectionWrapper(list);
+ assertTrue(wrapper2.add("test"));
+ assertEquals(2, wrapper2.getResults().size());
+ assertEquals(2, wrapper2.getListCount());
}
} \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilderTest.java
new file mode 100644
index 0000000000..4c812fe900
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilderTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorlicense.errors;
+
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class LimitErrorBuilderTest {
+ @Test
+ public void testGetInvalidValueErrorBuilder() {
+ ErrorCode res = LimitErrorBuilder.getInvalidValueErrorBuilder("attrebute", "404");
+ assertEquals("The attrebute value doesn't meet the expected attribute value.", res.message());
+ assertEquals("404", res.id());
+ }
+
+ @Test
+ public void testGetDuplicateNameErrorbuilder() {
+ ErrorCode res = LimitErrorBuilder.getDuplicateNameErrorbuilder("name", "type");
+ assertEquals("Invalid request, Limit with name name already exists for type type.", res.message());
+ assertEquals("DUPLICATE_LIMIT_NAME_NOT_ALLOWED", res.id());
+ }
+}