### Question:
OAuthConsumerManager extends AbstractOAuthManager implements IOAuthConsumerManager { @Override public ConsumerRecordVO getConsumerRecord(String consumerKey) throws ApsSystemException { ConsumerRecordVO consumer = null; try { consumer = this.getConsumerDAO().getConsumer(consumerKey); } catch (Exception t) { logger.error("Error extracting consumer record by key {}", consumerKey, t); throw new ApsSystemException("Error extracting consumer record by key " + consumerKey, t); } return consumer; }  @Override void init(); @Override ClientDetails loadClientByClientId(String clientId); @Override ConsumerRecordVO getConsumerRecord(String consumerKey); @Override ConsumerRecordVO addConsumer(ConsumerRecordVO consumer); @Override ConsumerRecordVO updateConsumer(ConsumerRecordVO consumer); @Override void deleteConsumer(String clientId); @Override List<String> getConsumerKeys(FieldSearchFilter<?>[] filters); void setConsumerDAO(IOAuthConsumerDAO consumerDAO); @Override List<ConsumerRecordVO> getConsumers(FieldSearchFilter<?>[] filters);  }### Answer:
@Test public void getConsumer() throws Exception { ConsumerRecordVO record = this.createMockConsumer("key_1", "secret", false); when(this.consumerDAO.getConsumer(Mockito.anyString())).thenReturn(record); ConsumerRecordVO extracted = this.consumerManager.getConsumerRecord("key"); Assert.assertEquals(record, extracted); Mockito.verify(consumerDAO, Mockito.times(1)).getConsumer(Mockito.anyString()); }
@Test(expected = ApsSystemException.class) public void failGetConsumer() throws Exception { Mockito.doThrow(RuntimeException.class).when(this.consumerDAO).getConsumer(Mockito.anyString()); try { ConsumerRecordVO extracted = this.consumerManager.getConsumerRecord("key"); } catch (ApsSystemException e) { throw e; } finally { Mockito.verify(consumerDAO, Mockito.times(1)).getConsumer(Mockito.anyString()); } }