Unit tests - openecomp-sdc-vsp-manager 42/93942/3
authorTomasz Golabek <tomasz.golabek@nokia.com>
Tue, 20 Aug 2019 09:39:23 +0000 (11:39 +0200)
committerPiotr Darosz <piotr.darosz@nokia.com>
Wed, 21 Aug 2019 06:12:44 +0000 (06:12 +0000)
Tests for org.openecomp.sdc.vendorsoftwareproduct

Change-Id: I737b8ca71219c3e241f902a34419c685435e467c
Issue-ID: SDC-2326
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactoryTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResultTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResultTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingDataTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponseTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResultTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructureTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTrackerTest.java [new file with mode: 0644]

index 1dbb1d7..4d705f8 100644 (file)
             <version>${powermock.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.google.code.bean-matchers</groupId>
+            <artifactId>bean-matchers</artifactId>
+            <version>${bean-matchers.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.openecomp.sdc</groupId>
             <artifactId>openecomp-sdc-activity-log-api</artifactId>
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactoryTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactoryTest.java
new file mode 100644 (file)
index 0000000..7d59215
--- /dev/null
@@ -0,0 +1,32 @@
+/*-
+ * ============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.vendorsoftwareproduct;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class ComponentManagerFactoryTest {
+
+    @Test
+    public void instanceShouldNotBeNull() {
+        assertNotNull(ComponentManagerFactory.getInstance());
+    }
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResultTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResultTest.java
new file mode 100644 (file)
index 0000000..543f05c
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============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.vendorsoftwareproduct.types;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.Set;
+import org.junit.Test;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+public class ComponentValidationResultTest {
+    @Test
+    public void componentShouldBeNotValidWhenNotNull() {
+        Set<CompositionEntityValidationData> validationData = Collections.emptySet();
+        ComponentValidationResult componentValidationResult = new ComponentValidationResult(validationData);
+        assertEquals(componentValidationResult.getValidationData(), validationData);
+        assertFalse(componentValidationResult.isValid());
+    }
+
+    @Test
+    public void componentShouldBeValidWhenNull() {
+        ComponentValidationResult componentValidationResult = new ComponentValidationResult(null);
+        assertTrue(componentValidationResult.isValid());
+    }
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResultTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResultTest.java
new file mode 100644 (file)
index 0000000..e01e062
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============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.vendorsoftwareproduct.types;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.Set;
+import org.junit.Test;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+public class DeploymentFlavorValidationResultTest {
+    @Test
+    public void flavorShouldBeNotValidWhenNotNull() {
+        Set<CompositionEntityValidationData> validationData = Collections.emptySet();
+        DeploymentFlavorValidationResult componentValidationResult = new DeploymentFlavorValidationResult(validationData);
+        assertEquals(componentValidationResult.getValidationData(), validationData);
+        assertFalse(componentValidationResult.isValid());
+    }
+
+    @Test
+    public void flavorShouldBeValidWhenNull() {
+        DeploymentFlavorValidationResult componentValidationResult = new DeploymentFlavorValidationResult(null);
+        assertTrue(componentValidationResult.isValid());
+    }
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingDataTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingDataTest.java
new file mode 100644 (file)
index 0000000..2061ead
--- /dev/null
@@ -0,0 +1,32 @@
+/*-
+ * ============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.vendorsoftwareproduct.types;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class LicensingDataTest {
+    @Test
+    public void shouldHaveValidGettersAndSetters() {
+        assertThat(LicensingData.class, hasValidGettersAndSetters());
+    }
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponseTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponseTest.java
new file mode 100644 (file)
index 0000000..21db918
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============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.vendorsoftwareproduct.types;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+
+public class OrchestrationTemplateActionResponseTest {
+
+    private static final String ERROR = "error";
+    private static final String TEST = "test";
+
+    @Test
+    public void shouldHaveValidGettersAndSetters() {
+        assertThat(OrchestrationTemplateActionResponse.class, hasValidGettersAndSettersExcluding("errors"));
+    }
+
+    @Test
+    public void shouldAddErrorToMap() {
+        OrchestrationTemplateActionResponse orchestrationTemplateActionResponse = new OrchestrationTemplateActionResponse();
+        orchestrationTemplateActionResponse.addErrorMessageToMap(TEST, ERROR, ErrorLevel.ERROR);
+        assertEquals(orchestrationTemplateActionResponse.getStatus(), UploadFileStatus.Failure);
+        assertEquals(orchestrationTemplateActionResponse.getErrors().get(TEST).get(0).getMessage(), ERROR);
+    }
+
+    @Test
+    public void shouldAddErrorToMapButLeaveAStatusUnchanged() {
+        OrchestrationTemplateActionResponse orchestrationTemplateActionResponse = new OrchestrationTemplateActionResponse();
+        orchestrationTemplateActionResponse.addErrorMessageToMap(TEST, ERROR, ErrorLevel.INFO);
+        assertEquals(orchestrationTemplateActionResponse.getStatus(), UploadFileStatus.Success);
+        assertEquals(orchestrationTemplateActionResponse.getErrors().get(TEST).get(0).getMessage(), ERROR);
+    }
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResultTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResultTest.java
new file mode 100644 (file)
index 0000000..bc0ed11
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============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.vendorsoftwareproduct.types;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.Set;
+import org.junit.Test;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+public class QuestionnaireValidationResultTest {
+    @Test
+    public void questionnaireShouldBeNotValidWhenNotNull() {
+        Set<CompositionEntityValidationData> validationData = Collections.emptySet();
+        QuestionnaireValidationResult questionnaireValidationResult = new QuestionnaireValidationResult(validationData);
+        assertEquals(questionnaireValidationResult.getValidationData(), validationData);
+        assertFalse(questionnaireValidationResult.isValid());
+    }
+
+    @Test
+    public void questionnaireShouldBeValidWhenNull() {
+        QuestionnaireValidationResult questionnaireValidationResult = new QuestionnaireValidationResult(null);
+        assertTrue(questionnaireValidationResult.isValid());
+    }
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructureTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructureTest.java
new file mode 100644 (file)
index 0000000..6cd0b44
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============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.vendorsoftwareproduct.types;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import org.junit.Test;
+
+public class UploadFileStructureTest {
+
+    private static final String TEST = "test";
+
+    @Test
+    public void shouldHaveValidGettersAndSetters() {
+        assertThat(UploadFileStructure.class, hasValidGettersAndSetters());
+    }
+
+    @Test
+    public void shouldAddFileToList() {
+        UploadFileStructure uploadFileStructure = new UploadFileStructure();
+        uploadFileStructure.setFileNames(new ArrayList<>());
+        uploadFileStructure.addNewFileToList(TEST);
+        assertEquals(uploadFileStructure.getFileNames().get(0), TEST);
+    }
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTrackerTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTrackerTest.java
new file mode 100644 (file)
index 0000000..ec13a4d
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * ============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.vendorsoftwareproduct.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class ComponentDependencyTrackerTest {
+
+    @Test
+    public void shouldAddNonCyclicDependency() {
+        ComponentDependencyTracker componentDependencyTracker = new ComponentDependencyTracker();
+        componentDependencyTracker.addDependency("TEST1", "TEST2");
+        assertFalse(componentDependencyTracker.isCyclicDependencyPresent());
+    }
+
+    @Test
+    public void shouldAddCyclicDependency() {
+        ComponentDependencyTracker componentDependencyTracker = new ComponentDependencyTracker();
+        componentDependencyTracker.addDependency("TEST1", "TEST2");
+        componentDependencyTracker.addDependency("TEST2", "TEST1");
+        assertTrue(componentDependencyTracker.isCyclicDependencyPresent());
+    }
+}
\ No newline at end of file