I need to write test cases for VoltDb procedures using mockito framework . The database returns as array of tables from which I need to get the table using index number and then iterate rows to get values from columns . So if I could get a sample on mocking voltdb connection, table and result it would be great.
Client voltDbClient;
@Mock
DAOFactory daoFactory;
@Test
public void testGetECMPWaitOverSelect() throws Exception {
String procedure = "Procedure Name is here";
int offset = PropertiesLoader.getIntValue(PropertiesLoader.OFFSET);
int fetchlimit = PropertiesLoader.getIntValue(PropertiesLoader.WAITOVER_FETCH_LIMIT);
Mockito.when(voltDbClient.callProcedure(procedure, offset,fetchlimit)).thenReturn(voltDbClient.callProcedure(procedure, offset, fetchlimit));
VoltTable[] voltTable = voltDbClient.callProcedure(procedure, offset, fetchlimit).getResults();
Mockito.verify(voltDbClient,Mockito.times(1)).callProcedure(procedure, offset, fetchlimit);
}
I expected the table to get mocked results as the class is mocked and verify db procedure is executed or no but since it is not the right way to do it, i did not get appropriate results.