aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java/org/openecomp
diff options
context:
space:
mode:
authorSindhuri.A <arcot.sindhuri@huawei.com>2018-10-30 15:02:17 +0530
committerTal Gitelman <tal.gitelman@att.com>2018-11-01 10:29:21 +0000
commit25d3b2e7e416997838fe44d31f13df83a848a5f8 (patch)
tree8e6d046c6556f6fa8fa10d9c0be093dda597675e /catalog-model/src/test/java/org/openecomp
parent63b4f6532cd9cadef8d6c53a210f66142158d601 (diff)
UT-ToscaOperationFacade 3
UT for catalog be ToscaOperationFacade class Issue-ID: SDC-1775 Change-Id: I72849bcaa5b86bf77c41ce8aa320e32ca12be719 Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'catalog-model/src/test/java/org/openecomp')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
index 91e83348ca..85019e6f1b 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
@@ -266,6 +266,53 @@ public class ToscaOperationFacadeTest {
assertThat(result.isLeft());
}
+ @Test
+ public void testValidateCompExists() {
+ Either<Boolean, StorageOperationStatus> result;
+ String componentId = "componentId";
+ GraphVertex graphVertex = getTopologyTemplateVertex();
+ when(titanDaoMock.getVertexById(componentId, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex));
+ result = testInstance.validateComponentExists(componentId);
+ assertEquals(true, result.left().value());
+ }
+
+ @Test
+ public void testValidateCompExists_NotFound() {
+ Either<Boolean, StorageOperationStatus> result;
+ String componentId = "componentId";
+ when(titanDaoMock.getVertexById(componentId, JsonParseFlagEnum.NoParse)).thenReturn(Either.right(TitanOperationStatus.NOT_FOUND));
+ result = testInstance.validateComponentExists(componentId);
+ assertEquals(false, result.left().value());
+ }
+
+ @Test
+ public void testValidateToscaResourceNameExists() {
+ Either<Boolean, StorageOperationStatus> result;
+ String templateName = "templateName";
+ Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
+ properties.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, templateName);
+ List<GraphVertex> graphVertexList = new ArrayList<>();
+ GraphVertex graphVertex = getTopologyTemplateVertex();
+ graphVertexList.add(graphVertex);
+ when(titanDaoMock.getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(graphVertexList));
+ result = testInstance.validateToscaResourceNameExists(templateName);
+ assertEquals(true, result.left().value());
+ }
+
+ @Test
+ public void testValidateToscaResourceNameExists_false() {
+ Either<Boolean, StorageOperationStatus> result;
+ String templateName = "templateName";
+ Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
+ properties.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, templateName);
+ List<GraphVertex> graphVertexList = new ArrayList<>();
+ GraphVertex graphVertex = getTopologyTemplateVertex();
+ graphVertexList.add(graphVertex);
+ when(titanDaoMock.getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(TitanOperationStatus.NOT_FOUND));
+ result = testInstance.validateToscaResourceNameExists(templateName);
+ assertEquals(false, result.left().value());
+ }
+
private Either<PolicyDefinition, StorageOperationStatus> associatePolicyToComponentWithStatus(StorageOperationStatus status) {
PolicyDefinition policy = new PolicyDefinition();
String componentId = "componentId";