Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
enricocolasante committed May 22, 2024
1 parent 927d790 commit 5654ec4
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,31 @@ public void setUp() {

@Test
void shouldReturnADateAtTheEndOfTheDayWhenAnEndDateIsPassedWithoutTime() throws Exception {
mockMvc.perform(get(ENDPOINT).param("before", "2001-06-17")).andExpect(status().isOk());
mockMvc.perform(get(ENDPOINT).param("end", "2001-06-17")).andExpect(status().isOk());

assertNull(actualStartDateTime);
assertEquals("2001-06-17T23:59:59", DateUtils.toLongDate(actualEndDateTime));
}

@Test
void shouldReturnADateWithTimeWhenAnEndDateIsPassedWithTime() throws Exception {
mockMvc
.perform(get(ENDPOINT).param("before", "2001-06-17T16:45:34"))
.andExpect(status().isOk());
mockMvc.perform(get(ENDPOINT).param("end", "2001-06-17T16:45:34")).andExpect(status().isOk());

assertNull(actualStartDateTime);
assertEquals("2001-06-17T16:45:34", DateUtils.toLongDate(actualEndDateTime));
}

@Test
void shouldReturnADateAtTheStartOfTheDayWhenAnStartDateIsPassedWithoutTime() throws Exception {
mockMvc.perform(get(ENDPOINT).param("after", "2001-06-17")).andExpect(status().isOk());
mockMvc.perform(get(ENDPOINT).param("start", "2001-06-17")).andExpect(status().isOk());

assertEquals("2001-06-17T00:00:00", DateUtils.toLongDate(actualStartDateTime));
assertNull(actualEndDateTime);
}

@Test
void shouldReturnADateWithTimeWhenAnStartDateIsPassedWithTime() throws Exception {
mockMvc.perform(get(ENDPOINT).param("after", "2001-06-17T16:45:34")).andExpect(status().isOk());
mockMvc.perform(get(ENDPOINT).param("start", "2001-06-17T16:45:34")).andExpect(status().isOk());

assertEquals("2001-06-17T16:45:34", DateUtils.toLongDate(actualStartDateTime));
assertNull(actualEndDateTime);
Expand All @@ -99,17 +97,17 @@ void shouldReturnADateWithTimeWhenAnStartDateIsPassedWithTime() throws Exception
private class BindingController {
@GetMapping(value = ENDPOINT)
public @ResponseBody WebMessage getDefault(Params params) {
actualStartDateTime = applyIfNotNull(params.getAfter(), StartDateTime::toDate);
actualEndDateTime = applyIfNotNull(params.getBefore(), EndDateTime::toDate);
actualStartDateTime = applyIfNotNull(params.getStart(), StartDateTime::toDate);
actualEndDateTime = applyIfNotNull(params.getEnd(), EndDateTime::toDate);
return ok();
}
}

@NoArgsConstructor
@Data

Check notice

Code scanning / CodeQL

Use of default toString() Note test

Default toString(): EndDateTime inherits toString() from Object, and so is not suitable for printing.
Default toString(): StartDateTime inherits toString() from Object, and so is not suitable for printing.
private class Params {

Check notice

Code scanning / CodeQL

Inner class could be static Note test

Params should be made static, since the enclosing instance is not used.
private StartDateTime after;
private StartDateTime start;

private EndDateTime before;
private EndDateTime end;
}
}

0 comments on commit 5654ec4

Please sign in to comment.