diff options
author | Michael Lando <ml636r@att.com> | 2018-03-04 14:53:33 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-03-07 13:19:05 +0000 |
commit | a5445100050e49e83f73424198d73cd72d672a4d (patch) | |
tree | cacf4df817df31be23e4e790d1dda857bdae061e /asdctool/src/test/java/org | |
parent | 51157f92c21976cba4914c378aaa3cba49826931 (diff) |
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74
Issue-ID: SDC-977
Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'asdctool/src/test/java/org')
2 files changed, 36 insertions, 116 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java deleted file mode 100644 index c97bffc4d8..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.openecomp.sdc.asdctool.migration.config; - -import org.junit.Test; -import org.openecomp.sdc.asdctool.migration.core.SdcMigrationTool; -import org.openecomp.sdc.asdctool.migration.dao.MigrationTasksDao; -import org.openecomp.sdc.asdctool.migration.resolver.MigrationResolver; -import org.openecomp.sdc.asdctool.migration.resolver.SpringBeansMigrationResolver; -import org.openecomp.sdc.asdctool.migration.service.SdcRepoService; -import org.openecomp.sdc.be.dao.cassandra.CassandraClient; - - -public class MigrationSpringConfigTest { - - private MigrationSpringConfig createTestSubject() { - return new MigrationSpringConfig(); - } - - - @Test - public void testSdcMigrationTool() throws Exception { - MigrationSpringConfig testSubject; - MigrationResolver migrationResolver = null; - SdcRepoService sdcRepoService = null; - SdcMigrationTool result; - - // default test - testSubject = createTestSubject(); - result = testSubject.sdcMigrationTool(migrationResolver, sdcRepoService); - } - - - @Test - public void testMigrationResolver() throws Exception { - MigrationSpringConfig testSubject; - SdcRepoService sdcRepoService = null; - SpringBeansMigrationResolver result; - - // default test - testSubject = createTestSubject(); - result = testSubject.migrationResolver(sdcRepoService); - } - - - @Test - public void testSdcRepoService() throws Exception { - MigrationSpringConfig testSubject; - MigrationTasksDao migrationTasksDao = null; - SdcRepoService result; - - // default test - testSubject = createTestSubject(); - result = testSubject.sdcRepoService(migrationTasksDao); - } - - - @Test - public void testMigrationTasksDao() throws Exception { - MigrationSpringConfig testSubject; - MigrationTasksDao result; - - // default test - testSubject = createTestSubject(); - result = testSubject.migrationTasksDao(); - } - - - @Test - public void testCassandraClient() throws Exception { - MigrationSpringConfig testSubject; - CassandraClient result; - - // default test - testSubject = createTestSubject(); - result = testSubject.cassandraClient(); - } -}
\ No newline at end of file diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java index 2cb5e2999c..0c1b32efd2 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java @@ -1,26 +1,17 @@ package org.openecomp.sdc.asdctool.migration.tasks.mig1710; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - +import com.google.common.collect.Lists; +import fj.data.Either; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult; +import org.openecomp.sdc.asdctool.migration.tasks.handlers.XlsOutputHandler; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.config.Configuration; import org.openecomp.sdc.be.config.ConfigurationManager; @@ -31,21 +22,19 @@ import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import com.google.common.collect.Lists; - -import fj.data.Either; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.*; @RunWith(MockitoJUnitRunner.class) public class UpgradeMigration1710Test { @@ -53,7 +42,9 @@ public class UpgradeMigration1710Test { private final static String CONF_LEVEL = "5.0"; private final User user = new User(); - private UpgradeMigration1710 migration; + + @InjectMocks + private UpgradeMigration1710 migration = new UpgradeMigration1710(); @Mock private IUserAdminOperation userAdminOperation; @Mock @@ -66,6 +57,9 @@ public class UpgradeMigration1710Test { private ComponentsUtils componentUtils; @Mock private ConfigurationSource configurationSource; + @Mock + private XlsOutputHandler outputHandler; + private static ConfigurationManager configurationManager; private static List<String> resources = Stream.of("org.openecomp.resource.cp.extCP").collect(Collectors.toList()); private static Map<String, List<String>> resourcesForUpgrade; @@ -78,12 +72,6 @@ public class UpgradeMigration1710Test { @Before public void setUp() { - migration = new UpgradeMigration1710(); - migration.setUserAdminOperation(userAdminOperation); - migration.setTitanDao(titanDao); - migration.setTosckaOperationFacade(toscaOperationFacade); - migration.setLifecycleBusinessLogic(lifecycleBusinessLogic); - user.setUserId(USER); configurationManager = new ConfigurationManager(configurationSource); configurationManager.setConfiguration(new Configuration()); @@ -106,11 +94,13 @@ public class UpgradeMigration1710Test { final boolean failOnVfUpgrade = true; final boolean upgradeServices = false; final boolean exceptionOnVfUpgrade = false; - final boolean upgradeFVC = false; + final boolean upgradeVFC = false; configurationManager.getConfiguration().setSkipUpgradeFailedVfs(false); resolveUserAndDefineUpgradeLevel(); - upgradeRules(failOnVfUpgrade, exceptionOnVfUpgrade, upgradeServices, upgradeFVC); + upgradeRules(failOnVfUpgrade, exceptionOnVfUpgrade, upgradeServices, upgradeVFC); assertEquals(MigrationResult.MigrationStatus.FAILED, migration.migrate().getMigrationStatus()); + verify(titanDao, times(1)).commit(); + verify(titanDao, times(2)).rollback(); } @Test @@ -118,11 +108,13 @@ public class UpgradeMigration1710Test { final boolean failOnVfUpgrade = false; final boolean upgradeServices = false; final boolean exceptionOnVfUpgrade = true; - final boolean upgradeFVC = false; + final boolean upgradeVFC = false; configurationManager.getConfiguration().setSkipUpgradeFailedVfs(false); resolveUserAndDefineUpgradeLevel(); - upgradeRules(failOnVfUpgrade, exceptionOnVfUpgrade, upgradeServices, upgradeFVC); + upgradeRules(failOnVfUpgrade, exceptionOnVfUpgrade, upgradeServices, upgradeVFC); assertEquals(MigrationResult.MigrationStatus.FAILED, migration.migrate().getMigrationStatus()); + verify(titanDao, times(1)).commit(); + verify(titanDao, times(2)).rollback(); } @Test @@ -130,11 +122,13 @@ public class UpgradeMigration1710Test { final boolean failOnVfUpgrade = false; final boolean upgradeServices = true; final boolean exceptionOnFvUpgrade = true; - final boolean upgradeFVC = false; + final boolean upgradeVFC = false; configurationManager.getConfiguration().setSkipUpgradeFailedVfs(true); resolveUserAndDefineUpgradeLevel(); - upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeFVC); + upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeVFC); assertEquals(MigrationResult.MigrationStatus.COMPLETED, migration.migrate().getMigrationStatus()); + verify(titanDao, times(2)).commit(); + verify(titanDao, times(3)).rollback(); } @@ -143,10 +137,12 @@ public class UpgradeMigration1710Test { final boolean failOnVfUpgrade = false; final boolean upgradeServices = true; final boolean exceptionOnFvUpgrade = false; - final boolean upgradeFVC = false; + final boolean upgradeVFC = false; resolveUserAndDefineUpgradeLevel(); - upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeFVC); + upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeVFC); assertEquals(MigrationResult.MigrationStatus.COMPLETED, migration.migrate().getMigrationStatus()); + verify(titanDao, times(2)).commit(); + verify(titanDao, times(3)).rollback(); } @Test @@ -154,11 +150,11 @@ public class UpgradeMigration1710Test { final boolean failOnVfUpgrade = false; final boolean upgradeServices = true; final boolean exceptionOnFvUpgrade = false; - final boolean upgradeFVC = true; + final boolean upgradeVFC = true; resolveUserAndDefineUpgradeLevel(); - upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeFVC); + upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeVFC); configurationManager.getConfiguration().setSkipUpgradeVSPs(false); - migration.setComponentsUtils(componentUtils); +// migration.setComponentsUtils(componentUtils); assertEquals(MigrationResult.MigrationStatus.COMPLETED, migration.migrate().getMigrationStatus()); } @@ -187,7 +183,7 @@ public class UpgradeMigration1710Test { when(titanDao.getByCriteria(any(), any(), any(), any())) .thenReturn(Either.left(components)); - when(titanDao.getParentVertecies(any(), any(), any())) + when(titanDao.getParentVertecies(any(GraphVertex.class), any(), any())) //1th node to upgrade .thenReturn(Either.left(components)) //parent of the 1th node - stop recursion |