TreatmentsResource extends BaseResource { @GET public Iterable<TreatmentDto> getTreatments(@PathParam("experimentName") String experimentName) { return mapper.toDto( ensureExists(experiments.get(experimentName)).getTreatments(), TreatmentDto.class ); } @Inject  TreatmentsResource(Experiments experiments, Mappers mapper); @GET Iterable<TreatmentDto> getTreatments(@PathParam("experimentName") String experimentName); @GET @Path("/{treatmentName}") TreatmentDto getTreatment(@PathParam("experimentName") String experimentName,
                                     @PathParam("treatmentName") String treatmentName); @PUT Response addTreatment(@PathParam("experimentName") String experimentName,
                                 @Valid TreatmentDto treatmentDto); @DELETE @Path("/{treatmentName}") void removeTreatment(@PathParam("experimentName") String experimentName,
                                @PathParam("treatmentName") String treatmentName); @POST @Path("/{treatmentName}") void updateTreatment(@PathParam("experimentName") String experimentName,
                                @PathParam("treatmentName") String treatmentName,
                                @Valid UpdateTreatmentRequest request); @DELETE void clearTreatments(@PathParam("experimentName") String experimentName);  }
@Test public void testGetTreatments() { get(TREATMENTS_ENDPOINT, EXPERIMENT_BAD) .assertStatus(Status.NOT_FOUND); final Iterable<TreatmentDto> expected = MAPPER.toDto(experiment(EXPERIMENT_1).getTreatments(), TreatmentDto.class); final Iterable<TreatmentDto> actual = get(TREATMENTS_ENDPOINT, EXPERIMENT_1) .assertStatus(Status.OK) .result(iterable(TreatmentDto.class)); assertEquals(expected, actual); }