From 9597e97eddcc9b5ea3376fb8d49b02fe42f5d820 Mon Sep 17 00:00:00 2001 From: Yuli Shlosberg Date: Thu, 10 May 2018 11:13:25 +0300 Subject: new unit tests for sdc-model Change-Id: Ie4cdc54ae829832b4092b249b467f5b9b4b756b6 Issue-ID: SDC-1302 Signed-off-by: Yuli Shlosberg --- .../sdc/be/model/LifeCycleTransitionEnumTest.java | 42 ++ .../org/openecomp/sdc/be/model/ModelTestBase.java | 1 + .../operations/NodeTemplateOperationTest.java | 235 +++++-- .../sdc/be/model/jsontitan/utils/IdMapperTest.java | 39 ++ .../model/jsontitan/utils/InterfaceUtilsTest.java | 72 ++ .../impl/ComponentInstanceOperationTest.java | 89 +++ .../operations/impl/ElementOperationTest.java | 399 ++++++++++- .../operations/impl/PropertyOperationTest.java | 742 ++++++++++++++++++++- .../tosca/constraints/ConstraintUtilTest.java | 41 ++ .../tosca/converters/LowerCaseConverterTest.java | 45 ++ .../converters/ToscaMapValueConverterTest.java | 27 + .../validators/ToscaBooleanValidatorTest.java | 58 ++ .../sdc/be/unittests/utils/FactoryUtilsTest.java | 179 +++++ .../src/test/resources/config/configuration.yaml | 677 +++++++++++++++++++ 14 files changed, 2584 insertions(+), 62 deletions(-) create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/IdMapperTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtilsTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/LowerCaseConverterTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverterTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/validators/ToscaBooleanValidatorTest.java create mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/unittests/utils/FactoryUtilsTest.java create mode 100644 catalog-model/src/test/resources/config/configuration.yaml (limited to 'catalog-model/src/test') diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java new file mode 100644 index 0000000000..43fac12509 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java @@ -0,0 +1,42 @@ +package org.openecomp.sdc.be.model; + +import javax.annotation.Generated; + +import org.junit.Test; + +public class LifeCycleTransitionEnumTest { + + private LifeCycleTransitionEnum createTestSubject() { + return LifeCycleTransitionEnum.CERTIFY; + } + + + @Test + public void testGetDisplayName() throws Exception { + LifeCycleTransitionEnum testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDisplayName(); + } + + + @Test + public void testGetFromDisplayName() throws Exception { + String name = LifeCycleTransitionEnum.CHECKIN.getDisplayName() ; + LifeCycleTransitionEnum result; + + // default test + result = LifeCycleTransitionEnum.getFromDisplayName(name); + } + + + @Test + public void testValuesAsString() throws Exception { + String result; + + // default test + result = LifeCycleTransitionEnum.valuesAsString(); + } +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java index c8917763a8..b6c081afd3 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java @@ -37,6 +37,7 @@ public class ModelTestBase { configurationManager = new ConfigurationManager(configurationSource); Configuration configuration = new Configuration(); + configuration.setTitanInMemoryGraph(true); configurationManager.setConfiguration(configuration); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java index 71d54bca73..971ebcca2b 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationTest.java @@ -5,8 +5,13 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.function.BiPredicate; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.tinkerpop.gremlin.structure.T; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; @@ -14,22 +19,47 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.TitanDao; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty; import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.ComponentInstanceProperty; +import org.openecomp.sdc.be.model.ComponentParametersView; +import org.openecomp.sdc.be.model.GroupDefinition; +import org.openecomp.sdc.be.model.GroupInstance; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.RelationshipImpl; import org.openecomp.sdc.be.model.RelationshipInfo; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate; +import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; + import com.google.common.collect.Lists; import fj.data.Either; -public class NodeTemplateOperationTest extends ModelTestBase{ +public class NodeTemplateOperationTest extends ModelTestBase { private final static String COMPONENT_ID = "componentId"; private final static String TO_INSTANCE_ID = "toInstanceId"; @@ -42,16 +72,16 @@ public class NodeTemplateOperationTest extends ModelTestBase{ private final static String REQUIREMENT_UID = "requirementUid"; private final static String REQUIREMENT_NAME = "requirementName"; private final static String RELATIONSHIP_TYPE = "relationshipType"; - + private static Map fulfilledCapability; private static Map fulfilledRequirement; private static CapabilityDataDefinition capability; private static RequirementDataDefinition requirement; private static RequirementCapabilityRelDef relation; - + private static TitanDao titanDao; private static NodeTemplateOperation operation; - + @BeforeClass public static void setup() { init(); @@ -60,7 +90,7 @@ public class NodeTemplateOperationTest extends ModelTestBase{ operation.setTitanDao(titanDao); buildDataDefinition(); } - + private static void buildDataDefinition() { buildCapabiltyDataDefinition(); buildRequirementDataDefinition(); @@ -68,68 +98,76 @@ public class NodeTemplateOperationTest extends ModelTestBase{ } @Test - public void testGetFulfilledCapabilityByRelationSuccess(){ + public void testGetFulfilledCapabilityByRelationSuccess() { GraphVertex vertex = Mockito.mock(GraphVertex.class); Either vertexRes = Either.left(vertex); when(titanDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes); - + GraphVertex dataVertex = new GraphVertex(); dataVertex.setJson(fulfilledCapability); Either childVertexRes = Either.left(dataVertex); - when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_CAPABILITIES), eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); - Either result = operation.getFulfilledCapabilityByRelation(COMPONENT_ID, TO_INSTANCE_ID, relation, (rel, cap)->isBelongingCapability(rel, cap)); + when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_CAPABILITIES), + eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); + Either result = operation.getFulfilledCapabilityByRelation( + COMPONENT_ID, TO_INSTANCE_ID, relation, (rel, cap) -> isBelongingCapability(rel, cap)); assertTrue(result.isLeft()); assertTrue(result.left().value().equals(capability)); } - + @Test - public void testGetFulfilledRequirementByRelationSuccess(){ + public void testGetFulfilledRequirementByRelationSuccess() { GraphVertex vertex = Mockito.mock(GraphVertex.class); Either vertexRes = Either.left(vertex); when(titanDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes); - + GraphVertex dataVertex = new GraphVertex(); dataVertex.setJson(fulfilledRequirement); Either childVertexRes = Either.left(dataVertex); - when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_REQUIREMENTS), eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); - Either result = operation.getFulfilledRequirementByRelation(COMPONENT_ID, FROM_INSTANCE_ID, relation, (rel, req)->isBelongingRequirement(rel, req)); + when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_REQUIREMENTS), + eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); + Either result = operation.getFulfilledRequirementByRelation( + COMPONENT_ID, FROM_INSTANCE_ID, relation, (rel, req) -> isBelongingRequirement(rel, req)); assertTrue(result.isLeft()); assertTrue(result.left().value().equals(requirement)); } - + @Test - public void testGetFulfilledCapabilityByRelationNotFoundFailure(){ + public void testGetFulfilledCapabilityByRelationNotFoundFailure() { GraphVertex vertex = Mockito.mock(GraphVertex.class); Either vertexRes = Either.left(vertex); when(titanDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes); - + Either childVertexRes = Either.right(TitanOperationStatus.NOT_FOUND); - when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_CAPABILITIES), eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); - Either result = operation.getFulfilledCapabilityByRelation(COMPONENT_ID, TO_INSTANCE_ID, relation, (rel, cap)->isBelongingCapability(rel, cap)); + when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_CAPABILITIES), + eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); + Either result = operation.getFulfilledCapabilityByRelation( + COMPONENT_ID, TO_INSTANCE_ID, relation, (rel, cap) -> isBelongingCapability(rel, cap)); assertTrue(result.isRight()); assertTrue(result.right().value() == StorageOperationStatus.NOT_FOUND); } - + @Test - public void testGetFulfilledRequirementByRelationNotFoundFailure(){ + public void testGetFulfilledRequirementByRelationNotFoundFailure() { GraphVertex vertex = Mockito.mock(GraphVertex.class); Either vertexRes = Either.left(vertex); when(titanDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes); - + Either childVertexRes = Either.right(TitanOperationStatus.NOT_FOUND); - when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_REQUIREMENTS), eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); - Either result = operation.getFulfilledRequirementByRelation(COMPONENT_ID, FROM_INSTANCE_ID, relation,(rel, req)->isBelongingRequirement(rel, req)); + when(titanDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_REQUIREMENTS), + eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes); + Either result = operation.getFulfilledRequirementByRelation( + COMPONENT_ID, FROM_INSTANCE_ID, relation, (rel, req) -> isBelongingRequirement(rel, req)); assertTrue(result.isRight()); assertTrue(result.right().value() == StorageOperationStatus.NOT_FOUND); } - + private static void buildRequirementDataDefinition() { buildRequirement(); fulfilledRequirement = new HashMap<>(); MapListRequirementDataDefinition mapListRequirementDataDefinition = new MapListRequirementDataDefinition(); mapListRequirementDataDefinition.add(requirement.getCapability(), requirement); fulfilledRequirement.put(FROM_INSTANCE_ID, mapListRequirementDataDefinition); - + } private static void buildRequirement() { @@ -154,40 +192,157 @@ public class NodeTemplateOperationTest extends ModelTestBase{ capability.setUniqueId(CAPABILITY_UID); capability.setName(CAPABILITY_NAME); } - + private static void buildRelation() { - + relation = new RequirementCapabilityRelDef(); CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship(); RelationshipInfo relationInfo = new RelationshipInfo(); relationInfo.setId(RELATION_ID); relationship.setRelation(relationInfo); - + relation.setRelationships(Lists.newArrayList(relationship)); relation.setToNode(TO_INSTANCE_ID); relation.setFromNode(FROM_INSTANCE_ID); - + relationInfo.setCapabilityOwnerId(CAPABILITY_OWNER_ID); relationInfo.setCapabilityUid(CAPABILITY_UID); relationInfo.setCapability(CAPABILITY_NAME); relationInfo.setRequirementOwnerId(REQUIREMENT_OWNER_ID); relationInfo.setRequirementUid(REQUIREMENT_UID); relationInfo.setRequirement(REQUIREMENT_NAME); - RelationshipImpl relationshipImpl = new RelationshipImpl(); + RelationshipImpl relationshipImpl = new RelationshipImpl(); relationshipImpl.setType(RELATIONSHIP_TYPE); relationInfo.setRelationships(relationshipImpl); } - + private boolean isBelongingRequirement(RelationshipInfo relationshipInfo, RequirementDataDefinition req) { - return req.getRelationship().equals(relationshipInfo.getRelationship().getType()) && - req.getName().equals(relationshipInfo.getRequirement()) && - req.getUniqueId().equals(relationshipInfo.getRequirementUid()) && - req.getOwnerId().equals(relationshipInfo.getRequirementOwnerId()); + return req.getRelationship().equals(relationshipInfo.getRelationship().getType()) + && req.getName().equals(relationshipInfo.getRequirement()) + && req.getUniqueId().equals(relationshipInfo.getRequirementUid()) + && req.getOwnerId().equals(relationshipInfo.getRequirementOwnerId()); } - + private boolean isBelongingCapability(RelationshipInfo relationshipInfo, CapabilityDataDefinition cap) { - return cap.getName().equals(relationshipInfo.getCapability()) && - cap.getUniqueId().equals(relationshipInfo.getCapabilityUid()) && - cap.getOwnerId().equals(relationshipInfo.getCapabilityOwnerId()); + return cap.getName().equals(relationshipInfo.getCapability()) + && cap.getUniqueId().equals(relationshipInfo.getCapabilityUid()) + && cap.getOwnerId().equals(relationshipInfo.getCapabilityOwnerId()); + } + + private NodeTemplateOperation createTestSubject() { + return operation; + } + + + @Test + public void testGetDefaultHeatTimeout() throws Exception { + Integer result; + + // default test + result = NodeTemplateOperation.getDefaultHeatTimeout(); } + + + + + + + + + + + + + @Test + public void testPrepareInstDeploymentArtifactPerInstance() throws Exception { + NodeTemplateOperation testSubject; + Map deploymentArtifacts = null; + String componentInstanceId = ""; + User user = null; + String envType = ""; + MapArtifactDataDefinition result; + + // test 1 + testSubject = createTestSubject(); + deploymentArtifacts = null; + result = testSubject.prepareInstDeploymentArtifactPerInstance(deploymentArtifacts, componentInstanceId, user, + envType); + Assert.assertEquals(null, result); + } + + + + @Test + public void testCreateCapPropertyKey() throws Exception { + String key = ""; + String instanceId = ""; + String result; + + // default test + result = NodeTemplateOperation.createCapPropertyKey(key, instanceId); + } + + + @Test + public void testPrepareCalculatedCapabiltyForNodeType() throws Exception { + NodeTemplateOperation testSubject; + Map capabilities = null; + ComponentInstanceDataDefinition componentInstance = null; + MapListCapabiltyDataDefinition result; + + // test 1 + testSubject = createTestSubject(); + capabilities = null; + result = testSubject.prepareCalculatedCapabiltyForNodeType(capabilities, componentInstance); + Assert.assertEquals(null, result); + } + + + @Test + public void testPrepareCalculatedRequirementForNodeType() throws Exception { + NodeTemplateOperation testSubject; + Map requirements = null; + ComponentInstanceDataDefinition componentInstance = null; + MapListRequirementDataDefinition result; + + // test 1 + testSubject = createTestSubject(); + requirements = null; + result = testSubject.prepareCalculatedRequirementForNodeType(requirements, componentInstance); + Assert.assertEquals(null, result); + } + + + @Test + public void testAddGroupInstancesToComponentInstance() throws Exception { + NodeTemplateOperation testSubject; + Component containerComponent = null; + ComponentInstanceDataDefinition componentInstance = null; + List groups = null; + Map> groupInstancesArtifacts = null; + StorageOperationStatus result; + + // test 1 + testSubject = createTestSubject(); + groupInstancesArtifacts = null; + result = testSubject.addGroupInstancesToComponentInstance(containerComponent, componentInstance, groups, + groupInstancesArtifacts); + Assert.assertEquals(StorageOperationStatus.OK, result); + } + + @Test + public void testGenerateCustomizationUUIDOnInstanceGroup() throws Exception { + NodeTemplateOperation testSubject; + String componentId = ""; + String instanceId = ""; + List groupInstances = null; + StorageOperationStatus result; + + // test 1 + testSubject = createTestSubject(); + groupInstances = null; + result = testSubject.generateCustomizationUUIDOnInstanceGroup(componentId, instanceId, groupInstances); + Assert.assertEquals(StorageOperationStatus.OK, result); + } + } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/IdMapperTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/IdMapperTest.java new file mode 100644 index 0000000000..3429f1ea49 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/IdMapperTest.java @@ -0,0 +1,39 @@ +package org.openecomp.sdc.be.model.jsontitan.utils; + +import javax.annotation.Generated; + +import org.junit.Test; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; + +public class IdMapperTest { + + private IdMapper createTestSubject() { + return new IdMapper(); + } + + + @Test + public void testMapComponentNameToUniqueId() throws Exception { + IdMapper testSubject; + String componentInstanceName = ""; + GraphVertex serviceVertex = null; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.mapComponentNameToUniqueId(componentInstanceName, serviceVertex); + } + + + @Test + public void testMapUniqueIdToComponentNameTo() throws Exception { + IdMapper testSubject; + String compUniqueId = ""; + GraphVertex serviceVertex = null; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.mapUniqueIdToComponentNameTo(compUniqueId, serviceVertex); + } +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtilsTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtilsTest.java new file mode 100644 index 0000000000..64c4cd792b --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtilsTest.java @@ -0,0 +1,72 @@ +package org.openecomp.sdc.be.model.jsontitan.utils; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; +import org.openecomp.sdc.be.model.InputDefinition; +import org.openecomp.sdc.be.model.InterfaceDefinition; +import org.openecomp.sdc.be.model.Operation; +import org.openecomp.sdc.be.model.Resource; + +public class InterfaceUtilsTest { + + private InterfaceUtils createTestSubject() { + return new InterfaceUtils(); + } + + + @Test + public void testGetInterfaceDefinitionFromToscaName() throws Exception { + Collection interfaces = null; + String resourceName = ""; + Optional result; + + // default test + result = InterfaceUtils.getInterfaceDefinitionFromToscaName(interfaces, resourceName); + } + + + @Test + public void testGetInterfaceDefinitionListFromToscaName() throws Exception { + Collection interfaces = null; + String resourceName = ""; + Collection result; + + // default test + result = InterfaceUtils.getInterfaceDefinitionListFromToscaName(interfaces, resourceName); + } + + + @Test + public void testCreateInterfaceToscaResourceName() throws Exception { + String resourceName = ""; + String result; + + // default test + result = InterfaceUtils.createInterfaceToscaResourceName(resourceName); + } + + + @Test + public void testGetInterfaceOperationsFromInterfaces() throws Exception { + Map interfaces = null; + Resource resource = null; + Map result; + + // default test + result = InterfaceUtils.getInterfaceOperationsFromInterfaces(interfaces, resource); + } + + @Test + public void testGetOperationsFromInterface() throws Exception { + Map interfaces = null; + List result; + + // default test + result = InterfaceUtils.getOperationsFromInterface(interfaces); + } +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java new file mode 100644 index 0000000000..bfefd00994 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java @@ -0,0 +1,89 @@ +package org.openecomp.sdc.be.model.operations.impl; + +import static org.junit.Assert.*; +import java.util.*; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; +import org.openecomp.sdc.be.dao.titan.TitanGenericDao; +import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.ComponentInstanceProperty; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import org.openecomp.sdc.be.resources.data.AttributeData; +import org.openecomp.sdc.be.resources.data.AttributeValueData; +import org.openecomp.sdc.be.resources.data.ComponentInstanceData; + +import fj.data.Either; + +public class ComponentInstanceOperationTest { + + private ComponentInstanceOperation createTestSubject() { + return new ComponentInstanceOperation(); + } + + + @Test + public void testSetTitanGenericDao() throws Exception { + ComponentInstanceOperation testSubject; + TitanGenericDao titanGenericDao = null; + + // default test + testSubject = createTestSubject(); + testSubject.setTitanGenericDao(titanGenericDao); + } + + + + + + +// @Test +// public void testValidateElementExistInGraph() throws Exception { +// ComponentInstanceOperation testSubject; +// String elementUniqueId = ""; +// NodeTypeEnum elementNodeType = null; +// Supplier> elementClassGen = null; +// Wrapper elementDataWrapper = null; +// Wrapper errorWrapper = null; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.validateElementExistInGraph(elementUniqueId, elementNodeType, elementClassGen, elementDataWrapper, +// errorWrapper); +// } + + + + + + + + + + + + + + + + @Test + public void testUpdateInputValueInResourceInstance() throws Exception { + ComponentInstanceOperation testSubject; + ComponentInstanceInput input = null; + String resourceInstanceId = ""; + boolean b = false; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.updateInputValueInResourceInstance(input, resourceInstanceId, b); + } + + + + + + +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java index e03349d9ab..1e493a74f4 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java @@ -20,26 +20,39 @@ package org.openecomp.sdc.be.model.operations.impl; +import static org.junit.Assert.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.titan.TitanGenericDao; +import org.openecomp.sdc.be.dao.titan.TitanGraphClient; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.ArtifactType; import org.openecomp.sdc.be.model.ModelTestBase; +import org.openecomp.sdc.be.model.PropertyScope; +import org.openecomp.sdc.be.model.Tag; import org.openecomp.sdc.be.model.category.CategoryDefinition; +import org.openecomp.sdc.be.model.category.GroupingDefinition; +import org.openecomp.sdc.be.model.category.SubCategoryDefinition; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil; +import org.openecomp.sdc.be.resources.data.category.CategoryData; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import fj.data.Either; +import java.util.*; + +import org.apache.tinkerpop.gremlin.structure.T; +import org.junit.Assert; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:application-context-test.xml") @@ -87,11 +100,27 @@ public class ElementOperationTest extends ModelTestBase { artifactTypesCfg.add("type5"); } + @Test + public void testAllDeploymentArtifactTypes() { + + List artifactTypesCfg = new ArrayList(); + artifactTypesCfg.add("type1"); + artifactTypesCfg.add("type2"); + artifactTypesCfg.add("type3"); + configurationManager.getConfiguration().setArtifactTypes(artifactTypesCfg); + Either, ActionStatus> allDeploymentArtifactTypes = elementOperation + .getAllDeploymentArtifactTypes(); + assertTrue(allDeploymentArtifactTypes.isLeft()); + assertEquals(artifactTypesCfg.size(), allDeploymentArtifactTypes.left().value().size()); + + } + // @Test public void testGetResourceAndServiceCategoty() { String id = OperationTestsUtil.deleteAndCreateResourceCategory(CATEGORY, SUBCATEGORY, titanDao); - Either res = elementOperation.getCategory(NodeTypeEnum.ResourceNewCategory, id); + Either res = elementOperation.getCategory(NodeTypeEnum.ResourceNewCategory, + id); assertTrue(res.isLeft()); CategoryDefinition categoryDefinition = (CategoryDefinition) res.left().value(); assertEquals(CATEGORY, categoryDefinition.getName()); @@ -104,4 +133,372 @@ public class ElementOperationTest extends ModelTestBase { categoryDefinition = (CategoryDefinition) res.left().value(); assertEquals(CATEGORY, categoryDefinition.getName()); } + + private ElementOperation createTestSubject() { + return new ElementOperation(new TitanGenericDao(new TitanGraphClient())); + } + + + @Test + public void testGetAllServiceCategories() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllServiceCategories(); + } + + + @Test + public void testGetAllResourceCategories() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllResourceCategories(); + } + + + @Test + public void testGetAllProductCategories() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllProductCategories(); + } + + + @Test + public void testCreateCategory() throws Exception { + ElementOperation testSubject; + CategoryDefinition category = new CategoryDefinition(); + NodeTypeEnum nodeType = NodeTypeEnum.AdditionalInfoParameters; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.createCategory(category, nodeType); + } + + + @Test + public void testCreateCategory_1() throws Exception { + ElementOperation testSubject; + CategoryDefinition category = new CategoryDefinition(); + NodeTypeEnum nodeType = NodeTypeEnum.ArtifactRef; + boolean inTransaction = false; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.createCategory(category, nodeType, inTransaction); + } + + + @Test + public void testCreateSubCategory() throws Exception { + ElementOperation testSubject; + String categoryId = ""; + SubCategoryDefinition subCategory = null; + NodeTypeEnum nodeType = null; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.createSubCategory(categoryId, subCategory, nodeType); + } + + + @Test + public void testCreateSubCategory_1() throws Exception { + ElementOperation testSubject; + String categoryId = ""; + SubCategoryDefinition subCategory = null; + NodeTypeEnum nodeType = null; + boolean inTransaction = false; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.createSubCategory(categoryId, subCategory, nodeType, inTransaction); + } + + + @Test + public void testCreateGrouping() throws Exception { + ElementOperation testSubject; + String subCategoryId = ""; + GroupingDefinition grouping = null; + NodeTypeEnum nodeType = null; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.createGrouping(subCategoryId, grouping, nodeType); + } + + + @Test + public void testGetAllCategories() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = NodeTypeEnum.Capability; + boolean inTransaction = false; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllCategories(nodeType, inTransaction); + } + + + + + + + + + + @Test + public void testGetCategory() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = NodeTypeEnum.CapabilityType; + String categoryId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCategory(nodeType, categoryId); + } + + + @Test + public void testGetSubCategory() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = NodeTypeEnum.Group; + String subCategoryId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSubCategory(nodeType, subCategoryId); + } + + + @Test + public void testDeleteCategory() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = NodeTypeEnum.getByName("resource"); + String categoryId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.deleteCategory(nodeType, categoryId); + } + + + @Test + public void testDeleteSubCategory() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = NodeTypeEnum.Attribute; + String subCategoryId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.deleteSubCategory(nodeType, subCategoryId); + } + + + @Test + public void testDeleteGrouping() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = NodeTypeEnum.DataType; + String groupingId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.deleteGrouping(nodeType, groupingId); + } + + + @Test + public void testIsCategoryUniqueForType() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = null; + String normalizedName = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isCategoryUniqueForType(nodeType, normalizedName); + } + + + @Test + public void testIsSubCategoryUniqueForCategory() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = null; + String subCategoryNormName = ""; + String parentCategoryId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isSubCategoryUniqueForCategory(nodeType, subCategoryNormName, parentCategoryId); + } + + + @Test + public void testIsGroupingUniqueForSubCategory() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = null; + String groupingNormName = ""; + String parentSubCategoryId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isGroupingUniqueForSubCategory(nodeType, groupingNormName, parentSubCategoryId); + } + + + @Test + public void testGetSubCategoryUniqueForType() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = null; + String normalizedName = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSubCategoryUniqueForType(nodeType, normalizedName); + } + + + @Test + public void testGetGroupingUniqueForType() throws Exception { + ElementOperation testSubject; + NodeTypeEnum nodeType = null; + String groupingNormalizedName = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getGroupingUniqueForType(nodeType, groupingNormalizedName); + } + + + @Test + public void testGetAllTags() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllTags(); + } + + + @Test + public void testGetCategoryData() throws Exception { + ElementOperation testSubject; + String name = ""; + NodeTypeEnum type = NodeTypeEnum.DataType; + Class clazz = null; + Either result; + + // test 1 + testSubject = createTestSubject(); + name = null; + result = testSubject.getCategoryData(name, type, null); + + // test 2 + testSubject = createTestSubject(); + name = ""; + result = testSubject.getCategoryData(name, type, null); + } + + + + + + @Test + public void testGetAllPropertyScopes() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllPropertyScopes(); + } + + + @Test + public void testGetAllArtifactTypes() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllArtifactTypes(); + } + + + @Test + public void testGetAllDeploymentArtifactTypes() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllDeploymentArtifactTypes(); + } + + + @Test + public void testGetDefaultHeatTimeout() throws Exception { + ElementOperation testSubject; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDefaultHeatTimeout(); + } + + + @Test + public void testGetResourceTypesMap() throws Exception { + ElementOperation testSubject; + Either, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceTypesMap(); + } + + + @Test + public void testGetNewCategoryData() throws Exception { + ElementOperation testSubject; + String name = ""; + NodeTypeEnum type = NodeTypeEnum.HeatParameter; + Class clazz = null; + Either result; + + // test 1 + testSubject = createTestSubject(); + name = null; + result = testSubject.getNewCategoryData(name, type, null); + + // test 2 + testSubject = createTestSubject(); + name = ""; + result = testSubject.getNewCategoryData(name, type, null); + } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java index 88f3a24b5d..c3e23ba001 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java @@ -20,35 +20,56 @@ package org.openecomp.sdc.be.model.operations.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.tinkerpop.gremlin.structure.T; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import org.openecomp.sdc.be.dao.titan.TitanGenericDao; +import org.openecomp.sdc.be.dao.titan.TitanGraphClient; +import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyRule; +import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.ComponentInstanceProperty; +import org.openecomp.sdc.be.model.DataTypeDefinition; +import org.openecomp.sdc.be.model.IComplexDefaultValue; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.operations.api.DerivedFromOperation; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.model.tosca.ToscaType; import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint; import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint; import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint; +import org.openecomp.sdc.be.resources.data.DataTypeData; +import org.openecomp.sdc.be.resources.data.PropertyData; +import org.openecomp.sdc.be.resources.data.PropertyValueData; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.thinkaurelius.titan.core.TitanVertex; -import static org.junit.Assert.*; +import fj.data.Either; public class PropertyOperationTest extends ModelTestBase { TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class); - + PropertyOperation propertyOperation = new PropertyOperation(titanGenericDao, null); @Before @@ -60,28 +81,46 @@ public class PropertyOperationTest extends ModelTestBase { /* * @Test public void addPropertyToResourceTest() { * - * String propName = "myProp"; PropertyDefinition property = buildPropertyDefinition(); List constraints = buildConstraints(); property.setConstraints(constraints); + * String propName = "myProp"; PropertyDefinition property = + * buildPropertyDefinition(); List constraints = + * buildConstraints(); property.setConstraints(constraints); * - * PropertyData propertyData = new PropertyData(property, propertyOperation.convertConstraintsToString(constraints)); + * PropertyData propertyData = new PropertyData(property, + * propertyOperation.convertConstraintsToString(constraints)); * - * Either either = Either.left(propertyData); //when(propertyDao.create((GraphNeighbourTable)anyObject(), eq(PropertyData.class), eq(NodeTypeEnum.Property))).thenReturn(either); GraphRelation graphRelation = - * new GraphRelation(); Either relationResult = Either.left(graphRelation); + * Either either = + * Either.left(propertyData); + * //when(propertyDao.create((GraphNeighbourTable)anyObject(), + * eq(PropertyData.class), eq(NodeTypeEnum.Property))).thenReturn(either); + * GraphRelation graphRelation = new GraphRelation(); Either relationResult = Either.left(graphRelation); * - * when(titanGenericDao.createNode((PropertyData)anyObject(), eq(PropertyData.class))).thenReturn(either); when(titanGenericDao.createRelation((GraphNode)anyObject(), (GraphNode)anyObject(), eq(GraphEdgeLabels.PROPERTY), + * when(titanGenericDao.createNode((PropertyData)anyObject(), + * eq(PropertyData.class))).thenReturn(either); + * when(titanGenericDao.createRelation((GraphNode)anyObject(), + * (GraphNode)anyObject(), eq(GraphEdgeLabels.PROPERTY), * anyMap())).thenReturn(relationResult); * - * Either result = propertyOperation.addPropertyToResource(propName, property, NodeTypeEnum.Resource, "my-resource.1.0"); + * Either result = + * propertyOperation.addPropertyToResource(propName, property, + * NodeTypeEnum.Resource, "my-resource.1.0"); * - * assertTrue(result.isLeft()); System.out.println(result.left().value()); PropertyDefinition propertyDefinition = result.left().value(); + * assertTrue(result.isLeft()); System.out.println(result.left().value()); + * PropertyDefinition propertyDefinition = result.left().value(); * - * List originalConstraints = property.getConstraints(); List propertyConstraintsResult = propertyDefinition.getConstraints(); assertEquals(propertyConstraintsResult.size(), originalConstraints.size()); + * List originalConstraints = property.getConstraints(); + * List propertyConstraintsResult = + * propertyDefinition.getConstraints(); + * assertEquals(propertyConstraintsResult.size(), + * originalConstraints.size()); * * } */ private PropertyDefinition buildPropertyDefinition() { PropertyDefinition property = new PropertyDefinition(); property.setDefaultValue("10"); - property.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node."); + property.setDescription( + "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node."); property.setType(ToscaType.INTEGER.name().toLowerCase()); return property; } @@ -147,7 +186,8 @@ public class PropertyOperationTest extends ModelTestBase { List convertedStringConstraints = propertyOperation.convertConstraintsToString(constraints); assertEquals("constraints size", constraints.size(), convertedStringConstraints.size()); - List convertedConstraints = propertyOperation.convertConstraints(convertedStringConstraints); + List convertedConstraints = propertyOperation + .convertConstraints(convertedStringConstraints); assertEquals("check size of constraints", constraints.size(), convertedConstraints.size()); Set constraintsClasses = new HashSet(); @@ -156,7 +196,8 @@ public class PropertyOperationTest extends ModelTestBase { } for (PropertyConstraint propertyConstraint : convertedConstraints) { - assertTrue("check all classes generated", constraintsClasses.contains(propertyConstraint.getClass().getName())); + assertTrue("check all classes generated", + constraintsClasses.contains(propertyConstraint.getClass().getName())); } } @@ -288,7 +329,8 @@ public class PropertyOperationTest extends ModelTestBase { assertEquals("check value", "v1node1", instanceProperty.getValue()); assertEquals("check default value", "v1node3", instanceProperty.getDefaultValue()); - assertEquals("check valid unique id", instanceProperty1.getValueUniqueUid(), instanceProperty.getValueUniqueUid()); + assertEquals("check valid unique id", instanceProperty1.getValueUniqueUid(), + instanceProperty.getValueUniqueUid()); } @@ -507,6 +549,664 @@ public class PropertyOperationTest extends ModelTestBase { } + private PropertyOperation createTestSubject() { + return new PropertyOperation(new TitanGenericDao(new TitanGraphClient()), null); + } + + + @Test + public void testMain() throws Exception { + String[] args = new String[] { "" }; + + // default test + PropertyOperation.main(args); + } + + + @Test + public void testConvertPropertyDataToPropertyDefinition() throws Exception { + PropertyOperation testSubject; + PropertyData propertyDataResult = new PropertyData(); + String propertyName = ""; + String resourceId = ""; + PropertyDefinition result; + + // default test + testSubject = createTestSubject(); + result = testSubject.convertPropertyDataToPropertyDefinition(propertyDataResult, propertyName, resourceId); + } + + + @Test + public void testAddPropertiesToGraph() throws Exception { + PropertyOperation testSubject; + Map properties = null; + String resourceId = ""; + Map dataTypes = null; + TitanOperationStatus result; + + // test 1 + testSubject = createTestSubject(); + properties = null; + result = testSubject.addPropertiesToGraph(properties, resourceId, dataTypes); + } + + + @Test + public void testAddPropertiesToGraph_1() throws Exception { + PropertyOperation testSubject; + TitanVertex metadataVertex = null; + Map properties = null; + Map dataTypes = null; + String resourceId = ""; + TitanOperationStatus result; + + // test 1 + testSubject = createTestSubject(); + properties = null; + result = testSubject.addPropertiesToGraph(metadataVertex, properties, dataTypes, resourceId); + } + + + @Test + public void testAddProperty() throws Exception { + PropertyOperation testSubject; + String propertyName = ""; + PropertyDefinition propertyDefinition = new PropertyDefinition(); + String resourceId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.addProperty(propertyName, propertyDefinition, resourceId); + } + + + @Test + public void testValidateAndUpdateProperty() throws Exception { + PropertyOperation testSubject; + IComplexDefaultValue propertyDefinition = new PropertyDefinition(); + Map dataTypes = new HashMap<>(); + dataTypes.put("", new DataTypeDefinition()); + StorageOperationStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.validateAndUpdateProperty(propertyDefinition, dataTypes); + } + + + @Test + public void testAddPropertyToGraph() throws Exception { + PropertyOperation testSubject; + String propertyName = ""; + PropertyDefinition propertyDefinition = new PropertyDefinition(); + String resourceId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.addPropertyToGraph(propertyName, propertyDefinition, resourceId); + } + + + @Test + public void testAddPropertyToGraphByVertex() throws Exception { + PropertyOperation testSubject; + TitanVertex metadataVertex = null; + String propertyName = ""; + PropertyDefinition propertyDefinition = new PropertyDefinition(); + String resourceId = ""; + TitanOperationStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.addPropertyToGraphByVertex(metadataVertex, propertyName, propertyDefinition, resourceId); + } + + + @Test + public void testGetTitanGenericDao() throws Exception { + PropertyOperation testSubject; + TitanGenericDao result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getTitanGenericDao(); + } + + + @Test + public void testDeleteProperty() throws Exception { + PropertyOperation testSubject; + String propertyId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.deleteProperty(propertyId); + } + + + @Test + public void testDeletePropertyFromGraph() throws Exception { + PropertyOperation testSubject; + String propertyId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.deletePropertyFromGraph(propertyId); + } + + + @Test + public void testUpdateProperty() throws Exception { + PropertyOperation testSubject; + String propertyId = ""; + PropertyDefinition newPropertyDefinition = new PropertyDefinition(); + Map dataTypes = new HashMap<>(); + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.updateProperty(propertyId, newPropertyDefinition, dataTypes); + } + + + @Test + public void testUpdatePropertyFromGraph() throws Exception { + PropertyOperation testSubject; + String propertyId = ""; + PropertyDefinition propertyDefinition = null; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.updatePropertyFromGraph(propertyId, propertyDefinition); + } + + + @Test + public void testSetTitanGenericDao() throws Exception { + PropertyOperation testSubject; + TitanGenericDao titanGenericDao = null; + + // default test + testSubject = createTestSubject(); + testSubject.setTitanGenericDao(titanGenericDao); + } + + + @Test + public void testAddPropertyToNodeType() throws Exception { + PropertyOperation testSubject; + String propertyName = ""; + PropertyDefinition propertyDefinition = new PropertyDefinition(); + NodeTypeEnum nodeType = NodeTypeEnum.Attribute; + String uniqueId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.addPropertyToNodeType(propertyName, propertyDefinition, nodeType, uniqueId); + } + + + @Test + public void testFindPropertiesOfNode() throws Exception { + PropertyOperation testSubject; + NodeTypeEnum nodeType = null; + String uniqueId = ""; + Either, TitanOperationStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.findPropertiesOfNode(nodeType, uniqueId); + } + + + @Test + public void testDeletePropertiesAssociatedToNode() throws Exception { + PropertyOperation testSubject; + NodeTypeEnum nodeType = null; + String uniqueId = ""; + Either, StorageOperationStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.deletePropertiesAssociatedToNode(nodeType, uniqueId); + } + + + @Test + public void testDeleteAllPropertiesAssociatedToNode() throws Exception { + PropertyOperation testSubject; + NodeTypeEnum nodeType = null; + String uniqueId = ""; + Either, StorageOperationStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.deleteAllPropertiesAssociatedToNode(nodeType, uniqueId); + } + + + @Test + public void testIsPropertyExist() throws Exception { + PropertyOperation testSubject; + List properties = null; + String resourceUid = ""; + String propertyName = ""; + String propertyType = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isPropertyExist(properties, resourceUid, propertyName, propertyType); + } + + + @Test + public void testValidateAndUpdateRules() throws Exception { + PropertyOperation testSubject; + String propertyType = ""; + List rules = null; + String innerType = ""; + Map dataTypes = null; + boolean isValidate = false; + ImmutablePair result; + + // test 1 + testSubject = createTestSubject(); + rules = null; + result = testSubject.validateAndUpdateRules(propertyType, rules, innerType, dataTypes, isValidate); + } + + + @Test + public void testAddRulesToNewPropertyValue() throws Exception { + PropertyOperation testSubject; + PropertyValueData propertyValueData = new PropertyValueData(); + ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty(); + String resourceInstanceId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.addRulesToNewPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId); + } + + + @Test + public void testFindPropertyValue() throws Exception { + PropertyOperation testSubject; + String resourceInstanceId = ""; + String propertyId = ""; + ImmutablePair result; + + // default test + testSubject = createTestSubject(); + result = testSubject.findPropertyValue(resourceInstanceId, propertyId); + } + + + @Test + public void testUpdateRulesInPropertyValue() throws Exception { + PropertyOperation testSubject; + PropertyValueData propertyValueData = new PropertyValueData(); + ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty(); + String resourceInstanceId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.updateRulesInPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId); + } + + + @Test + public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId() throws Exception { + PropertyOperation testSubject; + String resourceInstanceUid = ""; + Either, TitanOperationStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid); + } + + + @Test + public void testRemovePropertyOfResourceInstance() throws Exception { + PropertyOperation testSubject; + String propertyValueUid = ""; + String resourceInstanceId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.removePropertyOfResourceInstance(propertyValueUid, resourceInstanceId); + } + + + @Test + public void testRemovePropertyValueFromResourceInstance() throws Exception { + PropertyOperation testSubject; + String propertyValueUid = ""; + String resourceInstanceId = ""; + boolean inTransaction = false; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.removePropertyValueFromResourceInstance(propertyValueUid, resourceInstanceId, + inTransaction); + } + + + @Test + public void testBuildResourceInstanceProperty() throws Exception { + PropertyOperation testSubject; + PropertyValueData propertyValueData = new PropertyValueData(); + ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty(); + ComponentInstanceProperty result; + + // default test + testSubject = createTestSubject(); + result = testSubject.buildResourceInstanceProperty(propertyValueData, resourceInstanceProperty); + } + + + @Test + public void testIsPropertyDefaultValueValid() throws Exception { + PropertyOperation testSubject; + IComplexDefaultValue propertyDefinition = null; + Map dataTypes = null; + boolean result; + + // test 1 + testSubject = createTestSubject(); + propertyDefinition = null; + result = testSubject.isPropertyDefaultValueValid(propertyDefinition, dataTypes); + Assert.assertEquals(false, result); + } + + + @Test + public void testIsPropertyTypeValid() throws Exception { + PropertyOperation testSubject; + IComplexDefaultValue property = null; + boolean result; + + // test 1 + testSubject = createTestSubject(); + property = null; + result = testSubject.isPropertyTypeValid(property); + Assert.assertEquals(false, result); + } + + + @Test + public void testIsPropertyInnerTypeValid() throws Exception { + PropertyOperation testSubject; + IComplexDefaultValue property = null; + Map dataTypes = null; + ImmutablePair result; + + // test 1 + testSubject = createTestSubject(); + property = null; + result = testSubject.isPropertyInnerTypeValid(property, dataTypes); + } + + + @Test + public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId_1() throws Exception { + PropertyOperation testSubject; + String resourceInstanceUid = ""; + NodeTypeEnum instanceNodeType = null; + Either, TitanOperationStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid, instanceNodeType); + } + + + @Test + public void testFindDefaultValueFromSecondPosition() throws Exception { + PropertyOperation testSubject; + List pathOfComponentInstances = null; + String propertyUniqueId = ""; + String defaultValue = ""; + Either result; + + // test 1 + testSubject = createTestSubject(); + pathOfComponentInstances = null; + result = testSubject.findDefaultValueFromSecondPosition(pathOfComponentInstances, propertyUniqueId, + defaultValue); + } + + + @Test + public void testUpdatePropertyByBestMatch() throws Exception { + PropertyOperation testSubject; + String propertyUniqueId = ""; + ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty(); + List path = new ArrayList<>(); + path.add("path"); + instanceProperty.setPath(path); + Map instanceIdToValue = new HashMap<>(); + instanceIdToValue.put("123", instanceProperty); + + // default test + testSubject = createTestSubject(); + testSubject.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue); + } + + + @Test + public void testGetDataTypeByUid() throws Exception { + PropertyOperation testSubject; + String uniqueId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDataTypeByUid(uniqueId); + } + + + @Test + public void testAddDataType() throws Exception { + PropertyOperation testSubject; + DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(); + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.addDataType(dataTypeDefinition); + } + + + @Test + public void testGetDataTypeByName() throws Exception { + PropertyOperation testSubject; + String name = ""; + boolean inTransaction = false; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDataTypeByName(name, inTransaction); + } + + + @Test + public void testGetDataTypeByName_1() throws Exception { + PropertyOperation testSubject; + String name = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDataTypeByName(name); + } + + + @Test + public void testGetDataTypeByNameWithoutDerived() throws Exception { + PropertyOperation testSubject; + String name = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDataTypeByNameWithoutDerived(name); + } + + + @Test + public void testGetDataTypeByUidWithoutDerivedDataTypes() throws Exception { + PropertyOperation testSubject; + String uniqueId = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDataTypeByUidWithoutDerivedDataTypes(uniqueId); + } + + + @Test + public void testIsDefinedInDataTypes() throws Exception { + PropertyOperation testSubject; + String propertyType = ""; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isDefinedInDataTypes(propertyType); + } + + + @Test + public void testGetAllDataTypes() throws Exception { + PropertyOperation testSubject; + Either, TitanOperationStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllDataTypes(); + } + + + @Test + public void testCheckInnerType() throws Exception { + PropertyOperation testSubject; + PropertyDataDefinition propDataDef = new PropertyDataDefinition(); + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.checkInnerType(propDataDef); + } + + + @Test + public void testGetAllDataTypeNodes() throws Exception { + PropertyOperation testSubject; + Either, TitanOperationStatus> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllDataTypeNodes(); + } + + + @Test + public void testValidateAndUpdatePropertyValue() throws Exception { + PropertyOperation testSubject; + String propertyType = ""; + String value = ""; + boolean isValidate = false; + String innerType = ""; + Map dataTypes = null; + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.validateAndUpdatePropertyValue(propertyType, value, isValidate, innerType, dataTypes); + } + + + @Test + public void testValidateAndUpdatePropertyValue_1() throws Exception { + PropertyOperation testSubject; + String propertyType = ""; + String value = ""; + String innerType = ""; + Map dataTypes = new HashMap<>(); + dataTypes.put("", new DataTypeDefinition()); + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.validateAndUpdatePropertyValue(propertyType, value, innerType, dataTypes); + } + + + + + + @Test + public void testAddPropertiesToElementType() throws Exception { + PropertyOperation testSubject; + String uniqueId = ""; + NodeTypeEnum elementType = null; + List properties = null; + Either, TitanOperationStatus> result; + + // test 1 + testSubject = createTestSubject(); + properties = null; + result = testSubject.addPropertiesToElementType(uniqueId, elementType, properties); + } + + + @Test + public void testUpdateDataType() throws Exception { + PropertyOperation testSubject; + DataTypeDefinition newDataTypeDefinition = new DataTypeDefinition(); + DataTypeDefinition oldDataTypeDefinition = new DataTypeDefinition(); + Either result; + + // default test + testSubject = createTestSubject(); + result = testSubject.updateDataType(newDataTypeDefinition, oldDataTypeDefinition); + } + + + @Test + public void testIsValueToscaFunction() throws Exception { + PropertyOperation testSubject; + String type = ""; + String value = ""; + boolean result; + + // test 1 + testSubject = createTestSubject(); + value = null; + result = testSubject.isValueToscaFunction(type, value); + Assert.assertEquals(false, result); + + // test 2 + testSubject = createTestSubject(); + value = ""; + result = testSubject.isValueToscaFunction(type, value); + Assert.assertEquals(false, result); + } + // add all rule types // add rule with size = 1(instance itself = ALL). relevant for VLi. equals // to X.*.*.* in all paths size diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java new file mode 100644 index 0000000000..877c7c40eb --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java @@ -0,0 +1,41 @@ +package org.openecomp.sdc.be.model.tosca.constraints; + +import javax.annotation.Generated; + +import org.junit.Test; +import org.openecomp.sdc.be.model.tosca.ToscaType; +import org.openecomp.sdc.be.model.tosca.constraints.ConstraintUtil.ConstraintInformation; + +public class ConstraintUtilTest { + + @Test + public void testCheckStringType() throws Exception { + ToscaType propertyType = ToscaType.STRING; + + // default test + ConstraintUtil.checkStringType(propertyType); + } + + + @Test + public void testCheckComparableType() throws Exception { + ToscaType propertyType = ToscaType.INTEGER; + + // default test + ConstraintUtil.checkComparableType(propertyType); + } + + + @Test + public void testConvertToComparable() throws Exception { + ToscaType propertyType = ToscaType.BOOLEAN; + String value = ""; + Comparable result; + + // default test + result = ConstraintUtil.convertToComparable(propertyType, value); + } + + + +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/LowerCaseConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/LowerCaseConverterTest.java new file mode 100644 index 0000000000..d86f7f43f7 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/LowerCaseConverterTest.java @@ -0,0 +1,45 @@ +package org.openecomp.sdc.be.model.tosca.converters; + +import java.util.Map; + +import javax.annotation.Generated; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdc.be.model.DataTypeDefinition; + +public class LowerCaseConverterTest { + + private LowerCaseConverter createTestSubject() { + return LowerCaseConverter.getInstance(); + } + + + @Test + public void testConvert() throws Exception { + LowerCaseConverter testSubject; + String value = ""; + String innerType = ""; + Map dataTypes = null; + String result; + + // test 1 + testSubject = createTestSubject(); + value = null; + result = testSubject.convert(value, innerType, dataTypes); + + // test 2 + testSubject = createTestSubject(); + value = ""; + result = testSubject.convert(value, innerType, dataTypes); + } + + + @Test + public void testGetInstance() throws Exception { + LowerCaseConverter result; + + // default test + result = LowerCaseConverter.getInstance(); + } +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverterTest.java new file mode 100644 index 0000000000..02d8ed6632 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverterTest.java @@ -0,0 +1,27 @@ +package org.openecomp.sdc.be.model.tosca.converters; + +import static org.junit.Assert.*; +import java.util.*; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdc.be.model.DataTypeDefinition; + +import com.google.gson.JsonElement; + +public class ToscaMapValueConverterTest { + + private ToscaMapValueConverter createTestSubject() { + return ToscaMapValueConverter.getInstance(); + } + + + @Test + public void testGetInstance() throws Exception { + ToscaMapValueConverter result; + + // default test + result = ToscaMapValueConverter.getInstance(); + } + + +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/validators/ToscaBooleanValidatorTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/validators/ToscaBooleanValidatorTest.java new file mode 100644 index 0000000000..c1a99e754a --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/validators/ToscaBooleanValidatorTest.java @@ -0,0 +1,58 @@ +package org.openecomp.sdc.be.model.tosca.validators; + +import java.util.Map; + +import javax.annotation.Generated; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdc.be.model.DataTypeDefinition; + +public class ToscaBooleanValidatorTest { + + private ToscaBooleanValidator createTestSubject() { + return ToscaBooleanValidator.getInstance(); + } + + + @Test + public void testGetInstance() throws Exception { + ToscaBooleanValidator result; + + // default test + result = ToscaBooleanValidator.getInstance(); + } + + + @Test + public void testIsValid() throws Exception { + ToscaBooleanValidator testSubject; + String value = ""; + String innerType = ""; + Map dataTypes = null; + boolean result; + + // test 1 + testSubject = createTestSubject(); + value = null; + result = testSubject.isValid(value, innerType, dataTypes); + + // test 2 + testSubject = createTestSubject(); + value = ""; + result = testSubject.isValid(value, innerType, dataTypes); + } + + + @Test + public void testIsValid_1() throws Exception { + ToscaBooleanValidator testSubject; + String value = ""; + String innerType = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isValid(value, innerType); + } +} \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/unittests/utils/FactoryUtilsTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/unittests/utils/FactoryUtilsTest.java new file mode 100644 index 0000000000..380111dc77 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/unittests/utils/FactoryUtilsTest.java @@ -0,0 +1,179 @@ +package org.openecomp.sdc.be.unittests.utils; + +import java.util.List; + +import javax.annotation.Generated; + +import org.junit.Test; +import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; +import org.openecomp.sdc.be.model.CapabilityDefinition; +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.RequirementDefinition; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.resources.data.CapabilityData; +import org.openecomp.sdc.be.resources.data.CapabilityInstData; +import org.openecomp.sdc.be.resources.data.PropertyData; +import org.openecomp.sdc.be.resources.data.PropertyValueData; +import org.openecomp.sdc.be.resources.data.RequirementData; +import org.openecomp.sdc.be.resources.data.ResourceMetadataData; + +public class FactoryUtilsTest { + +// private FactoryUtils createTestSubject() { +// return FactoryUtils.Constants; +// } + + + @Test + public void testCreateVFWithRI() throws Exception { + String riVersion = ""; + Resource result; + + // default test + result = FactoryUtils.createVFWithRI(riVersion); + } + + + @Test + public void testCreateVF() throws Exception { + Resource result; + + // default test + result = FactoryUtils.createVF(); + } + + + @Test + public void testCreateResourceByType() throws Exception { + String resourceType = ""; + ResourceMetadataData result; + + // default test + result = FactoryUtils.createResourceByType(resourceType); + } + + + @Test + public void testAddComponentInstanceToVF() throws Exception { + Resource vf = new Resource(); + ComponentInstance resourceInstance = null; + + // default test + FactoryUtils.addComponentInstanceToVF(vf, resourceInstance); + } + + + @Test + public void testCreateResourceInstance() throws Exception { + ComponentInstance result; + + // default test + result = FactoryUtils.createResourceInstance(); + } + + + @Test + public void testCreateResourceInstanceWithVersion() throws Exception { + String riVersion = ""; + ComponentInstance result; + + // default test + result = FactoryUtils.createResourceInstanceWithVersion(riVersion); + } + + + @Test + public void testCreateCapabilityData() throws Exception { + CapabilityData result; + + // default test + result = FactoryUtils.createCapabilityData(); + } + + + @Test + public void testCreateRequirementData() throws Exception { + RequirementData result; + + // default test + result = FactoryUtils.createRequirementData(); + } + + + @Test + public void testConvertCapabilityDataToCapabilityDefinitionAddProperties() throws Exception { + CapabilityData capData = new CapabilityData(); + CapabilityDefinition result; + + // default test + result = FactoryUtils.convertCapabilityDataToCapabilityDefinitionAddProperties(capData); + } + + + @Test + public void testCreateComponentInstancePropertyList() throws Exception { + List result; + + // default test + result = FactoryUtils.createComponentInstancePropertyList(); + } + + + @Test + public void testConvertRequirementDataIDToRequirementDefinition() throws Exception { + String reqDataId = ""; + RequirementDefinition result; + + // default test + result = FactoryUtils.convertRequirementDataIDToRequirementDefinition(reqDataId); + } + + + @Test + public void testCreateGraphEdge() throws Exception { + GraphEdge result; + + // default test + result = FactoryUtils.createGraphEdge(); + } + + + @Test + public void testCreateCapabilityInstData() throws Exception { + CapabilityInstData result; + + // default test + result = FactoryUtils.createCapabilityInstData(); + } + + + @Test + public void testCreatePropertyData() throws Exception { + PropertyValueData result; + + // default test + result = FactoryUtils.createPropertyData(); + } + + + @Test + public void testConvertCapabilityDefinitionToCapabilityData() throws Exception { + PropertyDefinition propDef = new PropertyDefinition(); + PropertyData result; + + // default test + result = FactoryUtils.convertCapabilityDefinitionToCapabilityData(propDef); + } + + + @Test + public void testConvertCapabilityDataToCapabilityDefinitionRoot() throws Exception { + CapabilityData capData = new CapabilityData(); + CapabilityDefinition result; + + // default test + result = FactoryUtils.convertCapabilityDataToCapabilityDefinitionRoot(capData); + } +} \ No newline at end of file diff --git a/catalog-model/src/test/resources/config/configuration.yaml b/catalog-model/src/test/resources/config/configuration.yaml new file mode 100644 index 0000000000..f948f6e3cc --- /dev/null +++ b/catalog-model/src/test/resources/config/configuration.yaml @@ -0,0 +1,677 @@ +identificationHeaderFields: + - HTTP_IV_USER + - HTTP_CSP_FIRSTNAME + - HTTP_CSP_LASTNAME + - HTTP_IV_REMOTE_ADDRESS + - HTTP_CSP_WSTYPE + +# catalog backend hostname +beFqdn: localhost +# sdccatalog.att.com + +# catalog backend http port +beHttpPort: 8080 + +# catalog backend http context +beContext: /sdc/rest/config/get + +# catalog backend protocol +beProtocol: http + +# catalog backend ssl port +beSslPort: 8443 + +version: 1.1.0 +released: 2012-11-30 +toscaConformanceLevel: 5.0 +minToscaConformanceLevel: 3.0 + +titanCfgFile: /home/vagrant/catalog-be/config/catalog-be/titan.properties +titanInMemoryGraph: false +titanLockTimeout: 1800 + +# The interval to try and reconnect to titan DB when it is down during ASDC startup: +titanReconnectIntervalInSeconds: 3 + +# The read timeout towards Titan DB when health check is invoked: +titanHealthCheckReadTimeout: 1 + +# The interval to try and reconnect to Elasticsearch when it is down during ASDC startup: +esReconnectIntervalInSeconds: 3 +uebHealthCheckReconnectIntervalInSeconds: 15 +uebHealthCheckReadTimeout: 4 + +# Protocols +protocols: + - http + - https + +# Default imports +defaultImports: + - nodes: + file: nodes.yml + - datatypes: + file: data.yml + - capabilities: + file: capabilities.yml + - relationships: + file: relationships.yml + - groups: + file: groups.yml + - policies: + file: policies.yml + +# Users +users: + tom: passwd + bob: passwd + +neo4j: + host: neo4jhost + port: 7474 + user: neo4j + password: "12345" + +cassandraConfig: + cassandraHosts: ['localhost'] + localDataCenter: datacenter1 + reconnectTimeout : 30000 + authenticate: false + username: koko + password: bobo + ssl: false + truststorePath : /path/path + truststorePassword : 123123 + keySpaces: + - { name: sdcaudit, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + - { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + +#Application-specific settings of ES +elasticSearch: + # Mapping of index prefix to time-based frame. For example, if below is configured: + # + # - indexPrefix: auditingevents + # creationPeriod: minute + # + # then ES object of type which is mapped to "auditingevents-*" template, and created on 2015-12-23 13:24:54, will enter "auditingevents-2015-12-23-13-24" index. + # Another object created on 2015-12-23 13:25:54, will enter "auditingevents-2015-12-23-13-25" index. + # If creationPeriod: month, both of the above will enter "auditingevents-2015-12" index. + # + # PLEASE NOTE: the timestamps are created in UTC/GMT timezone! This is needed so that timestamps will be correctly presented in Kibana. + # + # Legal values for creationPeriod - year, month, day, hour, minute, none (meaning no time-based behaviour). + # + # If no creationPeriod is configured for indexPrefix, default behavour is creationPeriod: month. + + indicesTimeFrequency: + - indexPrefix: auditingevents + creationPeriod: month + - indexPrefix: monitoring_events + creationPeriod: month + +artifactTypes: + - CHEF + - PUPPET + - SHELL + - YANG + - YANG_XML + - HEAT + - BPEL + - DG_XML + - MURANO_PKG + - WORKFLOW + - NETWORK_CALL_FLOW + - TOSCA_TEMPLATE + - TOSCA_CSAR + - AAI_SERVICE_MODEL + - AAI_VF_MODEL + - AAI_VF_MODULE_MODEL + - AAI_VF_INSTANCE_MODEL + - OTHER + - SNMP_POLL + - SNMP_TRAP + - GUIDE + +licenseTypes: + - User + - Installation + - CPU + +#Deployment artifacts placeHolder +resourceTypes: &allResourceTypes + - VFC + - CP + - VL + - VF + - VFCMT + - Abstract + - CVFC + +# validForResourceTypes usage +# validForResourceTypes: +# - VF +# - VL +deploymentResourceArtifacts: +# heat: +# displayName: "Base HEAT Template" +# type: HEAT +# validForResourceTypes: *allResourceTypes +# heatVol: +# displayName: "Volume HEAT Template" +# type: HEAT_VOL +# validForResourceTypes: *allResourceTypes +# heatNet: +# displayName: "Network HEAT Template" +# type: HEAT_NET +# validForResourceTypes: *allResourceTypes + +deploymentResourceInstanceArtifacts: + heatEnv: + displayName: "HEAT ENV" + type: HEAT_ENV + description: "Auto-generated HEAT Environment deployment artifact" + fileExtension: "env" + VfHeatEnv: + displayName: "VF HEAT ENV" + type: HEAT_ENV + description: "VF Auto-generated HEAT Environment deployment artifact" + fileExtension: "env" + +#tosca artifacts placeholders +toscaArtifacts: + assetToscaTemplate: + artifactName: -template.yml + displayName: Tosca Template + type: TOSCA_TEMPLATE + description: TOSCA representation of the asset + assetToscaCsar: + artifactName: -csar.csar + displayName: Tosca Model + type: TOSCA_CSAR + description: TOSCA definition package of the asset + + +#Informational artifacts placeHolder +excludeResourceCategory: + - Generic +excludeResourceType: + - PNF +informationalResourceArtifacts: + features: + displayName: Features + type: OTHER + capacity: + displayName: Capacity + type: OTHER + vendorTestResult: + displayName: Vendor Test Result + type: OTHER + testScripts: + displayName: Test Scripts + type: OTHER + CloudQuestionnaire: + displayName: Cloud Questionnaire (completed) + type: OTHER + HEATTemplateFromVendor: + displayName: HEAT Template from Vendor + type: HEAT + resourceSecurityTemplate: + displayName: Resource Security Template + type: OTHER + +excludeServiceCategory: + +informationalServiceArtifacts: + serviceArtifactPlan: + displayName: Service Artifact Plan + type: OTHER + summaryOfImpactsToECOMPElements: + displayName: Summary of impacts to ECOMP elements,OSSs, BSSs + type: OTHER + controlLoopFunctions: + displayName: Control Loop Functions + type: OTHER + dimensioningInfo: + displayName: Dimensioning Info + type: OTHER + affinityRules: + displayName: Affinity Rules + type: OTHER + operationalPolicies: + displayName: Operational Policies + type: OTHER + serviceSpecificPolicies: + displayName: Service-specific Policies + type: OTHER + engineeringRules: + displayName: Engineering Rules (ERD) + type: OTHER + distributionInstructions: + displayName: Distribution Instructions + type: OTHER + certificationTestResults: + displayName: TD Certification Test Results + type: OTHER + deploymentVotingRecord: + displayName: Deployment Voting Record + type: OTHER + serviceQuestionnaire: + displayName: Service Questionnaire + type: OTHER + serviceSecurityTemplate: + displayName: Service Security Template + type: OTHER + +serviceApiArtifacts: + configuration: + displayName: Configuration + type: OTHER + instantiation: + displayName: Instantiation + type: OTHER + monitoring: + displayName: Monitoring + type: OTHER + reporting: + displayName: Reporting + type: OTHER + logging: + displayName: Logging + type: OTHER + testing: + displayName: Testing + type: OTHER + +additionalInformationMaxNumberOfKeys: 50 + +systemMonitoring: + enabled: false + isProxy: false + probeIntervalInSeconds: 15 + +defaultHeatArtifactTimeoutMinutes: 60 + +serviceDeploymentArtifacts: + YANG_XML: + acceptedTypes: + - xml + VNF_CATALOG: + acceptedTypes: + - xml + MODEL_INVENTORY_PROFILE: + acceptedTypes: + - xml + MODEL_QUERY_SPEC: + acceptedTypes: + - xml + UCPE_LAYER_2_CONFIGURATION: + acceptedTypes: + - xml + +#AAI Artifacts + AAI_SERVICE_MODEL: + acceptedTypes: + - xml + AAI_VF_MODULE_MODEL: + acceptedTypes: + - xml + AAI_VF_INSTANCE_MODEL: + acceptedTypes: + - xml + OTHER: + acceptedTypes: + +resourceDeploymentArtifacts: + HEAT: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_VOL: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_NET: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_NESTED: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_ARTIFACT: + acceptedTypes: + validForResourceTypes: *allResourceTypes + YANG_XML: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + VNF_CATALOG: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + VF_LICENSE: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + VENDOR_LICENSE: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + MODEL_INVENTORY_PROFILE: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + MODEL_QUERY_SPEC: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + LIFECYCLE_OPERATIONS: + acceptedTypes: + - yaml + - yml + validForResourceTypes: + - VF + - VFC + VES_EVENTS: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + PERFORMANCE_COUNTER: + acceptedTypes: + - csv + validForResourceTypes: *allResourceTypes + APPC_CONFIG: + acceptedTypes: + validForResourceTypes: + - VF + DCAE_TOSCA: + acceptedTypes: + - yml + - yaml + validForResourceTypes: + - VF + - VFCMT + DCAE_JSON: + acceptedTypes: + - json + validForResourceTypes: + - VF + - VFCMT + DCAE_POLICY: + acceptedTypes: + - emf + validForResourceTypes: + - VF + - VFCMT + DCAE_DOC: + acceptedTypes: + validForResourceTypes: + - VF + - VFCMT + DCAE_EVENT: + acceptedTypes: + validForResourceTypes: + - VF + - VFCMT + AAI_VF_MODEL: + acceptedTypes: + - xml + validForResourceTypes: + - VF + AAI_VF_MODULE_MODEL: + acceptedTypes: + - xml + validForResourceTypes: + - VF + OTHER: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_POLL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_TRAP: + acceptedTypes: + validForResourceTypes: *allResourceTypes + +resourceInstanceDeploymentArtifacts: + HEAT_ENV: + acceptedTypes: + - env + VF_MODULES_METADATA: + acceptedTypes: + - json + VES_EVENTS: + acceptedTypes: + - yaml + - yml + PERFORMANCE_COUNTER: + acceptedTypes: + - csv + DCAE_INVENTORY_TOSCA: + acceptedTypes: + - yml + - yaml + DCAE_INVENTORY_JSON: + acceptedTypes: + - json + DCAE_INVENTORY_POLICY: + acceptedTypes: + - emf + DCAE_INVENTORY_DOC: + acceptedTypes: + DCAE_INVENTORY_BLUEPRINT: + acceptedTypes: + DCAE_INVENTORY_EVENT: + acceptedTypes: + SNMP_POLL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_TRAP: + acceptedTypes: + validForResourceTypes: *allResourceTypes + +resourceInformationalArtifacts: + CHEF: + acceptedTypes: + validForResourceTypes: *allResourceTypes + PUPPET: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SHELL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + YANG: + acceptedTypes: + validForResourceTypes: *allResourceTypes + YANG_XML: + acceptedTypes: + validForResourceTypes: *allResourceTypes + HEAT: + acceptedTypes: + validForResourceTypes: *allResourceTypes + BPEL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + DG_XML: + acceptedTypes: + validForResourceTypes: *allResourceTypes + MURANO_PKG: + acceptedTypes: + validForResourceTypes: *allResourceTypes + OTHER: + acceptedTypes: + validForResourceTypes: + - VFC + - CVFC + - CP + - VL + - VF + - VFCMT + - Abstract + - PNF + SNMP_POLL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_TRAP: + acceptedTypes: + validForResourceTypes: *allResourceTypes + GUIDE: + acceptedTypes: + validForResourceTypes: + - VF + - VFC + - CVFC + +resourceInformationalDeployedArtifacts: + +requirementsToFulfillBeforeCert: + +capabilitiesToConsumeBeforeCert: + +unLoggedUrls: + - /sdc2/rest/healthCheck + +cleanComponentsConfiguration: + cleanIntervalInMinutes: 1440 + componentsToClean: + - Resource + - Service + +artifactsIndex: resources + +heatEnvArtifactHeader: "" +heatEnvArtifactFooter: "" + +onboarding: + protocol: http + host: localhost + port: 8080 + downloadCsarUri: "/onboarding-api/v1.0/vendor-software-products/packages" + healthCheckUri: "/onboarding-api/v1.0/healthcheck" + +dcae: + protocol: http + host: 127.0.0.1 + port: 8080 + healthCheckUri: "/dcae/healthCheck" + +switchoverDetector: + gBeFqdn: AIO-BE.ecomp.idns.cip.com + gFeFqdn: AIO-FE.ecomp.idns.cip.com + beVip: 0.0.0.0 + feVip: 0.0.0.0 + beResolveAttempts: 3 + feResolveAttempts: 3 + enabled: false + interval: 60 + changePriorityUser: ecompasdc + changePriorityPassword: ecompasdc123 + publishNetworkUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/update_network?user=root" + publishNetworkBody: '{"note":"publish network"}' + groups: + beSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com?user=root", + changePriorityBody: '{"name":"AIO-BE.ecomp.idns.com","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com","no_ad_redirection":false,"v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_be","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_be"],"failover_policy":["FAILALL"]},"comment":"AIO BE G-fqdn","intended_app_proto":"DNS"}'} + feSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com?user=root", + changePriorityBody: '{"comment":"AIO G-fqdn","name":"AIO-FE.ecomp.idns.com","v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_fe","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_fe"],"failover_policy":["FAILALL"]},"no_ad_redirection":false,"intended_app_proto":"DNS","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com"}'} + +applicationL1Cache: + datatypes: + enabled: true + firstRunDelay: 10 + pollIntervalInSec: 60 + +applicationL2Cache: + enabled: true + catalogL1Cache: + enabled: true + resourcesSizeInCache: 300 + servicesSizeInCache: 200 + productsSizeInCache: 100 + queue: + syncIntervalInSecondes: 43200 + waitOnShutDownInMinutes: 10 + numberOfCacheWorkers: 4 + +toscaValidators: + stringMaxLength: 2500 + +disableAudit: false + +vfModuleProperties: + min_vf_module_instances: + forBaseModule: 1 + forNonBaseModule: 0 + max_vf_module_instances: + forBaseModule: 1 + forNonBaseModule: + initial_count: + forBaseModule: 1 + forNonBaseModule: 0 + vf_module_type: + forBaseModule: Base + forNonBaseModule: Expansion + +genericAssetNodeTypes: + VFC: org.openecomp.resource.abstract.nodes.VFC + CVFC: org.openecomp.resource.abstract.nodes.VFC + VF : org.openecomp.resource.abstract.nodes.VF + PNF: org.openecomp.resource.abstract.nodes.PNF + Service: org.openecomp.resource.abstract.nodes.service + +workloadContext: Production +environmentContext: + defaultValue: General_Revenue-Bearing + validValues: + - Critical_Revenue-Bearing + - Vital_Revenue-Bearing + - Essential_Revenue-Bearing + - Important_Revenue-Bearing + - Needed_Revenue-Bearing + - Useful_Revenue-Bearing + - General_Revenue-Bearing + - Critical_Non-Revenue + - Vital_Non-Revenue + - Essential_Non-Revenue + - Important_Non-Revenue + - Needed_Non-Revenue + - Useful_Non-Revenue + - General_Non-Revenue + +dmaapConsumerConfiguration: + hosts: olsd004.wnsnet.attws.com:3905 + consumerGroup: asdc + consumerId: invalidMamaUser #mama - in Order To Consume Remove This String And Replace It With -> mama + timeoutMs: 15000 + limit: 1 + pollingInterval: 2 + topic: com.att.sdc.23911-SDCforTestDev-v001 + latitude: 32.109333 + longitude: 34.855499 + version: 1.0 + serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events + environment: TEST + partner: BOT_R + routeOffer: MR1 + protocol: https + contenttype: application/json + dme2TraceOn: true + aftEnvironment: AFTUAT + aftDme2ConnectionTimeoutMs: 15000 + aftDme2RoundtripTimeoutMs: 240000 + aftDme2ReadTimeoutMs: 50000 + dme2preferredRouterFilePath: DME2preferredRouter.txt + timeLimitForNotificationHandleMs: 0 + credential: + username: m09875@sdc.att.com + password: hmXYcznAljMSisdy8zgcag== + +dmeConfiguration: + dme2Search: DME2SEARCH + dme2Resolve: DME2RESOLVE -- cgit 1.2.3-korg