aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test
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 /catalog-dao/src/test
parent868746d27adc90efeba5909d3eb60a6e0cd24c27 (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 'catalog-dao/src/test')
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDaoTest.java21
1 files changed, 16 insertions, 5 deletions
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
+}