From 25d3b2e7e416997838fe44d31f13df83a848a5f8 Mon Sep 17 00:00:00 2001 From: "Sindhuri.A" Date: Tue, 30 Oct 2018 15:02:17 +0530 Subject: UT-ToscaOperationFacade 3 UT for catalog be ToscaOperationFacade class Issue-ID: SDC-1775 Change-Id: I72849bcaa5b86bf77c41ce8aa320e32ca12be719 Signed-off-by: Sindhuri.A --- .../operations/ToscaOperationFacadeTest.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) 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 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 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 result; + String templateName = "templateName"; + Map properties = new EnumMap<>(GraphPropertyEnum.class); + properties.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, templateName); + List 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 result; + String templateName = "templateName"; + Map properties = new EnumMap<>(GraphPropertyEnum.class); + properties.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, templateName); + List 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 associatePolicyToComponentWithStatus(StorageOperationStatus status) { PolicyDefinition policy = new PolicyDefinition(); String componentId = "componentId"; -- cgit 1.2.3-korg