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 --- .../be/dao/cassandra/ArtifactCassandraDaoTest.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'catalog-dao/src/test/java') 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 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 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 +} -- cgit 1.2.3-korg