From bf2ffad5b686eb0ffddbeeeca5824b8caea0c8ff Mon Sep 17 00:00:00 2001 From: Wojciech Sliwka Date: Thu, 27 Jun 2019 12:35:47 +0200 Subject: Remove field injection in catalog-dao Change-Id: I24c3a898fa34491e80074944614722fbb3085515 Issue-ID: SDC-2398 Signed-off-by: Wojciech Sliwka --- .../asdctool/impl/EsToCassandraDataMigrationConfigTest.java | 10 ++++++---- .../impl/validator/config/ValidationToolConfigurationTest.java | 6 ++++-- .../asdctool/migration/config/MigrationSpringConfigTest.java | 7 +++++-- .../sdc/asdctool/migration/dao/MigrationTasksDaoTest.java | 9 ++++++--- .../migration/resolver/SpringBeansMigrationResolverTest.java | 4 +++- .../sdc/asdctool/simulator/tenant/ImportTableConfigTest.java | 6 ++++-- 6 files changed, 28 insertions(+), 14 deletions(-) (limited to 'asdctool/src/test/java/org') diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java index cb4d2b78d2..b838c22f9a 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java @@ -6,6 +6,8 @@ import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao; +import static org.mockito.Mockito.mock; + public class EsToCassandraDataMigrationConfigTest { private EsToCassandraDataMigrationConfig createTestSubject() { @@ -29,7 +31,7 @@ public class EsToCassandraDataMigrationConfigTest { // default test testSubject = createTestSubject(); - result = testSubject.artifactCassandraDao(); + result = testSubject.artifactCassandraDao(mock(CassandraClient.class)); } @Test @@ -39,7 +41,7 @@ public class EsToCassandraDataMigrationConfigTest { // default test testSubject = createTestSubject(); - result = testSubject.auditCassandraDao(); + result = testSubject.auditCassandraDao(mock(CassandraClient.class)); } @Test @@ -59,6 +61,6 @@ public class EsToCassandraDataMigrationConfigTest { // default test testSubject = createTestSubject(); - result = testSubject.sdcSchemaFilesCassandraDao(); + result = testSubject.sdcSchemaFilesCassandraDao(mock(CassandraClient.class)); } -} \ No newline at end of file +} 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 cf064ee04d..084a5fa49a 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 @@ -16,6 +16,8 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient; import org.openecomp.sdc.be.model.DerivedNodeTypeResolver; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.*; +import static org.mockito.Mockito.mock; + public class ValidationToolConfigurationTest { private ValidationToolConfiguration createTestSubject() { @@ -89,7 +91,7 @@ public class ValidationToolConfigurationTest { // default test testSubject = createTestSubject(); - result = testSubject.artifactCassandraDao(); + result = testSubject.artifactCassandraDao(mock(CassandraClient.class)); } @Test @@ -263,4 +265,4 @@ public class ValidationToolConfigurationTest { testSubject = createTestSubject(); result = testSubject.artifactToolBL(); } -} \ No newline at end of file +} 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 50b02d653f..ea8ecfaab9 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 @@ -7,8 +7,11 @@ 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.components.distribution.engine.ServiceDistributionArtifactsBuilder; +import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.springframework.beans.factory.config.PropertiesFactoryBean; +import static org.mockito.Mockito.mock; + public class MigrationSpringConfigTest { private MigrationSpringConfig createTestSubject() { @@ -56,7 +59,7 @@ public class MigrationSpringConfigTest { // default test testSubject = createTestSubject(); - result = testSubject.migrationTasksDao(); + result = testSubject.migrationTasksDao(mock(CassandraClient.class)); } @Test @@ -78,4 +81,4 @@ public class MigrationSpringConfigTest { testSubject = createTestSubject(); result = testSubject.mapper(); } -} \ No newline at end of file +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDaoTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDaoTest.java index a21356637a..82f6533f65 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDaoTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDaoTest.java @@ -1,17 +1,20 @@ package org.openecomp.sdc.asdctool.migration.dao; import org.junit.Test; +import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.openecomp.sdc.be.resources.data.MigrationTaskEntry; import java.math.BigInteger; +import static org.mockito.Mockito.mock; + public class MigrationTasksDaoTest { private MigrationTasksDao createTestSubject() { - return new MigrationTasksDao(); + return new MigrationTasksDao(mock(CassandraClient.class)); } - @Test(expected=NullPointerException.class) + @Test public void testInit() throws Exception { MigrationTasksDao testSubject; @@ -50,4 +53,4 @@ public class MigrationTasksDaoTest { testSubject = createTestSubject(); testSubject.createMigrationTask(migrationTask); } -} \ No newline at end of file +} 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 b6267d3950..aacbcdd738 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 @@ -9,6 +9,7 @@ import org.openecomp.sdc.asdctool.migration.core.task.Migration; import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult; import org.openecomp.sdc.asdctool.migration.dao.MigrationTasksDao; import org.openecomp.sdc.asdctool.migration.service.SdcRepoService; +import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -16,6 +17,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -87,6 +89,6 @@ public class SpringBeansMigrationResolverTest { } private SpringBeansMigrationResolver createTestSubject() { - return new SpringBeansMigrationResolver(null, null, new SdcRepoService(new MigrationTasksDao())); + return new SpringBeansMigrationResolver(null, null, new SdcRepoService(new MigrationTasksDao(mock(CassandraClient.class)))); } } diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfigTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfigTest.java index fe5d3d95a1..573686b3c8 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfigTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfigTest.java @@ -4,6 +4,8 @@ import org.junit.Test; import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao; +import static org.mockito.Mockito.mock; + public class ImportTableConfigTest { private ImportTableConfig createTestSubject() { @@ -27,6 +29,6 @@ public class ImportTableConfigTest { // default test testSubject = createTestSubject(); - result = testSubject.operationalEnvironmentDao(); + result = testSubject.operationalEnvironmentDao(mock(CassandraClient.class)); } -} \ No newline at end of file +} -- cgit 1.2.3-korg