aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asdctool/pom.xml7
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRow.java68
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentRow.java95
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java123
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java81
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java33
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java33
7 files changed, 317 insertions, 123 deletions
diff --git a/asdctool/pom.xml b/asdctool/pom.xml
index 56d822e95f..ced840d173 100644
--- a/asdctool/pom.xml
+++ b/asdctool/pom.xml
@@ -473,6 +473,13 @@
</dependency>
<dependency>
+ <groupId>com.google.code.bean-matchers</groupId>
+ <artifactId>bean-matchers</artifactId>
+ <version>${bean-matchers.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.19.0</version>
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRow.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRow.java
new file mode 100644
index 0000000000..f2ee154644
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRow.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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;
+
+public class ComponentInstanceRow {
+ private String uniqueId;
+ private String name;
+ private String originUid;
+ private String originType;
+ private String containerUid;
+
+ public String getContainerUid() {
+ return containerUid;
+ }
+
+ public void setContainerUid(String containerUid) {
+ this.containerUid = containerUid;
+ }
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOriginUid() {
+ return originUid;
+ }
+
+ public void setOriginUid(String componentUid) {
+ this.originUid = componentUid;
+ }
+
+ public String getOriginType() {
+ return originType;
+ }
+
+ public void setOriginType(String originType) {
+ this.originType = originType;
+ }
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentRow.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentRow.java
new file mode 100644
index 0000000000..795810c47c
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ComponentRow.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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;
+
+public class ComponentRow {
+ private String uniqueId;
+ private String type;
+ private String name;
+ private String toscaResourceName;
+ private String resourceType;
+ private String version;
+ private Boolean isDeleted;
+ private Boolean hasNonCalculatedReqCap;
+
+ public Boolean getHasNonCalculatedReqCap() {
+ return hasNonCalculatedReqCap;
+ }
+
+ public void setHasNonCalculatedReqCap(Boolean hasNonCalculatedReqCap) {
+ this.hasNonCalculatedReqCap = hasNonCalculatedReqCap;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getToscaResourceName() {
+ return toscaResourceName;
+ }
+
+ public void setToscaResourceName(String toscaResourceName) {
+ this.toscaResourceName = toscaResourceName;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public Boolean getIsDeleted() {
+ return isDeleted;
+ }
+
+ public void setIsDeleted(Boolean deleted) {
+ this.isDeleted = deleted;
+ }
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
index 2aed83c823..1b065c2795 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
@@ -241,127 +241,4 @@ public class GraphMLDataAnalyzer {
return res;
}
- private class ComponentRow {
-
- private String uniqueId;
- private String type;
- private String name;
- private String toscaResourceName;
- private String resourceType;
- private String version;
- private Boolean isDeleted;
- private Boolean hasNonCalculatedReqCap;
-
- public Boolean getHasNonCalculatedReqCap() {
- return hasNonCalculatedReqCap;
- }
-
- public void setHasNonCalculatedReqCap(Boolean hasNonCalculatedReqCap) {
- this.hasNonCalculatedReqCap = hasNonCalculatedReqCap;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getToscaResourceName() {
- return toscaResourceName;
- }
-
- public void setToscaResourceName(String toscaResourceName) {
- this.toscaResourceName = toscaResourceName;
- }
-
- public String getResourceType() {
- return resourceType;
- }
-
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public Boolean getIsDeleted() {
- return isDeleted;
- }
-
- public void setIsDeleted(Boolean deleted) {
- this.isDeleted = deleted;
- }
- }
-
- private class ComponentInstanceRow {
- private String uniqueId;
- private String name;
- private String originUid;
- private String originType;
- private String containerUid;
-
- public String getContainerUid() {
- return containerUid;
- }
-
- public void setContainerUid(String containerUid) {
- this.containerUid = containerUid;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getOriginUid() {
- return originUid;
- }
-
- public void setOriginUid(String componentUid) {
- this.originUid = componentUid;
- }
-
- public String getOriginType() {
- return originType;
- }
-
- public void setOriginType(String originType) {
- this.originType = originType;
- }
- }
}
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