@Test public void getRequestTimeUsesCurrentTimeWhenNotSupplied() { @SuppressWarnings("serial") AbstractServlet srv = new AbstractServlet() {}; HttpServletRequest req = Mockito.mock(HttpServletRequest.class); ScheduledTime before = new ScheduledTime(DateTime.now(DateTimeZone.UTC)); Mockito.when(req.getParameter("time")).thenReturn(null); ScheduledTime t = srv.getRequestTime(req); ScheduledTime after = new ScheduledTime(DateTime.now(DateTimeZone.UTC)); Assert.assertTrue(before.compareTo(t) <= 0); Assert.assertTrue(t.compareTo(after) <= 0); }
protected ScheduledTime getRequestTime(HttpServletRequest req) { String t = req.getParameter(CelosClient.TIME_PARAM); if (t == null) { return new ScheduledTime(DateTime.now(DateTimeZone.UTC)); } else { return new ScheduledTime(t); } }
AbstractServlet extends HttpServlet { protected ScheduledTime getRequestTime(HttpServletRequest req) { String t = req.getParameter(CelosClient.TIME_PARAM); if (t == null) { return new ScheduledTime(DateTime.now(DateTimeZone.UTC)); } else { return new ScheduledTime(t); } } }
AbstractServlet extends HttpServlet { protected ScheduledTime getRequestTime(HttpServletRequest req) { String t = req.getParameter(CelosClient.TIME_PARAM); if (t == null) { return new ScheduledTime(DateTime.now(DateTimeZone.UTC)); } else { return new ScheduledTime(t); } }  }
AbstractServlet extends HttpServlet { protected ScheduledTime getRequestTime(HttpServletRequest req) { String t = req.getParameter(CelosClient.TIME_PARAM); if (t == null) { return new ScheduledTime(DateTime.now(DateTimeZone.UTC)); } else { return new ScheduledTime(t); } }  @Override void service(HttpServletRequest req, HttpServletResponse res); }
AbstractServlet extends HttpServlet { protected ScheduledTime getRequestTime(HttpServletRequest req) { String t = req.getParameter(CelosClient.TIME_PARAM); if (t == null) { return new ScheduledTime(DateTime.now(DateTimeZone.UTC)); } else { return new ScheduledTime(t); } }  @Override void service(HttpServletRequest req, HttpServletResponse res); static final String SCHEDULER_ATTR; }