### Question:
OAuthConsumerDAO extends AbstractSearcherDAO implements IOAuthConsumerDAO { @Override public ConsumerRecordVO addConsumer(ConsumerRecordVO consumer) { Connection conn = null; PreparedStatement stat = null; int index = 1; try { conn = this.getConnection(); conn.setAutoCommit(false); stat = conn.prepareStatement(ADD_CONSUMER); stat.setString(index++, consumer.getKey()); this.fillStatement(consumer, index, true, stat); stat.executeUpdate(); conn.commit(); } catch (SQLException | ApsSystemException t) { this.executeRollback(conn); logger.error("Error while adding a consumer", t); throw new RuntimeException("Error while adding a consumer", t); } finally { closeDaoResources(null, stat, conn); } return consumer; }  @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 addConsumer() throws Exception { ConsumerRecordVO record = this.createMockConsumer("key_1", "secret"); this.consumerDAO.addConsumer(record); Mockito.verify(stat, Mockito.times(7)).setString(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(stat, Mockito.times(2)).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); this.executeFinalCheck(false); }
@Test(expected = RuntimeException.class) public void failAddConsumer() throws Exception { Mockito.doThrow(SqlException.class).when(stat).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); ConsumerRecordVO record = this.createMockConsumer("key_2", "secret"); try { this.consumerDAO.addConsumer(record); } catch (RuntimeException e) { throw e; } finally { Mockito.verify(stat, Mockito.times(7)).setString(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(stat, Mockito.times(1)).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); this.executeFinalCheck(false); } }