aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorxuegao <xue.gao@intl.att.com>2021-03-25 10:31:08 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-03-25 16:27:18 +0000
commitde9224b1ae01755c7cc46e4bdd1a50c1bc08936e (patch)
tree86369286ebb95412426a73f1e36e317040f6b2d0 /catalog-model
parent7af307919d19761959a61ac64603312b3fb45b58 (diff)
Improve test coverage
Add unit tests to improve test coverage. Issue-ID: SDC-3428 Change-Id: I47da0decd6b6df93ace68b2af586b255ef0b792e Signed-off-by: xuegao <xue.gao@intl.att.com>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java137
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/VersionUtilTest.java70
2 files changed, 158 insertions, 49 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java
index d256cd15c8..92026dd211 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java
@@ -20,14 +20,17 @@
package org.openecomp.sdc.be.model;
-import org.junit.Assert;
-import org.junit.Test;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
public class ComponentInstInputsMapTest {
private ComponentInstInputsMap createTestSubject() {
@@ -35,85 +38,121 @@ public class ComponentInstInputsMapTest {
}
@Test
- public void testGetComponentInstanceInputsMap() throws Exception {
- ComponentInstInputsMap testSubject;
- Map<String, List<ComponentInstancePropInput>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getComponentInstanceInputsMap();
- }
-
- @Test
- public void testSetComponentInstanceInputsMap() throws Exception {
- ComponentInstInputsMap testSubject;
+ public void testComponentInstanceInputsMap() {
+ ComponentInstInputsMap testSubject = createTestSubject();
Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap = null;
// default test
- testSubject = createTestSubject();
testSubject.setComponentInstanceInputsMap(componentInstanceInputsMap);
- }
- @Test
- public void testGetComponentInstanceProperties() throws Exception {
- ComponentInstInputsMap testSubject;
- Map<String, List<ComponentInstancePropInput>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getComponentInstanceProperties();
+ Map<String, List<ComponentInstancePropInput>> result = testSubject.getComponentInstanceInputsMap();
+ assertEquals(0, result.size());
}
@Test
- public void testSetComponentInstancePropInput() throws Exception {
- ComponentInstInputsMap testSubject;
+ public void testComponentInstanceProperties() {
+ ComponentInstInputsMap testSubject = createTestSubject();
Map<String, List<ComponentInstancePropInput>> componentInstanceProperties = new HashMap<>();
-
- // default test
- testSubject = createTestSubject();
testSubject.setComponentInstancePropertiesToPolicies(componentInstanceProperties);
+ Map<String, List<ComponentInstancePropInput>> result = testSubject.getComponentInstanceProperties();
+ assertEquals(0, result.size());
}
@Test
- public void testResolvePropertiesToDeclareEmpty() throws Exception {
+ public void testResolvePropertiesToDeclareEmpty() {
ComponentInstInputsMap testSubject;
- Map<String, List<ComponentInstancePropInput>> componentInstanceProperties = null;
// default test
testSubject = createTestSubject();
- try {
+ assertThrows(IllegalStateException.class, () -> {
testSubject.resolvePropertiesToDeclare();
- } catch (Exception e) {
- Assert.assertTrue(e.getClass() == IllegalStateException.class);
- }
+ });
}
@Test
- public void testResolvePropertiesToDeclare() throws Exception {
+ public void testResolvePropertiesToDeclare() {
ComponentInstInputsMap testSubject;
- Map<String, List<ComponentInstancePropInput>> componentInstanceProperties = null;
-
Map<String, List<ComponentInstancePropInput>> inputs = new HashMap<>();
- inputs.put("mock", new LinkedList<>());
+ inputs.put("test", new LinkedList<>());
// default test
testSubject = createTestSubject();
testSubject.setComponentInstanceInputsMap(inputs);
- testSubject.resolvePropertiesToDeclare();
+ Pair<String, List<ComponentInstancePropInput>> result = testSubject.resolvePropertiesToDeclare();
+ assertEquals(0, result.getValue().size());
+
testSubject = createTestSubject();
testSubject.setComponentInstancePropertiesToPolicies(inputs);
- testSubject.resolvePropertiesToDeclare();
+ result = testSubject.resolvePropertiesToDeclare();
+ assertEquals(0, result.getValue().size());
+
testSubject = createTestSubject();
testSubject.setPolicyProperties(inputs);
- testSubject.resolvePropertiesToDeclare();
+ result = testSubject.resolvePropertiesToDeclare();
+ assertEquals(0, result.getValue().size());
+
+ testSubject = createTestSubject();
+ testSubject.setComponentInstancePropInput(inputs);
+ result = testSubject.resolvePropertiesToDeclare();
+ assertEquals(0, result.getValue().size());
+
+ testSubject = createTestSubject();
+ testSubject.setServiceProperties(inputs);
+ result = testSubject.resolvePropertiesToDeclare();
+ assertEquals(0, result.getValue().size());
+
+ testSubject = createTestSubject();
+ testSubject.setGroupProperties(inputs);
+ result = testSubject.resolvePropertiesToDeclare();
+ assertEquals(0, result.getValue().size());
+
+ testSubject = createTestSubject();
+ testSubject.setComponentPropertiesToPolicies(inputs);
+ result = testSubject.resolvePropertiesToDeclare();
+ assertEquals(0, result.getValue().size());
}
-
+
@Test
- public void testGetPolicyProperties() throws Exception {
- ComponentInstInputsMap testSubject;
- Map<String, List<ComponentInstancePropInput>> componentInstanceProperties = null;
+ public void testPolicyProperties() {
+ ComponentInstInputsMap testSubject = createTestSubject();
+ Map<String, List<ComponentInstancePropInput>> policyProperties = new HashMap<>();
+ testSubject.setPolicyProperties(policyProperties);
+ Map<String, List<ComponentInstancePropInput>> result = testSubject.getPolicyProperties();
+ assertEquals(0, result.size());
+ }
- // default test
- testSubject = createTestSubject();
- testSubject.getPolicyProperties();
+ @Test
+ public void testServiceProperties() {
+ ComponentInstInputsMap testSubject = createTestSubject();
+ Map<String, List<ComponentInstancePropInput>> serviceProperties = new HashMap<>();
+ testSubject.setServiceProperties(serviceProperties);
+ Map<String, List<ComponentInstancePropInput>> result = testSubject.getServiceProperties();
+ assertEquals(0, result.size());
+ }
+
+ @Test
+ public void testGroupProperties() {
+ ComponentInstInputsMap testSubject = createTestSubject();
+ Map<String, List<ComponentInstancePropInput>> groupProperties = new HashMap<>();
+ testSubject.setGroupProperties(groupProperties);
+ Map<String, List<ComponentInstancePropInput>> result = testSubject.getGroupProperties();
+ assertEquals(0, result.size());
+ }
+
+ @Test
+ public void testComponentPropertiesToPolicies() {
+ ComponentInstInputsMap testSubject = createTestSubject();
+ Map<String, List<ComponentInstancePropInput>> componentPropertiesToPolicies = new HashMap<>();
+ testSubject.setComponentPropertiesToPolicies(componentPropertiesToPolicies);
+ Map<String, List<ComponentInstancePropInput>> result = testSubject.getComponentPropertiesToPolicies();
+ assertEquals(0, result.size());
+ }
+
+ @Test
+ public void testComponentInstancePropertiesToPolicies() {
+ ComponentInstInputsMap testSubject = createTestSubject();
+ Map<String, List<ComponentInstancePropInput>> componentInstancePropertiesToPolicies = new HashMap<>();
+ testSubject.setComponentInstancePropertiesToPolicies(componentInstancePropertiesToPolicies);
+ Map<String, List<ComponentInstancePropInput>> result = testSubject.getComponentInstancePropertiesToPolicies();
+ assertEquals(0, result.size());
}
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/VersionUtilTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/VersionUtilTest.java
new file mode 100644
index 0000000000..89faa3afba
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/VersionUtilTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model.tosca;
+
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.model.tosca.version.ApplicationVersionException;
+import org.openecomp.sdc.be.model.tosca.version.Version;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+
+public class VersionUtilTest {
+
+ @Test
+ public void testIsSnapshot() {
+ assertTrue(VersionUtil.isSnapshot("test_snapshot"));
+ assertTrue(VersionUtil.isSnapshot("test_SNAPSHOT"));
+ assertFalse(VersionUtil.isSnapshot("test_SNAP"));
+ }
+
+ @Test
+ public void testIsValid() {
+ assertTrue(VersionUtil.isValid("1.0.2"));
+ assertTrue(VersionUtil.isValid("1.0-2"));
+ assertFalse(VersionUtil.isValid("1!2"));
+ }
+
+ @Test
+ public void testParseVersion() {
+ Version ver1 = VersionUtil.parseVersion("1.0.2");
+ assertEquals(1, ver1.getMajorVersion());
+ assertEquals(0, ver1.getMinorVersion());
+ assertEquals(2, ver1.getIncrementalVersion());
+
+ Version ver2 = VersionUtil.parseVersion("1.0-2");
+ assertEquals(1, ver2.getMajorVersion());
+ assertEquals(0, ver2.getMinorVersion());
+ assertEquals(2, ver2.getBuildNumber());
+
+ assertThrows(
+ ApplicationVersionException.class,
+ () -> VersionUtil.parseVersion("1!2")
+ );
+ }
+
+ @Test
+ public void testCompare() {
+ assertEquals(-1, VersionUtil.compare("1.0.2", "1.0.3"));
+ assertEquals(0, VersionUtil.compare("1.0.2", "1.0.2"));
+ assertEquals(1, VersionUtil.compare("1.0.2", "0.0.5"));
+ }
+}