From 2ea62aedb019a4a62ccb93c717695a7efddae41e Mon Sep 17 00:00:00 2001 From: "Sindhuri.A" Date: Sat, 27 Oct 2018 19:04:37 +0530 Subject: UT-ToscaOperationFacade 2 UT for catalog be ToscaOperationFacade class Issue-ID: SDC-1775 Change-Id: I2f66bc665d2b50279ba1fb46f79ca3423311afd0 Signed-off-by: Sindhuri.A --- .../operations/ToscaOperationFacadeTest.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'catalog-model') 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 aaa3fba697..91e83348ca 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 @@ -220,6 +220,52 @@ public class ToscaOperationFacadeTest { assertThat(result.isLeft()); } + @Test + public void testValidateCsarUuidUniqueness() { + StorageOperationStatus result; + String csarUUID = "csarUUID"; + Map properties = new EnumMap<>(GraphPropertyEnum.class); + properties.put(GraphPropertyEnum.CSAR_UUID, csarUUID); + List vertexList = new ArrayList<>(); + when(titanDaoMock.getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(vertexList)); + result = testInstance.validateCsarUuidUniqueness(csarUUID); + assertEquals(StorageOperationStatus.ENTITY_ALREADY_EXISTS, result); + } + + @Test + public void testValidateCsarUuidUnique_true() { + StorageOperationStatus result; + String csarUUID = "csarUUID"; + Map properties = new EnumMap<>(GraphPropertyEnum.class); + properties.put(GraphPropertyEnum.CSAR_UUID, csarUUID); + when(titanDaoMock.getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(TitanOperationStatus.NOT_FOUND)); + result = testInstance.validateCsarUuidUniqueness(csarUUID); + assertEquals(StorageOperationStatus.OK, result); + } + + @Test + public void testGetLatestCertiNodeTypeByToscaResourceName() { + Either result; + String toscaResourceName = "resourceName"; + String uniqueId = "uniqueId"; + GraphVertex graphVertex = getTopologyTemplateVertex(); + graphVertex.setJsonMetadataField(JsonPresentationFields.VERSION, "1.0"); + graphVertex.setUniqueId(uniqueId); + List vertexList = new ArrayList<>(); + vertexList.add(graphVertex); + Map props = new EnumMap<>(GraphPropertyEnum.class); + props.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, toscaResourceName); + props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true); + props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + ToscaElement topologyTemplate = new TopologyTemplate(); + topologyTemplate.setComponentType(ComponentTypeEnum.SERVICE); + when(titanDaoMock.getByCriteria(VertexTypeEnum.NODE_TYPE, props, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(vertexList)); + when(titanDaoMock.getVertexById(uniqueId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(graphVertex)); + when(topologyTemplateOperationMock.getToscaElement(any(GraphVertex.class), any(ComponentParametersView.class))).thenReturn(Either.left(topologyTemplate)); + result = testInstance.getLatestCertifiedNodeTypeByToscaResourceName(toscaResourceName); + assertThat(result.isLeft()); + } + private Either associatePolicyToComponentWithStatus(StorageOperationStatus status) { PolicyDefinition policy = new PolicyDefinition(); String componentId = "componentId"; -- cgit 1.2.3-korg