summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-06-27 12:35:47 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-07-07 08:22:31 +0000
commitbf2ffad5b686eb0ffddbeeeca5824b8caea0c8ff (patch)
tree53e09d40e18b4aecff6f501633d374b87c4688be
parent868746d27adc90efeba5909d3eb60a6e0cd24c27 (diff)
Remove field injection in catalog-dao
Change-Id: I24c3a898fa34491e80074944614722fbb3085515 Issue-ID: SDC-2398 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java12
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java5
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java9
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfig.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java10
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java7
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDaoTest.java9
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/resolver/SpringBeansMigrationResolverTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/simulator/tenant/ImportTableConfigTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java44
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java7
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java8
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDaoTest.java21
-rw-r--r--test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java4
26 files changed, 147 insertions, 71 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
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
index 48b79eafd3..e5462c6d71 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
@@ -25,6 +25,7 @@ import org.junit.Test;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.openecomp.sdc.be.dao.impl.AuditingDao;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
@@ -41,13 +42,15 @@ import fj.data.Either;
import mockit.Deencapsulation;
import org.openecomp.sdc.test.utils.TestConfigurationProvider;
+import static org.mockito.Mockito.mock;
+
public class CertificationRequestTransitionTest extends LifecycleTestBase {
private CertificationRequestTransition createTestSubject() {
return new CertificationRequestTransition(
- new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(), new TestConfigurationProvider())),
+ new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(mock(CassandraClient.class)), new TestConfigurationProvider())),
new ToscaElementLifecycleOperation(), new ServiceBusinessLogic(), new ToscaOperationFacade(), new JanusGraphDao(new JanusGraphClient()));
}
@@ -92,4 +95,4 @@ public class CertificationRequestTransitionTest extends LifecycleTestBase {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "validateConfiguredAtomicReqCapSatisfied", component);
}
-} \ No newline at end of file
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java
index 290ba07883..1e913ed798 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java
@@ -1,12 +1,18 @@
package org.openecomp.sdc.be.components.path.beans;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component("artifact-cassandra-dao")
public class ArtifactCassandraDaoMock extends ArtifactCassandraDao {
+
+ public ArtifactCassandraDaoMock(CassandraClient cassandraClient) {
+ super(cassandraClient);
+ }
+
@PostConstruct
@Override
public void init() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java
index c4885e1f07..ce50d586b5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.be.components.path.beans;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -8,6 +9,10 @@ import javax.annotation.PostConstruct;
@Component("audit-cassandra-dao")
public class AuditCassandraDaoMock extends AuditCassandraDao{
+ public AuditCassandraDaoMock(CassandraClient cassandraClient) {
+ super(cassandraClient);
+ }
+
@PostConstruct
public void init() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java
index 6a9731e86d..65d4219aa7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java
@@ -3,6 +3,7 @@ package org.openecomp.sdc.be.components.path.beans;
import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.cassandra.ComponentCacheAccessor;
import org.openecomp.sdc.be.dao.cassandra.ComponentCassandraDao;
@@ -20,8 +21,8 @@ public class ComponentCassandraDaoMock extends ComponentCassandraDao {
public static Integer DEFAULT_FETCH_SIZE = 500;
private ComponentCacheAccessor componentCacheAccessor;
- public ComponentCassandraDaoMock() {
- super();
+ public ComponentCassandraDaoMock(CassandraClient cassandraClient) {
+ super(cassandraClient);
}
@PostConstruct
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java
index 2d7b1ad287..3ddda8a987 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java
@@ -1,5 +1,6 @@
package org.openecomp.sdc.be.components.path.beans;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao;
import org.springframework.stereotype.Component;
@@ -7,6 +8,11 @@ import javax.annotation.PostConstruct;
@Component("operational-environment-dao")
public class EnvironmentCassandraDaoMock extends OperationalEnvironmentDao {
+
+ public EnvironmentCassandraDaoMock(CassandraClient cassandraClient) {
+ super(cassandraClient);
+ }
+
@PostConstruct
@Override
public void init() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java
index 4e0105f067..a4d634ae56 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java
@@ -1,5 +1,6 @@
package org.openecomp.sdc.be.components.path.beans;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
import org.springframework.stereotype.Component;
@@ -8,6 +9,10 @@ import javax.annotation.PostConstruct;
@Component("sdc-schema-files-cassandra-dao")
public class SdcSchemaFilesCassandraDaoMock extends SdcSchemaFilesCassandraDao {
+ public SdcSchemaFilesCassandraDaoMock(CassandraClient cassandraClient) {
+ super(cassandraClient);
+ }
+
@PostConstruct
@Override
public void init() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
index fdcd6d8c75..b76ac2e70f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
@@ -33,6 +33,7 @@ import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
import org.openecomp.sdc.be.dao.impl.AuditingDao;
@@ -55,12 +56,13 @@ import java.util.List;
import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ComponentsUtilsTest {
private ComponentsUtils createTestSubject() {
- return new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(), new TestConfigurationProvider()));
+ return new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(mock(CassandraClient.class)), new TestConfigurationProvider()));
}
@Before
@@ -68,7 +70,7 @@ public class ComponentsUtilsTest {
String appConfigDir = "src/test/resources/config/catalog-be";
ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
- ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
+ ComponentsUtils componentsUtils = new ComponentsUtils(mock(AuditingManager.class));
}
@Test
@@ -611,7 +613,7 @@ public class ComponentsUtilsTest {
@Test
public void testconvertJsonToObject() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
@@ -628,7 +630,7 @@ public class ComponentsUtilsTest {
@Test
public void testconvertJsonToObject_NllData() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
User user = new User();
@@ -641,7 +643,7 @@ public class ComponentsUtilsTest {
@Test
public void testconvertJsonToObjectInvalidData() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
@@ -657,7 +659,7 @@ public class ComponentsUtilsTest {
@Test
public void testconvertToStorageOperationStatus() {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Assert.assertEquals(StorageOperationStatus.OK,compUtils.convertToStorageOperationStatus(CassandraOperationStatus.OK));
@@ -669,7 +671,7 @@ public class ComponentsUtilsTest {
@Test
public void testgetResponseFormatByDataType() {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
DataTypeDefinition dataType = new DataTypeDefinition();
@@ -683,7 +685,7 @@ public class ComponentsUtilsTest {
@Test
public void testGetResponseFormatByPolicyType_POLICY_TYPE_ALREADY_EXIST() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
PolicyTypeDefinition policyType = new PolicyTypeDefinition();
@@ -696,7 +698,7 @@ public class ComponentsUtilsTest {
@Test
public void testGetResponseFormatByPolicyType_PolicyID_NULL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
ResponseFormat responseFormat = compUtils.getResponseFormatByPolicyType(ActionStatus.POLICY_TYPE_ALREADY_EXIST, null);
@@ -707,7 +709,7 @@ public class ComponentsUtilsTest {
@Test
public void testGetResponseFormatByGroupType_GROUP_MEMBER_EMPTY() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
GroupTypeDefinition groupType = new GroupTypeDefinition();
@@ -721,7 +723,7 @@ public class ComponentsUtilsTest {
@Test
public void testConvertFromStorageResponseForDataType_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
@@ -738,7 +740,7 @@ public class ComponentsUtilsTest {
@Test
public void testConvertFromStorageResponseForGroupType_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
@@ -752,7 +754,7 @@ public class ComponentsUtilsTest {
@Test
public void testConvertFromStorageResponseForConsumer_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
@@ -767,7 +769,7 @@ public class ComponentsUtilsTest {
@Test
public void testGetResponseFormatAdditionalProperty_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
@@ -802,7 +804,7 @@ public class ComponentsUtilsTest {
@Test
public void testConvertFromResultStatusEnum_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Assert.assertEquals(ActionStatus.OK,compUtils.convertFromResultStatusEnum(ResultStatusEnum.OK, null));
@@ -815,7 +817,7 @@ public class ComponentsUtilsTest {
@Test
public void testconvertFromStorageResponseForAdditionalInformation() throws Exception{
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Assert.assertEquals(ActionStatus.OK,compUtils.convertFromStorageResponseForAdditionalInformation(StorageOperationStatus.OK));
@@ -825,7 +827,7 @@ public class ComponentsUtilsTest {
@Test
public void testgetResponseFormatByComponent() throws Exception{
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Component component = new Resource();
@@ -846,7 +848,7 @@ public class ComponentsUtilsTest {
@Test
public void testConvertFromStorageResponseForResourceInstanceProperty_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Assert.assertEquals(ActionStatus.OK,compUtils.convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus.OK));
@@ -860,7 +862,7 @@ public class ComponentsUtilsTest {
@Test
public void testConvertFromStorageResponseForResourceInstance_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponseForResourceInstance(StorageOperationStatus.ARTIFACT_NOT_FOUND, false));
@@ -877,7 +879,7 @@ public class ComponentsUtilsTest {
@Test
public void testConvertFromStorageResponse_ALL() throws Exception {
- AuditingManager auditingmanager = Mockito.mock(AuditingManager.class);
+ AuditingManager auditingmanager = mock(AuditingManager.class);
ComponentsUtils compUtils = new ComponentsUtils(auditingmanager);
when(auditingmanager.auditEvent(any())).thenReturn("OK");
Assert.assertEquals(ActionStatus.GENERAL_ERROR,compUtils.convertFromStorageResponse(StorageOperationStatus.CONNECTION_FAILURE, ComponentTypeEnum.RESOURCE));
@@ -899,4 +901,4 @@ public class ComponentsUtilsTest {
Assert.assertEquals(ActionStatus.INVALID_PROPERTY,compUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_PROPERTY, ComponentTypeEnum.RESOURCE));
Assert.assertEquals(ActionStatus.COMPONENT_IS_ARCHIVED,compUtils.convertFromStorageResponse(StorageOperationStatus.COMPONENT_IS_ARCHIVED, ComponentTypeEnum.RESOURCE));
}
-} \ No newline at end of file
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java
index 8449e676ca..30da6bce6e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java
@@ -28,6 +28,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
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.Component;
import javax.annotation.PostConstruct;
@@ -38,8 +39,10 @@ public class ArtifactCassandraDao extends CassandraDao {
private static Logger logger = Logger.getLogger(ArtifactCassandraDao.class.getName());
private ArtifactAccessor artifactAccessor;
- public ArtifactCassandraDao() {
- super();
+
+ @Autowired
+ public ArtifactCassandraDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
index d5c8a19f06..7c27fc912a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
@@ -30,6 +30,7 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.schema.Table;
import org.openecomp.sdc.be.resources.data.auditing.*;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -43,8 +44,9 @@ public class AuditCassandraDao extends CassandraDao {
private static Logger logger = Logger.getLogger(AuditCassandraDao.class.getName());
- public AuditCassandraDao() {
- super();
+ @Autowired
+ public AuditCassandraDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
}
@PostConstruct
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
index 284b91ac74..3eba7ae54a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
@@ -27,7 +27,6 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.mapping.MappingManager;
import fj.data.Either;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
public abstract class CassandraDao {
@@ -36,9 +35,12 @@ public abstract class CassandraDao {
protected Session session;
protected MappingManager manager;
- @Autowired
protected CassandraClient client;
+ public CassandraDao(CassandraClient cassandraClient) {
+ this.client = cassandraClient;
+ }
+
/**
* the method checks if the given table is empty under the keyspace the
* session was opened to.
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java
index 11643d16e8..7b23a9db41 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java
@@ -30,6 +30,7 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.resources.data.ComponentCacheData;
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.Component;
import javax.annotation.PostConstruct;
@@ -45,9 +46,10 @@ public class ComponentCassandraDao extends CassandraDao {
private ComponentCacheAccessor componentCacheAccessor;
- public ComponentCassandraDao() {
- super();
+ @Autowired
+ public ComponentCassandraDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
}
@PostConstruct
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
index 783eb9533b..9e1bfd8c35 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
@@ -10,6 +10,7 @@ import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -22,8 +23,9 @@ public class OperationalEnvironmentDao extends CassandraDao {
private static Logger logger = Logger.getLogger(OperationalEnvironmentDao.class.getName());
private OperationalEnvironmentsAccessor operationalEnvironmentsAccessor;
- public OperationalEnvironmentDao() {
- super();
+ @Autowired
+ public OperationalEnvironmentDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
}
@PostConstruct
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java
index a9ca4e845b..76aaad95a5 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java
@@ -28,6 +28,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
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.Component;
import javax.annotation.PostConstruct;
@@ -38,9 +39,10 @@ public class SdcSchemaFilesCassandraDao extends CassandraDao {
private static Logger logger = Logger.getLogger(SdcSchemaFilesCassandraDao.class.getName());
private SdcSchemaFilesAccessor sdcSchemaFilesAccessor;
-
- public SdcSchemaFilesCassandraDao() {
- super();
+
+ @Autowired
+ public SdcSchemaFilesCassandraDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
}
@PostConstruct
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDaoTest.java
index 0bbe2b6e03..dcd92aef45 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDaoTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDaoTest.java
@@ -13,17 +13,21 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
public class ArtifactCassandraDaoTest {
@InjectMocks
- ArtifactCassandraDao testSubject;
+ private ArtifactCassandraDao testSubject;
@Mock
- CassandraClient client;
+ private CassandraClient client;
@Mock
- ArtifactAccessor artifactAccessor;
+ private ArtifactAccessor artifactAccessor;
+
+ @Mock
+ private MappingManager mappingManager;
@Before
public void setUp() throws Exception {
@@ -89,6 +93,9 @@ public class ArtifactCassandraDaoTest {
@Test
public void testGetCountOfArtifactById() throws Exception {
+ Mockito.when(client.isConnected()).thenReturn(true);
+ Mockito.when(client.connect(AuditingTypesConstants.ARTIFACT_KEYSPACE)).thenReturn(Either.left(ImmutablePair.of(null,mappingManager)));
+ Mockito.when(mappingManager.createAccessor(ArtifactAccessor.class)).thenReturn(artifactAccessor);
String uniqeId = "mock";
Either<Long, CassandraOperationStatus> result;
ResultSet value = Mockito.mock(ResultSet.class);
@@ -98,17 +105,21 @@ public class ArtifactCassandraDaoTest {
Mockito.when(artifactAccessor.getNumOfArtifactsById(uniqeId)).thenReturn(value);
// default test
+ testSubject.init();
result = testSubject.getCountOfArtifactById(uniqeId);
}
@Test
public void testGetCountOfArtifactById1() throws Exception {
+ Mockito.when(client.isConnected()).thenReturn(true);
+ Mockito.when(client.connect(AuditingTypesConstants.ARTIFACT_KEYSPACE)).thenReturn(Either.left(ImmutablePair.of(null,mappingManager)));
+ Mockito.when(mappingManager.createAccessor(ArtifactAccessor.class)).thenReturn(artifactAccessor);
String uniqeId = "mock";
Either<Long, CassandraOperationStatus> result;
ResultSet value = Mockito.mock(ResultSet.class);
Mockito.when(artifactAccessor.getNumOfArtifactsById(uniqeId)).thenReturn(null);
-
+ testSubject.init();
// default test
result = testSubject.getCountOfArtifactById(uniqeId);
}
-} \ No newline at end of file
+}
diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java
index f0c7610513..009071e2df 100644
--- a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java
+++ b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/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);
}
}