### Question:
OAuthConsumerDAO extends AbstractSearcherDAO implements IOAuthConsumerDAO { @Override public ConsumerRecordVO updateConsumer(ConsumerRecordVO consumer) { Connection conn = null; PreparedStatement stat = null; int index = 1; try { conn = this.getConnection(); conn.setAutoCommit(false); String query = (!StringUtils.isBlank(consumer.getSecret())) ? UPDATE_CONSUMER_WITH_SECRET : UPDATE_CONSUMER; stat = conn.prepareStatement(query); index = this.fillStatement(consumer, index, false, stat); stat.setString(index++, consumer.getKey()); stat.executeUpdate(); conn.commit(); } catch (SQLException | ApsSystemException t) { this.executeRollback(conn); logger.error("Error while updating a consumer", t); throw new RuntimeException("Error while updating 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 updateConsumer() throws Exception { ConsumerRecordVO record = this.createMockConsumer("key_3", null); this.consumerDAO.updateConsumer(record); Mockito.verify(stat, Mockito.times(6)).setString(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(stat, Mockito.times(1)).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); this.executeFinalCheck(false); }
@Test(expected = RuntimeException.class) public void failUpdateConsumer() throws Exception { Mockito.doThrow(SqlException.class).when(stat).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); ConsumerRecordVO record = this.createMockConsumer("key_4", null); try { this.consumerDAO.updateConsumer(record); } catch (RuntimeException e) { throw e; } finally { Mockito.verify(stat, Mockito.times(6)).setString(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(stat, Mockito.times(1)).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); this.executeFinalCheck(false); } }