public long retrieveConsumerId(HttpServletRequest request) {
    Object value = request.getAttribute(CONSUMER_ID);

    try {
      return Long.parseLong(value.toString());
    } catch (Throwable ex) {
      throw new IllegalStateException("No consumer id!", ex);
    }
  }
@Test(expected = IllegalStateException.class)
  public void testRetrieveConsumerIdWithConsumerIdInvalid() throws Exception {
    String someInvalidConsumerId = "abc";

    when(request.getAttribute(ConsumerAuthUtil.CONSUMER_ID)).thenReturn(someInvalidConsumerId);
    consumerAuthUtil.retrieveConsumerId(request);
  }