/******************************************************************************************************************* * * Returns the current year reading it from the path params, or by default from the calendar. * ******************************************************************************************************************/ @Nonnegative private int getCurrentYear (final @Nonnull String pathParams) throws HttpStatusException { try { return "".equals(pathParams) ? new DateTime().getYear() : Integer.parseInt(pathParams.replaceAll("/$", "").replaceAll("^/", "")); // return "".equals(pathParams) ? new DateTime().getYear() : Integer.parseInt(pathParams.replaceAll("/", "")); } catch (NumberFormatException e) { throw new HttpStatusException(404); } } }
throw new HttpStatusException(404);
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test public void must_call_some_RequestProcessors_when_HttpStatusException_with_generic_Http_status() throws Exception { final HttpStatusException e = new HttpStatusException(SC_NOT_ACCEPTABLE); mockRequestProcessor3.setThrowable(e); commonExceptionTestSequence(); verify(responseBuilder).forException(same(e)); // inOrder.verifyNoMoreInteractions(); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test public void must_call_some_RequestProcessors_when_HttpStatusException_with_SC_FOUND() throws Exception { final HttpStatusException e = new HttpStatusException(SC_FOUND); mockRequestProcessor3.setThrowable(e); commonExceptionTestSequence(); verify(responseBuilder).forException(same(e)); // inOrder.verifyNoMoreInteractions(); }