+
+ @Test
+ public void testFindLastCertifiedToscaElementByUUID(){
+ Either<Component, StorageOperationStatus> result;
+ Component component = new Resource();
+ List<GraphVertex> list = new ArrayList<>();
+ GraphVertex graphVertex = getTopologyTemplateVertex();
+ list.add(graphVertex);
+ Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class);
+ props.put(GraphPropertyEnum.UUID, component.getUUID());
+ props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+ TopologyTemplate toscaElement = new TopologyTemplate();
+ toscaElement.setComponentType(ComponentTypeEnum.RESOURCE);
+ when(topologyTemplateOperationMock.getToscaElement(ArgumentMatchers.eq(graphVertex),any(ComponentParametersView.class))).thenReturn(Either.left(toscaElement));
+ when(titanDaoMock.getByCriteria(ModelConverter.getVertexType(component), props)).thenReturn(Either.left(list));
+ result = testInstance.findLastCertifiedToscaElementByUUID(component);
+ Component resultComp = result.left().value();
+ assertEquals(resultComp.getToscaType(),ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue());
+ }
+
+ @Test
+ public void testLatestComponentByToscaResourceName(){
+ Either<Component, StorageOperationStatus> result;
+ TopologyTemplate toscaElement = new TopologyTemplate();
+ toscaElement.setComponentType(ComponentTypeEnum.SERVICE);
+ List<GraphVertex> list = new ArrayList<>();
+ GraphVertex graphVertex = getTopologyTemplateVertex();
+ Map<GraphPropertyEnum, Object> props = new HashMap<>();
+ props.put(GraphPropertyEnum.VERSION, "1.0");
+ graphVertex.setMetadataProperties(props);
+ list.add(graphVertex);
+
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesToMatch.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, "toscaResourceName");
+ propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+ propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+
+ when(titanDaoMock.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(list));
+ when(topologyTemplateOperationMock.getToscaElement(ArgumentMatchers.eq(graphVertex),any(ComponentParametersView.class))).thenReturn(Either.left(toscaElement));
+
+ result = testInstance.getFullLatestComponentByToscaResourceName("toscaResourceName");
+ assertThat(result.isLeft());
+ }
+