summaryrefslogtreecommitdiffstats
path: root/asdctool/src/test
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-03-18 16:02:43 +0900
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-04-01 08:36:21 +0000
commit8b8061e8b47703beb7a19174de5c9b29ccf1ca14 (patch)
tree902e0828458e4a9ef97e1ad125e150f638f0b5dd /asdctool/src/test
parent8824935445f26a3f8077f48c327951dd9e778d90 (diff)
Increase test coverage for asdctool
Add basic JUnit test cases in asdctool/migration/tasks/mig1806 Add hamcrest-all version in parent pom.xml Issue-ID: SDC-1895 Change-Id: I88b1bdb2f3619721fe80f57f0526de5b59e8a6af Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'asdctool/src/test')
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java50
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java52
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java44
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/Version.java16
4 files changed, 162 insertions, 0 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java
new file mode 100644
index 0000000000..c10291b198
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
+
+import static org.junit.Assert.assertThat;
+import java.math.BigInteger;
+import org.hamcrest.core.Is;
+import org.hamcrest.core.IsNull;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
+
+public class ForwardPathMigrationTest {
+
+ ForwardPathMigration forwardPathMigration = null;
+
+ @Mock
+ TitanDao titanDao;
+
+ @Mock
+ UserAdminOperation userAdminOperation;
+
+ @Mock
+ ToscaOperationFacade toscaOperationFacade;
+
+ @Before
+ public void setUp() throws Exception {
+ forwardPathMigration = new ForwardPathMigration(titanDao, userAdminOperation, toscaOperationFacade);
+ }
+
+ @Test
+ public void testDescription() {
+ assertThat(forwardPathMigration,IsNull.notNullValue());
+ assertThat("remove corrupted forwarding paths ", Is.is(forwardPathMigration.description()));
+ }
+
+ @Test
+ public void testGetVersion() {
+ DBVersion dbVersion = DBVersion.from(BigInteger.valueOf(Version.MAJOR.getValue()), BigInteger.valueOf(Version.MINOR.getValue()));
+ assertThat(dbVersion,Is.is(forwardPathMigration.getVersion()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testMigrate() {
+ assertThat(forwardPathMigration,IsNull.notNullValue());
+ forwardPathMigration.migrate();
+ }
+}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java
new file mode 100644
index 0000000000..b7f014039e
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java
@@ -0,0 +1,52 @@
+package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
+
+import static org.junit.Assert.assertThat;
+import java.math.BigInteger;
+import org.hamcrest.core.Is;
+import org.hamcrest.core.IsNull;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
+import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ResourceLifecycleMigrationTest {
+
+ @Mock
+ private TitanDao titanDao;
+ @Mock
+ private LifecycleBusinessLogic lifecycleBusinessLogic;
+ @Mock
+ private UserAdminOperation userAdminOperation;
+
+ ResourceLifecycleMigration resourceLifecycleMigration = null;
+
+ @Before
+ public void setUp() throws Exception {
+ resourceLifecycleMigration =
+ new ResourceLifecycleMigration(titanDao, lifecycleBusinessLogic, userAdminOperation);
+ }
+
+ @Test
+ public void testDescription() {
+ assertThat(resourceLifecycleMigration,IsNull.notNullValue());
+ assertThat("change resource lifecycle state from testing to certified", Is.is(resourceLifecycleMigration.description()));
+ }
+
+ @Test
+ public void testGetVersion() {
+ DBVersion dbVersion = DBVersion.from(BigInteger.valueOf(Version.MAJOR.getValue()), BigInteger.valueOf(Version.MINOR.getValue()));
+ assertThat(dbVersion, Is.is(resourceLifecycleMigration.getVersion()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testMigrate() {
+ assertThat(resourceLifecycleMigration,IsNull.notNullValue());
+ resourceLifecycleMigration.migrate();
+ }
+}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java
new file mode 100644
index 0000000000..0ea3b91083
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java
@@ -0,0 +1,44 @@
+package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
+
+import static org.junit.Assert.assertThat;
+import java.math.BigInteger;
+import org.hamcrest.core.Is;
+import org.hamcrest.core.IsNull;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SdcArchiveMigrationTest {
+ @Mock
+ private TitanDao titanDao;
+
+ SdcArchiveMigration sdcArchiveMigration = null;
+
+ @Before
+ public void setUp() throws Exception {
+ sdcArchiveMigration = new SdcArchiveMigration(titanDao);
+ }
+
+ @Test
+ public void testDescription() {
+ assertThat(sdcArchiveMigration,IsNull.notNullValue());
+ assertThat("add archive node for archiving/restoring components ", Is.is(sdcArchiveMigration.description()));
+ }
+
+ @Test
+ public void testGetVersion() {
+ DBVersion dbVersion = DBVersion.from(BigInteger.valueOf(Version.MAJOR.getValue()), BigInteger.valueOf(Version.MINOR.getValue()));
+ assertThat(dbVersion, Is.is(sdcArchiveMigration.getVersion()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testMigrate() {
+ assertThat(sdcArchiveMigration,IsNull.notNullValue());
+ sdcArchiveMigration.migrate();
+ }
+}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/Version.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/Version.java
new file mode 100644
index 0000000000..8341e738a1
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/Version.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
+
+public enum Version {
+
+ MINOR(0), MAJOR(1806);
+
+ private final int value;
+
+ private Version(final int newValue) {
+ value = newValue;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}