diff options
Diffstat (limited to 'asdctool/src/test/java/org')
3 files changed, 147 insertions, 0 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java index 8a6c9afa12..0ea4484ba4 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java @@ -27,11 +27,14 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; +import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; @@ -59,6 +62,9 @@ public class ArtifactUuidFixTest { private ArtifactUuidFix test; @Mock + private Component component; + + @Mock private JanusGraphDao janusGraphDao; @Mock @@ -214,4 +220,79 @@ public class ArtifactUuidFixTest { result = test.doFix(fixComponent, runMode); assertEquals(false,result); } + + + @Test + public void testDoFixVfWithFixMode() { + String fixComponent = ""; + String runMode = "fix"; + String uniqueId = "uniqueId"; + boolean result; + fixComponent = "vf_only"; + Map<GraphPropertyEnum, Object> hasProps1 = new HashMap<>(); + hasProps1.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); + hasProps1.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + List<GraphVertex> list = new ArrayList<>(); + GraphVertex graphVertex = new GraphVertex(); + graphVertex.setVertex(vertex); + graphVertex.setUniqueId(uniqueId); + graphVertex.setMetadataProperties(hasProps1); + list.add(graphVertex); + when(janusGraphDao.getByCriteria(VertexTypeEnum.NODE_TYPE, hasProps1)).thenReturn(Either.left(list)); + + Map<GraphPropertyEnum, Object> hasProps2 = new HashMap<>(); + hasProps2.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); + hasProps2.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF); + hasProps2.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + when(janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps2)).thenReturn(Either.left(list)); + + Map<GraphPropertyEnum, Object> hasProps3 = new HashMap<>(); + hasProps3.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name()); + hasProps3.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + when(janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps3)).thenReturn(Either.left(list)); + + Map<GraphPropertyEnum, Object> hasProps = new HashMap<>(); + hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); + hasProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF.name()); + Map<GraphPropertyEnum, Object> hasNotProps = new HashMap<>(); + hasNotProps.put(GraphPropertyEnum.IS_DELETED, true); + when(janusGraphDao + .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps, hasNotProps, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(list)); + Resource resource = new Resource(); + resource.setName(uniqueId); + Map<String, ArtifactDefinition> deployArtifact = new HashMap<>(); + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType()); + artifactDefinition.setUniqueId("one.two"); + artifactDefinition.setArtifactUUID("one.two"); + deployArtifact.put("two", artifactDefinition); + resource.setDeploymentArtifacts(deployArtifact); + List<GroupDefinition> groups = new ArrayList<>(); + GroupDefinition groupDefinition = new GroupDefinition(); + groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE); + List<String> artifacts = new ArrayList<>(); + artifacts.add("one.two"); + groupDefinition.setArtifacts(artifacts); + groupDefinition.setArtifactsUuid(artifacts); + groups.add(groupDefinition); + resource.setGroups(groups); + resource.setUniqueId(uniqueId); + resource.setComponentType(ComponentTypeEnum.SERVICE_INSTANCE); + + when(toscaOperationFacade.getToscaElement(graphVertex.getUniqueId())).thenReturn(Either.left(resource)); + when(toscaOperationFacade.getToscaFullElement(Mockito.anyString())).thenReturn(Either.left(component)); + when(component.getUniqueId()).thenReturn(uniqueId); + when(toscaOperationFacade.getToscaElement(Mockito.anyString(), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(component)); + when(janusGraphDao.getVertexById(uniqueId, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex)); + when(janusGraphDao.getChildVertex(graphVertex, EdgeLabelEnum.GROUPS, JsonParseFlagEnum.ParseJson)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + when(janusGraphDao.getChildVertex(graphVertex, EdgeLabelEnum.DEPLOYMENT_ARTIFACTS, JsonParseFlagEnum.ParseJson)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + when(janusGraphDao.getChildVertex(graphVertex, EdgeLabelEnum.TOSCA_ARTIFACTS, JsonParseFlagEnum.ParseJson)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + + List<Service> serviceList = new ArrayList<>(); + serviceList.add(service); + + result = test.doFix(fixComponent, runMode); + assertEquals(true, result); + } + } diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java new file mode 100644 index 0000000000..8b8f9893f6 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.asdctool.impl; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class ComponentInstanceRowTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(ComponentInstanceRow.class, + hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java new file mode 100644 index 0000000000..e5c139c698 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.asdctool.impl; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class ComponentRowTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(ComponentRow.class, + hasValidGettersAndSetters()); + } +}
\ No newline at end of file |