### Question:
CoverageService { int flatIndex(List<AxisDTO> axes, int[] coordinates) { int index = coordinates[0]; int multiplier = 1; for (int i = 1; i < coordinates.length; ++i) { multiplier *= axes.get(i - 1).getPoints().size(); index += coordinates[i] * multiplier; } return index; }  CoverageDTO computeCoverage(long projectId);  }### Answer:
@Test public void flatIndex_should_work_with_one_dimension() { List<AxisDTO> axes = Collections.singletonList( dimensionOfSize(3)); int[] coordinates = new int[] { 2 }; final int flatIndex = cut.flatIndex(axes, coordinates); assertThat(flatIndex).isEqualTo(2); }
@Test public void flatIndex_should_work_with_two_dimensions() { List<AxisDTO> axes = Arrays.asList( dimensionOfSize(4), dimensionOfSize(5)); int[] coordinates = new int[] { 2, 3 }; final int flatIndex = cut.flatIndex(axes, coordinates); assertThat(flatIndex).isEqualTo(14); }
@Test public void flatIndex_should_work_with_three_dimensions() { List<AxisDTO> axes = Arrays.asList( dimensionOfSize(6), dimensionOfSize(7), dimensionOfSize(8)); int[] coordinates = new int[] { 3, 4, 5 }; final int flatIndex = cut.flatIndex(axes, coordinates); assertThat(flatIndex).isEqualTo(237); }