diff options
author | Tal Gitelman <tg851x@intl.att.com> | 2017-12-10 18:55:03 +0200 |
---|---|---|
committer | Tal Gitelman <tg851x@intl.att.com> | 2017-12-10 19:33:38 +0200 |
commit | 51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch) | |
tree | 3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /asdctool/src/test | |
parent | b5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff) |
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507
Issue-ID: SDC-714
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'asdctool/src/test')
23 files changed, 307 insertions, 106 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnumTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnumTest.java index 5afabc5639..a84c74d2f5 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnumTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnumTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.enums; -import javax.annotation.Generated; - import org.junit.Test; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java index 775006bfdc..6adbdccf1d 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java @@ -2,8 +2,6 @@ package org.openecomp.sdc.asdctool.impl.validator.config; import java.util.Properties; -import javax.annotation.Generated; - import org.junit.Test; @@ -21,16 +19,6 @@ public class ValidationConfigManagerTest { // default test result = ValidationConfigManager.getOutputFilePath(); } - - - @Test - public void testSetOutputFilePath() throws Exception { - String outputPath = ""; - - // default test - ValidationConfigManager.setOutputFilePath(outputPath); - } - @Test public void testGetCsvReportFilePath() throws Exception { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java index f220fa149a..fb916541c0 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.config; -import javax.annotation.Generated; - import org.junit.Test; import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL; import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter; @@ -10,7 +8,6 @@ import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidat import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask; import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.VfArtifactValidationTask; import org.openecomp.sdc.asdctool.impl.validator.tasks.moduleJson.ModuleJsonTask; -import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager; import org.openecomp.sdc.be.dao.TitanClientStrategy; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraClient; @@ -20,7 +17,6 @@ import org.openecomp.sdc.be.model.DerivedNodeTypeResolver; import org.openecomp.sdc.be.model.jsontitan.operations.ArtifactsOperations; import org.openecomp.sdc.be.model.jsontitan.operations.CategoryOperation; import org.openecomp.sdc.be.model.jsontitan.operations.GroupsOperation; -import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation; import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation; import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaDataOperation; @@ -99,18 +95,6 @@ public class ValidationToolConfigurationTest { testSubject = createTestSubject(); result = testSubject.basicVfValidator(); } - - - @Test - public void testReportManager() throws Exception { - ValidationToolConfiguration testSubject; - ReportManager result; - - // default test - testSubject = createTestSubject(); - result = testSubject.reportManager(); - } - @Test public void testArtifactCassandraDao() throws Exception { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java index 344c439f4b..05acd9aa6f 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; -import javax.annotation.Generated; - import org.junit.Test; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java index 523b9ac077..3747d7fd09 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java @@ -1,11 +1,6 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; -import java.util.List; - import org.junit.Test; -import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; public class TopologyTemplateValidatorExecuterTest { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java index 0d75c4d8b2..12136df609 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; -import javax.annotation.Generated; - import org.junit.Test; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResultTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResultTest.java index ba1bd72fb7..8ba509cf9c 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResultTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResultTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts; -import javax.annotation.Generated; - import org.junit.Test; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java index cdada41b92..ef0b23bc59 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java @@ -1,11 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts; -import javax.annotation.Generated; - -import org.junit.Test; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; - - public class ServiceArtifactValidationTaskTest { private ServiceArtifactValidationTask createTestSubject() { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java index 554e58d9d5..04aec47ebb 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java @@ -1,12 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts; -import javax.annotation.Generated; - -import org.junit.Test; -import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; - - public class VfArtifactValidationTaskTest { private VfArtifactValidationTask createTestSubject() { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java index 6e72a31421..7467699fc0 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java @@ -2,8 +2,6 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; import java.util.List; -import javax.annotation.Generated; - import org.junit.Test; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResultTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResultTest.java index 96eedcf1fd..d51075bc89 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResultTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResultTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; -import javax.annotation.Generated; - import org.junit.Test; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResultTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResultTest.java index 3b88a683ed..9b44eef1f5 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResultTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResultTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; -import javax.annotation.Generated; - import org.junit.Test; 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 index e8641097b6..c97bffc4d8 100644 --- 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 @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.migration.config; -import javax.annotation.Generated; - import org.junit.Test; import org.openecomp.sdc.asdctool.migration.core.SdcMigrationTool; import org.openecomp.sdc.asdctool.migration.dao.MigrationTasksDao; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/DBVersionTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/DBVersionTest.java index 4e5fd3ab31..afdd0d6da8 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/DBVersionTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/DBVersionTest.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.asdctool.migration.core; +import static org.testng.Assert.assertEquals; + import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; - public class DBVersionTest { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java index b1813227e2..fe74891950 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java @@ -1,5 +1,12 @@ package org.openecomp.sdc.asdctool.migration.core; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; + import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -12,13 +19,6 @@ import org.openecomp.sdc.asdctool.migration.service.SdcRepoService; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.Arrays; -import java.util.Collections; - -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - public class SdcMigrationToolTest { @InjectMocks diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/execution/MigrationExecutorImplTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/execution/MigrationExecutorImplTest.java index 7d8cc5aa78..9547abc00f 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/execution/MigrationExecutorImplTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/execution/MigrationExecutorImplTest.java @@ -1,14 +1,13 @@ package org.openecomp.sdc.asdctool.migration.core.execution; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + import org.openecomp.sdc.asdctool.migration.DummyMigrationFactory; -import org.openecomp.sdc.asdctool.migration.core.DBVersion; import org.openecomp.sdc.asdctool.migration.core.task.Migration; import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - public class MigrationExecutorImplTest { @Test diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/task/MigrationResultTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/task/MigrationResultTest.java index 31af99c64d..04a8bd213b 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/task/MigrationResultTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/task/MigrationResultTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.migration.core.task; -import javax.annotation.Generated; - import org.junit.Test; import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult.MigrationStatus; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/resolver/SpringBeansMigrationResolverTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/resolver/SpringBeansMigrationResolverTest.java index 6084608f0e..360b3aab40 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/resolver/SpringBeansMigrationResolverTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/resolver/SpringBeansMigrationResolverTest.java @@ -1,23 +1,24 @@ package org.openecomp.sdc.asdctool.migration.resolver; +import static org.mockito.Mockito.when; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openecomp.sdc.asdctool.migration.core.DBVersion; +import org.openecomp.sdc.asdctool.migration.core.task.IMigrationStage; import org.openecomp.sdc.asdctool.migration.core.task.Migration; import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult; import org.openecomp.sdc.asdctool.migration.service.SdcRepoService; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - public class SpringBeansMigrationResolverTest { @InjectMocks @@ -38,7 +39,8 @@ public class SpringBeansMigrationResolverTest { @Test public void testResolveMigrations_getMigrationsWithVersionGreaterThanLatest() throws Exception { when(sdcRepoServiceMock.getLatestDBVersion()).thenReturn(DBVersion.fromString("1710.2")); - List<Migration> resolvedMigrations = testInstance.resolveMigrations(); + testInstance.setPostMigrations(Collections.emptyList()); + List<IMigrationStage> resolvedMigrations = testInstance.resolveMigrations(); assertEquals(resolvedMigrations.size(), 2); assertEquals(resolvedMigrations.get(0).getVersion(), DBVersion.fromString("1710.3")); assertEquals(resolvedMigrations.get(1).getVersion(), DBVersion.fromString("1710.22")); @@ -47,7 +49,8 @@ public class SpringBeansMigrationResolverTest { @Test public void testResolveMigration_noLatestVersionForCurrentMajorVersion() throws Exception { when(sdcRepoServiceMock.getLatestDBVersion()).thenReturn(DBVersion.fromString("1710.-1")); - List<Migration> resolvedMigrations = testInstance.resolveMigrations(); + testInstance.setPostMigrations(Collections.emptyList()); + List<IMigrationStage> resolvedMigrations = testInstance.resolveMigrations(); assertEquals(resolvedMigrations.size(), 3); assertEquals(resolvedMigrations.get(0).getVersion(), DBVersion.fromString("1710.1")); assertEquals(resolvedMigrations.get(1).getVersion(), DBVersion.fromString("1710.3")); @@ -57,8 +60,9 @@ public class SpringBeansMigrationResolverTest { @Test public void testResolveMigrations_emptyMigrationsList() throws Exception { testInstance.setMigrations(Collections.emptyList()); + testInstance.setPostMigrations(Collections.emptyList()); when(sdcRepoServiceMock.getLatestDBVersion()).thenReturn(DBVersion.fromString("1710.-1")); - List<Migration> resolvedMigrations = testInstance.resolveMigrations(); + List<IMigrationStage> resolvedMigrations = testInstance.resolveMigrations(); assertTrue(resolvedMigrations.isEmpty()); } diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java index a2bf623b83..c50cae0673 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java @@ -1,8 +1,5 @@ package org.openecomp.sdc.asdctool.migration.scanner; -import org.apache.commons.io.FileUtils; -import org.openecomp.sdc.asdctool.migration.core.MigrationException; - import java.io.File; import java.lang.reflect.Modifier; import java.net.URL; @@ -12,6 +9,9 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import org.apache.commons.io.FileUtils; +import org.openecomp.sdc.asdctool.migration.core.MigrationException; + /** * scan and instantiate classes of given type in the class path */ diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java index 705f8d13e6..31e1a63689 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java @@ -1,5 +1,11 @@ package org.openecomp.sdc.asdctool.migration.service; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.testng.Assert.assertEquals; + +import java.math.BigInteger; + import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -10,12 +16,6 @@ import org.openecomp.sdc.be.resources.data.MigrationTaskEntry; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.math.BigInteger; - -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; - public class SdcRepoServiceTest { @InjectMocks diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java index 037d51ba12..fa61b7e19e 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java @@ -1,5 +1,11 @@ package org.openecomp.sdc.asdctool.migration.task; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + import org.apache.commons.lang.StringUtils; import org.openecomp.sdc.asdctool.migration.core.DBVersion; import org.openecomp.sdc.asdctool.migration.core.task.Migration; @@ -9,13 +15,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - - public class MigrationTasksTest { public static final String MIGRATIONS_BASE_PACKAGE = "org.openecomp.sdc.asdctool.migration.tasks"; 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 new file mode 100644 index 0000000000..2cb5e2999c --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java @@ -0,0 +1,265 @@ +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 org.junit.Before; +import org.junit.BeforeClass; +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.task.MigrationResult; +import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; +import org.openecomp.sdc.be.dao.jsongraph.TitanDao; +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.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; + +@RunWith(MockitoJUnitRunner.class) +public class UpgradeMigration1710Test { + + private final static String USER = "jh0003"; + private final static String CONF_LEVEL = "5.0"; + + private final User user = new User(); + private UpgradeMigration1710 migration; + @Mock + private IUserAdminOperation userAdminOperation; + @Mock + private ToscaOperationFacade toscaOperationFacade; + @Mock + private LifecycleBusinessLogic lifecycleBusinessLogic; + @Mock + private TitanDao titanDao; + @Mock + private ComponentsUtils componentUtils; + @Mock + private ConfigurationSource configurationSource; + 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; + + @BeforeClass + public static void setUpClass() { + resourcesForUpgrade = new HashMap<>(); + resourcesForUpgrade.put(CONF_LEVEL, resources); + } + + @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()); + configurationManager.getConfiguration().setSkipUpgradeVSPs(true); + configurationManager.getConfiguration().setSkipUpgradeFailedVfs(true); + configurationManager.getConfiguration().setAutoHealingOwner(USER); + + } + + @Test + public void nodeTypesUpgradeFailed() { + resolveUserAndDefineUpgradeLevel(); + when(titanDao.getByCriteria(any(), any(), any(), any())) + .thenReturn(Either.right(TitanOperationStatus.NOT_FOUND)); + assertEquals(MigrationResult.MigrationStatus.FAILED, migration.migrate().getMigrationStatus()); + } + + @Test + public void nodeTypesUpgradePassedAndVFsUpgradeFailedWhenSkipFailedVFsIsNotSupported() { + final boolean failOnVfUpgrade = true; + final boolean upgradeServices = false; + final boolean exceptionOnVfUpgrade = false; + final boolean upgradeFVC = false; + configurationManager.getConfiguration().setSkipUpgradeFailedVfs(false); + resolveUserAndDefineUpgradeLevel(); + upgradeRules(failOnVfUpgrade, exceptionOnVfUpgrade, upgradeServices, upgradeFVC); + assertEquals(MigrationResult.MigrationStatus.FAILED, migration.migrate().getMigrationStatus()); + } + + @Test + public void upgradeAllVFsUpgradeFailedOnExceptionWhenSkipFailedVFsIsNotSupported() { + final boolean failOnVfUpgrade = false; + final boolean upgradeServices = false; + final boolean exceptionOnVfUpgrade = true; + final boolean upgradeFVC = false; + configurationManager.getConfiguration().setSkipUpgradeFailedVfs(false); + resolveUserAndDefineUpgradeLevel(); + upgradeRules(failOnVfUpgrade, exceptionOnVfUpgrade, upgradeServices, upgradeFVC); + assertEquals(MigrationResult.MigrationStatus.FAILED, migration.migrate().getMigrationStatus()); + } + + @Test + public void upgradeAllIfVFsUpgradeFailedOnExceptionWhenSkipFailedVFsIsSupported() { + final boolean failOnVfUpgrade = false; + final boolean upgradeServices = true; + final boolean exceptionOnFvUpgrade = true; + final boolean upgradeFVC = false; + configurationManager.getConfiguration().setSkipUpgradeFailedVfs(true); + resolveUserAndDefineUpgradeLevel(); + upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeFVC); + assertEquals(MigrationResult.MigrationStatus.COMPLETED, migration.migrate().getMigrationStatus()); + } + + + @Test + public void upgradeAll() { + final boolean failOnVfUpgrade = false; + final boolean upgradeServices = true; + final boolean exceptionOnFvUpgrade = false; + final boolean upgradeFVC = false; + resolveUserAndDefineUpgradeLevel(); + upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeFVC); + assertEquals(MigrationResult.MigrationStatus.COMPLETED, migration.migrate().getMigrationStatus()); + } + + @Test + public void upgradeAllWhenVspUpgradeIsRequired() { + final boolean failOnVfUpgrade = false; + final boolean upgradeServices = true; + final boolean exceptionOnFvUpgrade = false; + final boolean upgradeFVC = true; + resolveUserAndDefineUpgradeLevel(); + upgradeRules(failOnVfUpgrade, exceptionOnFvUpgrade, upgradeServices, upgradeFVC); + configurationManager.getConfiguration().setSkipUpgradeVSPs(false); + migration.setComponentsUtils(componentUtils); + assertEquals(MigrationResult.MigrationStatus.COMPLETED, migration.migrate().getMigrationStatus()); + } + + @Test + public void migrationFailedWhenUserNotResolved() { + when(userAdminOperation.getUserData(anyString(), eq(false))).thenReturn(Either.right(ActionStatus.MISSING_INFORMATION)); + when(titanDao.rollback()).thenReturn(TitanOperationStatus.OK); + assertEquals(MigrationResult.MigrationStatus.FAILED, migration.migrate().getMigrationStatus()); + } + + private void resolveUserAndDefineUpgradeLevel() { + when(userAdminOperation.getUserData(anyString(), eq(false))).thenReturn(Either.left(user)); + configurationManager.getConfiguration().setToscaConformanceLevel(CONF_LEVEL); + configurationManager.getConfiguration().setResourcesForUpgrade(resourcesForUpgrade); + } + + private void upgradeRules(boolean failedVfUpgrade, boolean exceptionOnVfUpgrade, boolean upgradeService, boolean upgradeVFCs) { + GraphVertex component = new GraphVertex(); + component.setJsonMetadataField(JsonPresentationFields.LIFECYCLE_STATE, LifecycleStateEnum.CERTIFIED.name()); + component.setJsonMetadataField(JsonPresentationFields.UNIQUE_ID, "12345"); + List<GraphVertex> components = Lists.newArrayList(); + components.add(component); + + Resource resource = new Resource(); + Either<Component, StorageOperationStatus> foundResource = Either.left(resource); + + when(titanDao.getByCriteria(any(), any(), any(), any())) + .thenReturn(Either.left(components)); + when(titanDao.getParentVertecies(any(), any(), any())) + //1th node to upgrade + .thenReturn(Either.left(components)) + //parent of the 1th node - stop recursion + .thenReturn(Either.right(TitanOperationStatus.NOT_FOUND)); + if (failedVfUpgrade) { + Either<Component, StorageOperationStatus> getToscaForVF = Either.right(StorageOperationStatus.NOT_FOUND); + when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(foundResource) + .thenReturn(foundResource) + .thenReturn(getToscaForVF); + } + else { + if (exceptionOnVfUpgrade) { + when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(foundResource) + .thenReturn(foundResource) + .thenThrow(new RuntimeException()); + } + else { + when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(foundResource); + //happy flow + if (upgradeService) { + Either<Resource, StorageOperationStatus> service = Either.left(resource); + if (upgradeVFCs) { + when(componentUtils.convertFromStorageResponse(any(), any())).thenCallRealMethod(); + when(componentUtils.getResponseFormat(any(ActionStatus.class),any())).thenCallRealMethod(); + when(toscaOperationFacade.getLatestCertifiedByToscaResourceName(any(), any(), any())) + .thenReturn(service) + .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)) + .thenReturn(service) + .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); + } + else { + when(toscaOperationFacade.getLatestCertifiedByToscaResourceName(any(), any(), any())) + .thenReturn(service); + } + } + } + } + List<ComponentInstance> instances = Lists.newArrayList(); + instances.add(createComponentInstance()); + resource.setComponentInstances(instances); + Either<Resource, ResponseFormat> fromLifeCycle = Either.left(resource); + doReturn(fromLifeCycle).when(lifecycleBusinessLogic) + .changeComponentState(any(), any(), any(), any(), any(),eq(true), eq(false)); + + } + + private ComponentInstance createComponentInstance() { + ComponentInstance instance = new ComponentInstance(); + instance.setIcon(""); + instance.setUniqueId(""); + instance.setName(""); + instance.setComponentUid(""); + instance.setCreationTime(1L); + instance.setModificationTime(2L); + instance.setDescription(""); + instance.setPosX(""); + instance.setPosY(""); + instance.setPropertyValueCounter(1); + instance.setNormalizedName(""); + instance.setOriginType(OriginTypeEnum.CVFC); + instance.setCustomizationUUID(""); + instance.setComponentName(""); + instance.setComponentVersion(""); + instance.setToscaComponentName(""); + instance.setInvariantName(""); + instance.setSourceModelInvariant(""); + instance.setSourceModelName(""); + instance.setSourceModelUuid(""); + instance.setSourceModelUid(""); + instance.setIsProxy(false); + return instance; + } + + +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/servlets/EntryPointTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/servlets/EntryPointTest.java index c3f7874c12..217bc3919f 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/servlets/EntryPointTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/servlets/EntryPointTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.asdctool.servlets; -import javax.annotation.Generated; - import org.junit.Test; |