### Question:
OAuthConsumerDAO extends AbstractSearcherDAO implements IOAuthConsumerDAO { @Override public List<String> getConsumerKeys(FieldSearchFilter<?>[] filters) { return super.searchId(filters); }  @Override List<String> getConsumerKeys(FieldSearchFilter<?>[] filters); @Override ConsumerRecordVO getConsumer(String clientId); @Override List<ConsumerRecordVO> getConsumers(FieldSearchFilter<?>[] filters); @Override ConsumerRecordVO addConsumer(ConsumerRecordVO consumer); @Override ConsumerRecordVO updateConsumer(ConsumerRecordVO consumer); @Override void deleteConsumer(String clientId);  }### Answer:
@Test public void getConsumerKeys() throws Exception { when(this.stat.executeQuery()).thenReturn(res); Mockito.when(res.next()).thenReturn(true).thenReturn(false); List<String> keys = this.consumerDAO.getConsumerKeys(new FieldSearchFilter[]{}); Assert.assertNotNull(keys); Assert.assertEquals(1, keys.size()); this.executeFinalCheck(true); }
@Test(expected = RuntimeException.class) public void failGetConsumerKeys() throws Exception { when(this.stat.executeQuery()).thenThrow(SqlException.class); try { List<String> keys = this.consumerDAO.getConsumerKeys(new FieldSearchFilter[]{}); } catch (RuntimeException e) { throw e; } finally { this.executeFinalCheck(true); } }
@Test(expected = RuntimeException.class) public void failGetConsumer() throws Exception { when(this.stat.executeQuery()).thenReturn(res); Mockito.when(res.next()).thenReturn(true).thenReturn(false); Mockito.when(res.getString("consumerkey")).thenThrow(SqlException.class); try { List<String> keys = this.consumerDAO.getConsumerKeys(new FieldSearchFilter[]{}); } catch (RuntimeException e) { throw e; } finally { Mockito.verify(stat, Mockito.times(1)).setString(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(res, Mockito.times(1)).next(); this.executeFinalCheck(true); } }