From dfc9cdee69426b48d683e119dda9fae9154e6fde Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 1 Mar 2021 20:58:10 +0000 Subject: Improve test coverage - remove unused code - use lombok Change-Id: I8c52584249347c7ca2102022457225401f95b9a5 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3490 --- .../sdc/be/model/CapabilityTypeDefinition.java | 9 --- .../org/openecomp/sdc/be/model/Combination.java | 71 ++--------------- .../operations/ArtifactsOperations.java | 6 -- .../jsonjanusgraph/operations/BaseOperation.java | 40 ---------- .../model/operations/impl/AbstractOperation.java | 4 - .../model/operations/impl/ArtifactOperation.java | 89 ---------------------- .../model/operations/impl/CapabilityOperation.java | 9 +-- .../be/model/operations/impl/CsarOperation.java | 11 --- .../be/model/operations/impl/OnboardingClient.java | 16 +--- .../model/operations/impl/PropertyOperation.java | 36 --------- .../tosca/version/ApplicationVersionException.java | 4 - .../openecomp/sdc/be/model/CombinationTest.java | 9 +-- .../operations/impl/PropertyOperationTest.java | 85 --------------------- 13 files changed, 9 insertions(+), 380 deletions(-) (limited to 'catalog-model/src') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java index f7627e76df..c15d1541d0 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java @@ -28,7 +28,6 @@ import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition; import org.openecomp.sdc.be.resources.data.CapabilityTypeData; import java.util.Map; -import java.util.stream.Collectors; /** * Specifies the capabilities that the Node Type exposes. @@ -47,14 +46,6 @@ public class CapabilityTypeDefinition extends CapabilityTypeDataDefinition { public CapabilityTypeDefinition(CapabilityTypeDataDefinition p) { super(p); } - - public CapabilityTypeDefinition(CapabilityDefinition cp) { - this.setUniqueId(cp.getUniqueId()); - this.setDescription ( cp.getDescription()); - this.setType(cp.getType()); - this.setValidSourceTypes( cp.getValidSourceTypes()); - this.setProperties(cp.getProperties().stream().collect(Collectors.toMap(ComponentInstanceProperty::getName, PropertyDefinition::new))); - } public CapabilityTypeDefinition(CapabilityTypeData ctd) { this.setUniqueId(ctd.getUniqueId()); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Combination.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Combination.java index b38e2ff04a..0ea79d975c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Combination.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Combination.java @@ -22,8 +22,12 @@ import com.fasterxml.jackson.annotation.JsonInclude; import java.util.List; import java.util.Map; +import lombok.Getter; +import lombok.Setter; import org.openecomp.sdc.be.ui.model.UiCombination; +@Getter +@Setter @JsonInclude(JsonInclude.Include.NON_NULL) public class Combination { @@ -36,75 +40,10 @@ public class Combination { private Map> componentInstancesProperties; private Map> componentInstancesAttributes; - public Combination() { - } // To form the combination object with the data received from UI public Combination(UiCombination UICombination) { name = UICombination.getName(); description = UICombination.getDescription(); } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return description; - } - - public void setDesc(String description) { - this.description = description; - } - - public String getUniqueId() { - return uniqueId; - } - - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; - } - - public List getComponentInstances() { - return componentInstances; - } - - public void setComponentInstances(List componentInstances) { - this.componentInstances = componentInstances; - } - - public List getComponentInstancesRelations() { - return componentInstancesRelations; - } - - public void setComponentInstancesRelations(List componentInstancesRelations) { - this.componentInstancesRelations = componentInstancesRelations; - } - - public Map> getComponentInstancesInputs() { - return componentInstancesInputs; - } - - public void setComponentInstancesInputs(Map> componentInstancesInputs) { - this.componentInstancesInputs = componentInstancesInputs; - } - - public Map> getComponentInstancesProperties() { - return componentInstancesProperties; - } - - public void setComponentInstancesProperties(Map> componentInstancesProperties) { - this.componentInstancesProperties = componentInstancesProperties; - } - - public Map> getComponentInstancesAttributes() { - return componentInstancesAttributes; - } - - public void setComponentInstancesAttributes(Map> componentInstancesAttributes) { - this.componentInstancesAttributes = componentInstancesAttributes; - } -} \ No newline at end of file +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java index 30e76a8b79..baf1d22cb2 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java @@ -376,12 +376,6 @@ public class ArtifactsOperations extends BaseOperation { } } - // @TODO add implementation - - public Either, StorageOperationStatus> getArtifacts(String parentId, NodeTypeEnum parentType) { - return null; - } - public Either addHeatEnvArtifact(ArtifactDefinition artifactHeatEnv, ArtifactDefinition artifactHeat, Component component, NodeTypeEnum parentType, boolean failIfExist, String instanceId) { artifactHeatEnv.setGeneratedFromId(artifactHeat.getUniqueId()); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java index 9e12e6e67d..1f2ef528cf 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java @@ -291,7 +291,6 @@ public abstract class BaseOperation { } protected Either updateOrCopyOnUpdate(GraphVertex dataVertex, GraphVertex toscaElementVertex, EdgeLabelEnum label) { -// healingPipelineDao.setHealingVersion(dataVertex); Iterator edges = dataVertex.getVertex().edges(Direction.IN, label.name()); int edgeCount = 0; Edge edgeToRemove = null; @@ -386,45 +385,6 @@ public abstract class BaseOperation { return addToscaDataToToscaElement(toscaElement, edgeLabel, vertexLabel, toscaDataList, mapKeyField); } - /** - * Adds tosca data deep element to tosca element according received labels - * - * @param toscaElement - * @param edgeLabel - * @param vertexLabel - * @param toscaData - * @param pathKeys - * @param mapKeyField - * @return - */ - public StorageOperationStatus addToscaDataDeepElementToToscaElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel, T toscaData, List pathKeys, - JsonPresentationFields mapKeyField) { - - List toscaDataList = new ArrayList<>(); - toscaDataList.add(toscaData); - return addToscaDataDeepElementsToToscaElement(toscaElement, edgeLabel, vertexLabel, toscaDataList, pathKeys, mapKeyField); - } - - /** - * Converts recieved map of tosca data deep elements to list and adds it to tosca element according received labels - * - * @param toscaElement - * @param edgeLabel - * @param vertexLabel - * @param toscaDataMap - * @param pathKeys - * @param mapKeyField - * @return - */ - public StorageOperationStatus addToscaDataDeepElementsToToscaElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel, Map toscaDataMap, List pathKeys, - JsonPresentationFields mapKeyField) { - - if (toscaDataMap != null) { - return addToscaDataDeepElementsToToscaElement(toscaElement, edgeLabel, vertexLabel, toscaDataMap.values().stream().collect(Collectors.toList()), pathKeys, mapKeyField); - } - return StorageOperationStatus.OK; - } - /** * Adds list of tosca data deep elements to tosca element according received labels * diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java index 40fe5c8b4f..62f85e6b5f 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java @@ -197,10 +197,6 @@ public abstract class AbstractOperation { return value == null; } - public boolean isNullParam(String value) { - return value == null; - } - protected StorageOperationStatus validateAndUpdateComplexValue(IComplexDefaultValue propertyDefinition, String propertyType, String value, DataTypeDefinition dataTypeDefinition, Map dataTypes) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperation.java index f64f761873..102e896c38 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperation.java @@ -77,22 +77,6 @@ public class ArtifactOperation { super(); } - public JanusGraphGenericDao getJanusGraphGenericDao() { - return janusGraphGenericDao; - } - - public void setJanusGraphGenericDao(JanusGraphGenericDao janusGraphGenericDao) { - this.janusGraphGenericDao = janusGraphGenericDao; - } - - public HeatParametersOperation getHeatParametersOperation() { - return heatParametersOperation; - } - - public void setHeatParametersOperation(HeatParametersOperation heatParametersOperation) { - this.heatParametersOperation = heatParametersOperation; - } - public Either addArifactToComponent(ArtifactDefinition artifactInfo, String parentId, NodeTypeEnum type, boolean failIfExist, boolean inTransaction) { Either status = addArtifactToGraph(artifactInfo, parentId, type, failIfExist); @@ -117,79 +101,6 @@ public class ArtifactOperation { } - public StorageOperationStatus addArifactToComponent(ArtifactDefinition artifactInfo, String parentId, NodeTypeEnum type, boolean failIfExist, JanusGraphVertex parentVertex) { - - StorageOperationStatus status = addArtifactToGraph(artifactInfo, parentId, type, failIfExist, parentVertex); - - if (status.equals(StorageOperationStatus.OK)) { - log.debug("Failed to add artifact {} {} to {}", artifactInfo.getArtifactName(), type, parentId); - } - return status; - } - - private StorageOperationStatus addArtifactToGraph(ArtifactDefinition artifactInfo, String id, NodeTypeEnum type, boolean failIfexist, JanusGraphVertex parentVertex) { - - if (artifactInfo.getUniqueId() == null || artifactInfo.getUniqueId().isEmpty()) { - String uniqueId = UniqueIdBuilder.buildPropertyUniqueId(id, artifactInfo.getArtifactLabel()); - artifactInfo.setUniqueId(uniqueId); - } - - if (!validateParentType(type)) { - return StorageOperationStatus.GENERAL_ERROR; - } - - ArtifactData artifactData = new ArtifactData(artifactInfo); - - Either existArtifact = janusGraphGenericDao - .getVertexByProperty(artifactData.getUniqueIdKey(), artifactData.getUniqueId()); - if (existArtifact.isRight()) { - if (existArtifact.right().value().equals(JanusGraphOperationStatus.NOT_FOUND)) { - // create new node - log.debug("Before adding artifact to graph {}", artifactData); - if (artifactData.getArtifactDataDefinition().getArtifactUUID() == null || artifactData.getArtifactDataDefinition().getArtifactUUID().isEmpty()) - updateUUID(artifactData.getArtifactDataDefinition(), null, artifactData.getArtifactDataDefinition().getArtifactVersion()); - Either createNodeResult = janusGraphGenericDao.createNode(artifactData); - - if (createNodeResult.isRight()) { - JanusGraphOperationStatus operationStatus = createNodeResult.right().value(); - log.debug("Failed to add artifact {} to graph. status is {}", artifactData.getArtifactDataDefinition().getArtifactName(), operationStatus); - BeEcompErrorManager.getInstance().logBeFailedCreateNodeError("Add artifact", artifactData.getArtifactDataDefinition().getArtifactName(), String.valueOf(operationStatus)); - return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(operationStatus); - } - - // add heat parameters - if (artifactInfo.getHeatParameters() != null && !artifactInfo.getHeatParameters().isEmpty() && !artifactInfo.getArtifactType().equals(ArtifactTypeEnum.HEAT_ENV.getType())) { - StorageOperationStatus addPropertiesStatus = heatParametersOperation.addPropertiesToGraph(artifactInfo.getListHeatParameters(), artifactData.getUniqueId().toString(), NodeTypeEnum.ArtifactRef); - if (addPropertiesStatus != StorageOperationStatus.OK) { - log.debug("Failed to create heat parameters on graph for artifact {}", artifactInfo.getArtifactName()); - return addPropertiesStatus; - } - } - - } else { - log.debug("Failed to check existance of artifact in graph for id {}", artifactData.getUniqueId()); - return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(existArtifact.right().value()); - } - } else if (failIfexist) { - log.debug("Artifact {} already exist", artifactData.getUniqueId()); - return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(JanusGraphOperationStatus.ALREADY_EXIST); - } - - // save logical artifact ref name on edge as property - Map properties = new HashMap<>(); - properties.put(GraphEdgePropertiesDictionary.NAME.getProperty(), artifactInfo.getArtifactLabel()); - if (artifactInfo.getArtifactGroupType() != null) - properties.put(GraphEdgePropertiesDictionary.GROUP_TYPE.getProperty(), artifactInfo.getArtifactGroupType().getType()); - JanusGraphOperationStatus relation = janusGraphGenericDao - .createEdge(parentVertex, artifactData, GraphEdgeLabels.ARTIFACT_REF, properties); - if (!relation.equals(JanusGraphOperationStatus.OK)) { - log.debug("Failed to create relation in graph for id {} to new artifact", id); - return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(relation); - } - - return StorageOperationStatus.OK; - } - private Either addArtifactToGraph(ArtifactDefinition artifactInfo, String id, NodeTypeEnum type, boolean failIfexist) { if (artifactInfo.getUniqueId() == null || artifactInfo.getUniqueId().isEmpty()) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java index ed635d1a0a..9ee085342e 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java @@ -22,7 +22,6 @@ package org.openecomp.sdc.be.model.operations.impl; import static org.springframework.util.CollectionUtils.isEmpty; -import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import fj.data.Either; import java.util.ArrayList; @@ -36,7 +35,6 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; -import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary; @@ -68,12 +66,7 @@ public class CapabilityOperation extends AbstractOperation { this.capabilityTypeOperation = capabilityTypeOperation; this.propertyOperation = propertyOperation; } - - - @VisibleForTesting - public void setJanusGraphGenericDao(HealingJanusGraphGenericDao janusGraphGenericDao) { - this.janusGraphGenericDao = janusGraphGenericDao; - } + public Either addCapabilityToGraph(String resourceId, CapabilityTypeData capTypeData, CapabilityDefinition capabilityDefinition) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CsarOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CsarOperation.java index af8a68f410..0e88d6b081 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CsarOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CsarOperation.java @@ -40,17 +40,6 @@ public class CsarOperation { @javax.annotation.Resource private OnboardingClient onboardingClient; - public static void main(String[] args) { - - CsarOperation csarOperation = new CsarOperation(); - csarOperation.init(); - - String csarUuid = "70025CF6081B489CA7B1CBA583D5278D"; - Either, StorageOperationStatus> csar = csarOperation.getCsar(csarUuid, null); - System.out.println(csar.left().value()); - - } - @PostConstruct public void init() { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/OnboardingClient.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/OnboardingClient.java index ed0b43e38e..5aabc6402e 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/OnboardingClient.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/OnboardingClient.java @@ -23,6 +23,7 @@ package org.openecomp.sdc.be.model.operations.impl; import fj.data.Either; import java.util.Map; import java.util.Properties; +import lombok.NoArgsConstructor; import org.apache.http.HttpStatus; import org.openecomp.sdc.be.config.Configuration.OnboardingConfig; import org.openecomp.sdc.be.config.ConfigurationManager; @@ -33,6 +34,7 @@ import org.openecomp.sdc.common.http.client.api.HttpResponse; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.zip.ZipUtils; +@NoArgsConstructor @org.springframework.stereotype.Component("onboarding-client") public class OnboardingClient { @@ -44,20 +46,6 @@ public class OnboardingClient { downloadCsarHeaders.put("Accept", "application/octet-stream"); } - public OnboardingClient() { - super(); - } - - public static void main(String[] args) { - - OnboardingClient csarOperation = new OnboardingClient(); - - String csarUuid = "70025CF6081B489CA7B1CBA583D5278D"; - Either, StorageOperationStatus> csar = csarOperation.getCsar(csarUuid, null); - System.out.println(csar.left().value()); - - } - public Either, StorageOperationStatus> getCsar(String csarUuid, String userId) { String url = buildDownloadCsarUrl() + "/" + csarUuid; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java index 419adb8b70..f626c1d629 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java @@ -118,21 +118,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe private static final String PROPERTY = "Property"; private static final String UPDATE_DATA_TYPE = "UpdateDataType"; - public static void main(String[] args) { - - List buildFunctionPatterns = buildFunctionPatterns(); - - for (Pattern pattern : buildFunctionPatterns) { - - String[] strs = { "str_replace", "{ str_replace:", " {str_replace:", " { str_replace:", "{str_replace:" }; - for (String str : strs) { - Matcher m = pattern.matcher(str); - System.out.println(pattern.pattern() + " " + str + " " + m.find()); - } - } - - } - @Autowired public PropertyOperation(HealingJanusGraphGenericDao janusGraphGenericDao, DerivedFromOperation derivedFromOperation) { this.janusGraphGenericDao = janusGraphGenericDao; @@ -141,27 +126,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe private static Logger log = Logger.getLogger(PropertyOperation.class.getName()); - /** - * The value of functions is in a json format. Build pattern for each function name - * - * { str_replace: .... } {str_replace: .... } {str_replace: .... } { str_replace: .... } - * - * @return - */ - private static List buildFunctionPatterns() { - - List functionPatterns = new ArrayList<>(); - - String[] functions = { "get_input", "get_property" }; - - for (String function : functions) { - Pattern pattern = Pattern.compile("^[ ]*\\{[ ]*" + function + ":"); - functionPatterns.add(pattern); - } - - return functionPatterns; - } - public PropertyDefinition convertPropertyDataToPropertyDefinition(PropertyData propertyDataResult, String propertyName, String resourceId) { log.debug("The object returned after create property is {}", propertyDataResult); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/version/ApplicationVersionException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/version/ApplicationVersionException.java index 9dca0389f7..58037192f7 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/version/ApplicationVersionException.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/version/ApplicationVersionException.java @@ -24,10 +24,6 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.TechnicalException public class ApplicationVersionException extends TechnicalException { - public ApplicationVersionException(String message, Throwable cause) { - super(message, cause); - } - public ApplicationVersionException(String message) { super(message); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CombinationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CombinationTest.java index 2f63c2310e..13c82c6933 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CombinationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CombinationTest.java @@ -24,9 +24,6 @@ import org.junit.Test; import org.mockito.Mockito; import org.openecomp.sdc.be.ui.model.UiCombination; -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; -import static org.hamcrest.MatcherAssert.assertThat; - public class CombinationTest { @Test @@ -35,8 +32,4 @@ public class CombinationTest { new Combination(uiComb); } - @Test - public void shouldHaveValidGettersAndSetters() { - assertThat(Combination.class, hasValidGettersAndSetters()); - } -} \ No newline at end of file +} 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 e3d69fdadc..254208e06c 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 @@ -62,27 +62,6 @@ public class PropertyOperationTest extends ModelTestBase { } - /* - * @Test public void addPropertyToResourceTest() { - * - * String propName = "myProp"; PropertyDefinition property = buildPropertyDefinition(); List constraints = buildConstraints(); property.setConstraints(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); - * - * when(janusGraphGenericDao.createNode((PropertyData)anyObject(), eq(PropertyData.class))).thenReturn(either); when(janusGraphGenericDao.createRelation((GraphNode)anyObject(), (GraphNode)anyObject(), eq(GraphEdgeLabels.PROPERTY), - * anyMap())).thenReturn(relationResult); - * - * 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(); - * - * List originalConstraints = property.getConstraints(); List propertyConstraintsResult = propertyDefinition.getConstraints(); assertEquals(propertyConstraintsResult.size(), originalConstraints.size()); - * - * } - */ private PropertyDefinition buildPropertyDefinition() { PropertyDefinition property = new PropertyDefinition(); property.setDefaultValue("10"); @@ -91,60 +70,6 @@ public class PropertyOperationTest extends ModelTestBase { return property; } - @Test - public void addPropertiesToGraphTableTest() { - - // Map properties = new HashMap(); - // String propName = "myProp"; - // PropertyDefinition property = buildPropertyDefinition(); - // - // List constraints = buildConstraints(); - // property.setConstraints(constraints); - // - // properties.put(propName, property); - // - // GraphNeighbourTable graphNeighbourTable = new GraphNeighbourTable(); - // ResourceData resourceData = new ResourceData(); - // String resourceName = "my-resource"; - // String resourceVersion = "1.0"; - // String resourceId = resourceName + "." + resourceVersion; - // resourceData.setUniqueId(resourceId); - // int resourceIndex = graphNeighbourTable.addNode(resourceData); - // - // heatParametersOperation.addPropertiesToGraphTable(properties, - // graphNeighbourTable, resourceIndex, resourceId); - // - // assertEquals(2, graphNeighbourTable.getNodes().size()); - // assertEquals(1, graphNeighbourTable.getDirectedEdges().size()); - // List nodes = graphNeighbourTable.getNodes(); - // boolean nodeFound = false; - // for (GraphNode neo4jNode : nodes) { - // if (neo4jNode instanceof PropertyData) { - // PropertyData propertyData = (PropertyData)neo4jNode; - // assertEquals("check property unique id", resourceId + "." + propName, - // propertyData.getUniqueId()); - // assertEquals(property.getDescription(), - // propertyData.getPropertyDataDefinition().getDescription()); - // nodeFound = true; - // } - // } - // assertEquals("looking for PropertyData object in table", true, - // nodeFound); - // - // NodeRelation nodeRelation = - // graphNeighbourTable.getDirectedEdges().get(0); - // assertEquals("check from index to index edge", 0, - // nodeRelation.getFromIndex()); - // assertEquals("check from index to index edge", 1, - // nodeRelation.getToIndex()); - // assertEquals("check edge type", - // GraphEdgePropertiesDictionary.PROPERTY, - // nodeRelation.getEdge().getEdgeType()); - // assertEquals("check propert name on edge", true, - // nodeRelation.getEdge().getProperties().values().contains(propName)); - } - @Test public void convertConstraintsTest() { @@ -516,16 +441,6 @@ public class PropertyOperationTest extends ModelTestBase { return new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null); } - - @Test - public void testMain() throws Exception { - String[] args = new String[] { "" }; - - // default test - PropertyOperation.main(args); - } - - @Test public void testConvertPropertyDataToPropertyDefinition() throws Exception { PropertyOperation testSubject; -- cgit 1.2.3-korg