summaryrefslogtreecommitdiffstats
path: root/common-be/src/test/java/org
diff options
context:
space:
mode:
authorxuegao <xue.gao@intl.att.com>2021-03-25 16:00:32 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-03-26 19:16:24 +0000
commite83d137179fa3c532c191f89f9e6cdd53b0778c7 (patch)
treef397a70f4096c068b24b55eb52a93f6789d1523b /common-be/src/test/java/org
parent021978494010df2a4258845b2ada19967869afd1 (diff)
Improve test coverage
Add unit tests to improve test coverage. Issue-ID: SDC-3428 Change-Id: Ifd9e6eb25fa3ec9f4f93d283277574120edff835 Signed-off-by: xuegao <xue.gao@intl.att.com>
Diffstat (limited to 'common-be/src/test/java/org')
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java43
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java63
2 files changed, 74 insertions, 32 deletions
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java b/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java
new file mode 100644
index 0000000000..cf31223973
--- /dev/null
+++ b/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 AT&T Intellectual Property. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.config;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class NonManoFolderTypeTest {
+
+ @Test
+ public void getPathTest() {
+ NonManoFolderType instance = new NonManoFolderType();
+ instance.setType("type");
+ instance.setLocation("location");
+ assertEquals("Artifacts/type/location", instance.getPath());
+ }
+
+ @Test
+ public void isValidTest() {
+ NonManoFolderType instance = new NonManoFolderType();
+ instance.setType("type");
+ instance.setLocation("location");
+ assertTrue(instance.isValid());
+ }
+} \ No newline at end of file
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java
index 9d98cf237d..6177ada28d 100644
--- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java
+++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java
@@ -20,7 +20,11 @@
package org.openecomp.sdc.be.datatypes.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class ComponentTypeEnumTest {
@@ -30,48 +34,43 @@ public class ComponentTypeEnumTest {
@Test
public void testGetValue() throws Exception {
- ComponentTypeEnum testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getValue();
+ ComponentTypeEnum testSubject = createTestSubject();
+ assertEquals("Product", testSubject.getValue());
}
@Test
- public void testGetNodeType() throws Exception {
- ComponentTypeEnum testSubject;
- NodeTypeEnum result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNodeType();
+ public void testGetNodeType() {
+ assertEquals(NodeTypeEnum.Resource, ComponentTypeEnum.RESOURCE.getNodeType());
+ assertEquals(NodeTypeEnum.Product, ComponentTypeEnum.PRODUCT.getNodeType());
+ assertEquals(NodeTypeEnum.Service, ComponentTypeEnum.SERVICE.getNodeType());
+ assertEquals(NodeTypeEnum.ResourceInstance, ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType());
+ assertThrows(UnsupportedOperationException.class, () -> {
+ ComponentTypeEnum.SERVICE_INSTANCE.getNodeType();
+ });
}
@Test
- public void testFindByValue() throws Exception {
- String value = "";
- ComponentTypeEnum result;
-
- // default test
- result = ComponentTypeEnum.findByValue(value);
+ public void testFindByValue() {
+ assertNull(ComponentTypeEnum.findByValue(""));
+ assertEquals(ComponentTypeEnum.RESOURCE, ComponentTypeEnum.findByValue("Resource"));
+ assertEquals(ComponentTypeEnum.SERVICE, ComponentTypeEnum.findByValue("Service"));
+ assertEquals(ComponentTypeEnum.PRODUCT, ComponentTypeEnum.findByValue("Product"));
}
@Test
- public void testFindByParamName() throws Exception {
- String paramName = "";
- ComponentTypeEnum result;
-
- // default test
- result = ComponentTypeEnum.findByParamName(paramName);
+ public void testFindByParamName() {
+ assertNull(ComponentTypeEnum.findByParamName(""));
+ assertEquals(ComponentTypeEnum.RESOURCE, ComponentTypeEnum.findByParamName("resources"));
+ assertEquals(ComponentTypeEnum.SERVICE, ComponentTypeEnum.findByParamName("services"));
+ assertEquals(ComponentTypeEnum.PRODUCT, ComponentTypeEnum.findByParamName("products"));
}
@Test
- public void testFindParamByType() throws Exception {
- ComponentTypeEnum type = null;
- String result;
-
- // default test
- result = ComponentTypeEnum.findParamByType(type);
+ public void testFindParamByType() {
+ assertNull(ComponentTypeEnum.findParamByType(null));
+ assertNull(ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE_INSTANCE));
+ assertEquals("resources", ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE));
+ assertEquals("services", ComponentTypeEnum.findParamByType(ComponentTypeEnum.SERVICE));
+ assertEquals("products", ComponentTypeEnum.findParamByType(ComponentTypeEnum.PRODUCT));
}
}