### Question:
CoverageService { int indexOf(List<AxisPointDTO> points, String id) { for (int i = 0; i < points.size(); i++) { if (id.equals(points.get(i).getId())) { return i; } } throw new NotGonnaHappenException("Ids are generated from the points, so it's unlikely an unknown id will be requested"); }  CoverageDTO computeCoverage(long projectId);  }### Answer:
@Test public void indexOf_should_return_index_of_requested_id_at_start() { List<AxisPointDTO> points = Arrays.asList( new AxisPointDTO().withId("1"), new AxisPointDTO().withId("2")); final int index = cut.indexOf(points, "1"); assertThat(index).isEqualTo(0); }
@Test public void indexOf_should_return_index_of_requested_id_in_middle() { List<AxisPointDTO> points = Arrays.asList( new AxisPointDTO().withId("1"), new AxisPointDTO().withId("2"), new AxisPointDTO().withId("3")); final int index = cut.indexOf(points, "3"); assertThat(index).isEqualTo(2); }
@Test() public void indexOf_should_throw_NotGonnaHappenException_on_unknown_id_which_will_assert_false() { List<AxisPointDTO> points = Collections.emptyList(); assertThrows(NotGonnaHappenException.class, () -> cut.indexOf(points, "404")); }