ConsumerAuthUtil { public Long getConsumerId(String token) { return consumerService.getConsumerIdByToken(token); } ConsumerAuthUtil(final ConsumerService consumerService); Long getConsumerId(String token); void storeConsumerId(HttpServletRequest request, Long consumerId); long retrieveConsumerId(HttpServletRequest request);  }
@Test public void testGetConsumerId() throws Exception { String someToken = "someToken"; Long someConsumerId = 1L; when(consumerService.getConsumerIdByToken(someToken)).thenReturn(someConsumerId); assertEquals(someConsumerId, consumerAuthUtil.getConsumerId(someToken)); verify(consumerService, times(1)).getConsumerIdByToken(someToken); }