summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2018-10-08 14:28:48 +0530
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-10-09 09:38:53 +0000
commit52b9a0d5103c000f473b038f1cb524696ab78678 (patch)
treee33348b49d9003491c3d5a54eb17b2fecc701f2b /openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test
parent234e6a81f53079b0cd22818df48f39fd479883a4 (diff)
Increased UT coverage -versioning-api-dao-types
Increased UT coverage openecomp-sdc-versioning-api dao-types Change-Id: I1fe246926d44582eb9b6534509885ff21166a1c0 Issue-ID: SDC-1673 Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test')
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test/java/org/openecomp/sdc/versioning/dao/types/VersionTest.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test/java/org/openecomp/sdc/versioning/dao/types/VersionTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test/java/org/openecomp/sdc/versioning/dao/types/VersionTest.java
new file mode 100644
index 0000000000..30cdbbdc70
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test/java/org/openecomp/sdc/versioning/dao/types/VersionTest.java
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ *
+ */
+package org.openecomp.sdc.versioning.dao.types;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class VersionTest {
+ @Test
+ public void testValueOfPositive() {
+ Version version = Version.valueOf("1.1");
+ Assert.assertEquals(1, version.getMajor());
+ Assert.assertEquals(1, version.getMinor());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testValueOfWihLengthOne() {
+ Version version = Version.valueOf("1");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testValueOfNegative() {
+ Version version = Version.valueOf("1a.1");
+ }
+ @Test
+ public void testValueOfNullVersion() {
+ Version version = Version.valueOf(null);
+ Assert.assertNull(version);
+ }
+
+ @Test
+ public void testCalculateNextCandidate() {
+ Version version = new Version();
+ version.setMinor(1);
+ Assert.assertEquals(2, version.calculateNextCandidate().getMinor());
+ }
+
+ @Test
+ public void testCalculateNextCandidateFinal() {
+ Version version = new Version();
+ version.setMajor(0);
+ Assert.assertEquals(1, version.calculateNextFinal().getMajor());
+ }
+
+ @Test
+ public void testCompareTo() {
+ Version version = new Version();
+ version.setMajor(1);
+
+ Version versionToCompare = new Version();
+ versionToCompare.setMajor(1);
+ Assert.assertEquals(0, version.compareTo(versionToCompare));
+ }
+
+ @Test
+ public void testVersionEquals() {
+ Version version = new Version();
+ version.setMajor(0);
+ version.setMinor(2);
+ Version versionToCompare = new Version();
+ versionToCompare.setMajor(0);
+ versionToCompare.setMinor(2);
+
+ Assert.assertTrue(version.equals(versionToCompare));
+ }
+
+ @Test
+ public void testVersionClone() {
+ Version version = new Version("1.0");
+ Assert.assertEquals(version, version.clone());
+ }
+
+ @Test
+ public void testVersionHashcode() {
+ Version version = new Version("1.0");
+ Assert.assertEquals((31 * (version.getMajor())+ version.getMinor()), version.hashCode());
+ }
+} \ No newline at end of file