diff options
author | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-27 12:35:47 +0200 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-07-07 08:22:31 +0000 |
commit | bf2ffad5b686eb0ffddbeeeca5824b8caea0c8ff (patch) | |
tree | 53e09d40e18b4aecff6f501633d374b87c4688be /asdctool | |
parent | 868746d27adc90efeba5909d3eb60a6e0cd24c27 (diff) |
Remove field injection in catalog-dao
Change-Id: I24c3a898fa34491e80074944614722fbb3085515
Issue-ID: SDC-2398
Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'asdctool')
11 files changed, 50 insertions, 26 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java index 3242c27384..7056acfab7 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java @@ -35,13 +35,13 @@ public class EsToCassandraDataMigrationConfig { } @Bean(name = "artifact-cassandra-dao") - public ArtifactCassandraDao artifactCassandraDao() { - return new ArtifactCassandraDao(); + public ArtifactCassandraDao artifactCassandraDao(CassandraClient cassandraClient) { + return new ArtifactCassandraDao(cassandraClient); } @Bean(name = "audit-cassandra-dao") - public AuditCassandraDao auditCassandraDao() { - return new AuditCassandraDao(); + public AuditCassandraDao auditCassandraDao(CassandraClient cassandraClient) { + return new AuditCassandraDao(cassandraClient); } @Bean(name = "cassandra-client") @@ -50,7 +50,7 @@ public class EsToCassandraDataMigrationConfig { } @Bean(name = "sdc-schema-files-cassandra-dao") - public SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao() { - return new SdcSchemaFilesCassandraDao(); + public SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao(CassandraClient cassandraClient) { + return new SdcSchemaFilesCassandraDao(cassandraClient); } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java index 02b37b7d21..a1dec76354 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java @@ -64,8 +64,8 @@ public class ValidationToolConfiguration { public ReportManager reportManager() { return new ReportManager();} @Bean(name = "artifact-cassandra-dao") - public ArtifactCassandraDao artifactCassandraDao() { - return new ArtifactCassandraDao(); + public ArtifactCassandraDao artifactCassandraDao(CassandraClient cassandraClient) { + return new ArtifactCassandraDao(cassandraClient); } @Bean diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java index a18d644f08..a4906ed031 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java @@ -10,6 +10,7 @@ import org.openecomp.sdc.asdctool.migration.service.SdcRepoService; import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder; import org.openecomp.sdc.be.components.scheduledtasks.ComponentsCleanBusinessLogic; import org.openecomp.sdc.be.config.CatalogModelSpringConfig; +import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.openecomp.sdc.be.dao.config.DAOSpringConfig; import org.openecomp.sdc.config.CatalogBESpringConfig; import org.springframework.beans.factory.annotation.Autowired; @@ -52,8 +53,8 @@ public class MigrationSpringConfig { } @Bean(name = "sdc-migration-tasks-cassandra-dao") - public MigrationTasksDao migrationTasksDao() { - return new MigrationTasksDao(); + public MigrationTasksDao migrationTasksDao(CassandraClient cassandraClient) { + return new MigrationTasksDao(cassandraClient); } @Bean(name = "serviceDistributionArtifactsBuilder") diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java index e1144c14b5..c9473541d6 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java @@ -7,21 +7,30 @@ import com.datastax.driver.mapping.Mapper; import com.datastax.driver.mapping.MappingManager; import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; +import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.openecomp.sdc.be.dao.cassandra.CassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; import org.openecomp.sdc.be.resources.data.MigrationTaskEntry; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; import org.openecomp.sdc.common.log.wrappers.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import java.math.BigInteger; +@Service public class MigrationTasksDao extends CassandraDao { private static Logger logger = Logger.getLogger(MigrationTasksDao.class.getName()); private MigrationTasksAccessor migrationTasksAccessor; private Mapper<MigrationTaskEntry> migrationTaskMapper; + @Autowired + public MigrationTasksDao(CassandraClient cassandraClient){ + super(cassandraClient); + } + @PostConstruct public void init() { String keyspace = AuditingTypesConstants.REPO_KEYSPACE; diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfig.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfig.java index 5ce4314361..8256a33ae3 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfig.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfig.java @@ -13,7 +13,7 @@ public class ImportTableConfig { } @Bean(name = "operational-environment-dao") - public OperationalEnvironmentDao operationalEnvironmentDao() { - return new OperationalEnvironmentDao(); + public OperationalEnvironmentDao operationalEnvironmentDao(CassandraClient cassandraClient) { + return new OperationalEnvironmentDao(cassandraClient); } } 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 +} |