@Test public void testGetBetween() throws Exception { mockMvc .perform( get(REST_URL + "between?startDateTime=2015-05-30T07:00&endDateTime=2015-05-31T11:00:00") .with(userHttpBasic(USER))) .andExpect(status().isOk()) .andDo(print()) .andExpect( MATCHER_WITH_EXCEED.contentListMatcher( UserMealsUtil.createWithExceed(MEAL4, true), UserMealsUtil.createWithExceed(MEAL1, false))); }
@Test public void testGetAll() throws Exception { mockMvc .perform(get(REST_URL).contentType(MediaType.APPLICATION_JSON).with(userHttpBasic(USER))) .andExpect(status().isOk()) .andDo(print()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect( MATCHER_WITH_EXCEED.contentListMatcher( UserMealsUtil.getWithExceeded(USER_MEALS, USER.getCaloriesPerDay()))); }
@Test public void testFilterAll() throws Exception { mockMvc .perform(get(REST_URL + "filter?startDate=&endTime=").with(userHttpBasic(USER))) .andExpect(status().isOk()) .andDo(print()) .andExpect( MATCHER_WITH_EXCEED.contentListMatcher( UserMealsUtil.getWithExceeded( Arrays.asList(MEAL6, MEAL5, MEAL4, MEAL3, MEAL2, MEAL1), USER.getCaloriesPerDay()))); }
public List<UserMealWithExceed> getBetween( LocalDate startDate, LocalTime startTime, LocalDate endDate, LocalTime endTime) { int userId = LoggedUser.id(); LOG.info( "getBetween dates {} - {} for time {} - {} for User {}", startDate, endDate, startTime, endTime, userId); return UserMealsUtil.getFilteredWithExceeded( service.getBetweenDates(startDate, endDate, userId), startTime, endTime, LoggedUser.getCaloriesPerDay()); }
public List<UserMealWithExceed> getAll() { int userId = LoggedUser.id(); LOG.info("getAll for User {}", userId); return UserMealsUtil.getWithExceeded(service.getAll(userId), LoggedUser.getCaloriesPerDay()); }