diff options
author | Sindhuri.A <arcot.sindhuri@huawei.com> | 2018-10-27 19:04:37 +0530 |
---|---|---|
committer | Michael Lando <michael.lando@intl.att.com> | 2018-10-29 18:06:28 +0000 |
commit | 2ea62aedb019a4a62ccb93c717695a7efddae41e (patch) | |
tree | 05ce5b1e36c5ded2ec8616241feed1555bf48abe /catalog-model/src/test | |
parent | 2ce1a664e36a787b566d252c0604049c0b8d2652 (diff) |
UT-ToscaOperationFacade 2
UT for catalog be ToscaOperationFacade class
Issue-ID: SDC-1775
Change-Id: I2f66bc665d2b50279ba1fb46f79ca3423311afd0
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java | 46 |
1 files changed, 46 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 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<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class); + properties.put(GraphPropertyEnum.CSAR_UUID, csarUUID); + List<GraphVertex> 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<GraphPropertyEnum, Object> 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<Resource, StorageOperationStatus> result; + String toscaResourceName = "resourceName"; + String uniqueId = "uniqueId"; + GraphVertex graphVertex = getTopologyTemplateVertex(); + graphVertex.setJsonMetadataField(JsonPresentationFields.VERSION, "1.0"); + graphVertex.setUniqueId(uniqueId); + List<GraphVertex> vertexList = new ArrayList<>(); + vertexList.add(graphVertex); + Map<GraphPropertyEnum, Object> 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<PolicyDefinition, StorageOperationStatus> associatePolicyToComponentWithStatus(StorageOperationStatus status) { PolicyDefinition policy = new PolicyDefinition(); String componentId = "componentId"; |