diff options
author | Sindhuri.A <arcot.sindhuri@huawei.com> | 2018-11-16 12:37:00 +0530 |
---|---|---|
committer | Tal Gitelman <tal.gitelman@att.com> | 2018-11-19 17:26:45 +0000 |
commit | 79279b3e6e0cd5189d4b3c4b78a0a8253d1d2456 (patch) | |
tree | 275fa7216f25a6aaf4c1507c11f4db2d9f641c80 /catalog-model | |
parent | 8ca3eb9101c591042c0b993cb5be65ecfa8ef476 (diff) |
UT-AdditionalInfoOperation2
UT for AdditionalInformationOperation class
Issue-ID: SDC-1775
Change-Id: I971043f92b6566b121f3d31201ce29148d7d2b85
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'catalog-model')
2 files changed, 48 insertions, 4 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperation.java index 349ee289b7..ebec8b134b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperation.java @@ -55,6 +55,11 @@ import java.util.Map.Entry; @Component("additional-information-operation") public class AdditionalInformationOperation implements IAdditionalInformationOperation { + private static final Logger log = Logger.getLogger(AdditionalInformationOperation.class.getName()); + + @javax.annotation.Resource + private TitanGenericDao titanGenericDao; + private static final String GOING_TO_EXECUTE_COMMIT_ON_GRAPH = "Going to execute commit on graph."; private static final String GOING_TO_EXECUTE_ROLLBACK_ON_GRAPH = "Going to execute rollback on graph."; private static final String ADDITIONAL_INFORMATION_OF = "additional information of "; @@ -64,10 +69,6 @@ public class AdditionalInformationOperation implements IAdditionalInformationOpe super(); } - private static final Logger log = Logger.getLogger(AdditionalInformationOperation.class.getName()); - - @javax.annotation.Resource - private TitanGenericDao titanGenericDao; @Override public Either<AdditionalInformationDefinition, TitanOperationStatus> addAdditionalInformationParameter(NodeTypeEnum nodeType, String componentId, String key, String value) { diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java index 8bb4a2940d..6fd04c18bb 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java @@ -20,14 +20,19 @@ package org.openecomp.sdc.be.model.operations.impl; +import com.thinkaurelius.titan.core.TitanEdge; +import com.thinkaurelius.titan.core.TitanGraph; import com.thinkaurelius.titan.core.TitanVertex; import fj.data.Either; import static org.assertj.core.api.Assertions.assertThat; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; +import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.dao.titan.TitanGenericDao; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; @@ -39,6 +44,8 @@ import org.openecomp.sdc.be.resources.data.UserData; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.Iterator; + import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.eq; @@ -103,6 +110,42 @@ public class AdditionalInformationOperationTest extends ModelTestBase { assertTrue(result.isRight()); } + @Test + public void testDelAdditionalInfoParam_InvalidId() { + Either<AdditionalInformationDefinition, TitanOperationStatus> result; + String id = "uid"; + String componentId = "componentId"; + TitanGraph graph = titanDao.getGraph().left().value(); + TitanVertex v1 = graph.addVertex(); + v1.property("uid", componentId); + v1.property(GraphPropertiesDictionary.LABEL.getProperty(), "resource"); + TitanVertex v2 = graph.addVertex(); + v2.property(id,id); + + TitanEdge addEdge = v1.addEdge(GraphEdgeLabels.ADDITIONAL_INFORMATION.getProperty(), v2); + addEdge.property("edgeProp", "resource"); + graph.tx().commit(); + + result = additionalInformationOperation.deleteAdditionalInformationParameter(NodeTypeEnum.Resource, componentId, id); + clearGraph(); + assertTrue(result.isRight()); + } + + private void clearGraph() { + Either<TitanGraph, TitanOperationStatus> graphResult = titanDao.getGraph(); + TitanGraph graph = graphResult.left().value(); + + Iterable<TitanVertex> vertices = graph.query().vertices(); + if (vertices != null) { + Iterator<TitanVertex> iterator = vertices.iterator(); + while (iterator.hasNext()) { + TitanVertex vertex = iterator.next(); + vertex.remove(); + } + } + titanDao.commit(); + } + private UserData deleteAndCreateUser(String userId, String firstName, String lastName) { UserData userData = new UserData(); userData.setUserId(userId); |