From 52b9a0d5103c000f473b038f1cb524696ab78678 Mon Sep 17 00:00:00 2001 From: mojahidi Date: Mon, 8 Oct 2018 14:28:48 +0530 Subject: 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 --- .../sdc/versioning/dao/types/VersionTest.java | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test/java/org/openecomp/sdc/versioning/dao/types/VersionTest.java (limited to 'openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/test') 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 -- cgit 1.2.3-korg