### Question:
MeasurementsResource { @POST @Path("/{resource}") @Timed public Collection<Collection<MeasurementDTO>> getMeasurements( ResultDescriptorDTO descriptorDTO, @PathParam("resource") Resource resource, @QueryParam("start") Optional<TimestampParam> start, @QueryParam("end") Optional<TimestampParam> end, @QueryParam("resolution") Optional<DurationParam> resolution, @QueryParam("context") Optional<String> contextId) { Optional<Timestamp> lower = Transform.toTimestamp(start); Optional<Timestamp> upper = Transform.toTimestamp(end); Optional<Duration> step = Transform.toDuration(resolution); Context context = contextId.isPresent() ? new Context(contextId.get()) : Context.DEFAULT_CONTEXT; LOG.debug( "Retrieving measurements for resource {}, from {} to {} w/ resolution {} and w/ report {}", resource, lower, upper, step, descriptorDTO); ResultDescriptor rDescriptor = Transform.resultDescriptor(descriptorDTO); return Transform.measurementDTOs(m_repository.select(context, resource, lower, upper, rDescriptor, step)); } MeasurementsResource(SampleRepository repository, Map<String, ResultDescriptorDTO> reports); @POST @Path("/{resource}") @Timed Collection<Collection<MeasurementDTO>> getMeasurements(
            ResultDescriptorDTO descriptorDTO,
            @PathParam("resource") Resource resource,
            @QueryParam("start") Optional<TimestampParam> start,
            @QueryParam("end") Optional<TimestampParam> end,
            @QueryParam("resolution") Optional<DurationParam> resolution,
            @QueryParam("context") Optional<String> contextId); @GET @Path("/{report}/{resource}") @Timed Collection<Collection<MeasurementDTO>> getMeasurements(
            @PathParam("report") String report,
            @PathParam("resource") Resource resource,
            @QueryParam("start") Optional<TimestampParam> start,
            @QueryParam("end") Optional<TimestampParam> end,
            @QueryParam("resolution") Optional<DurationParam> resolution,
            @QueryParam("context") Optional<String> contextId);  }### Answer:
@Test public void testGetMeasurements() throws Exception { final Results<Measurement> results = new Results<>(); when( m_repository.select( eq(Context.DEFAULT_CONTEXT), eq(new Resource("localhost")), eq(Optional.of(Timestamp.fromEpochSeconds(900000000))), eq(Optional.of(Timestamp.fromEpochSeconds(900003600))), any(ResultDescriptor.class), eq(Optional.of(Duration.seconds(900)))) ).thenReturn(results); assertThat( m_resource.getMeasurements( "temps", new Resource("localhost"), Optional.of(new TimestampParam("1998-07-09T11:00:00-0500")), Optional.of(new TimestampParam("1998-07-09T12:00:00-0500")), Optional.of(new DurationParam("15m")), Optional.<String>absent()), CoreMatchers.instanceOf(Collection.class)); assertThat( m_resource.getMeasurements( getResultDescriptorDTO(), new Resource("localhost"), Optional.of(new TimestampParam("1998-07-09T11:00:00-0500")), Optional.of(new TimestampParam("1998-07-09T12:00:00-0500")), Optional.of(new DurationParam("15m")), Optional.<String>absent()), CoreMatchers.instanceOf(Collection.class)); }