@Test public void testAddTreatment() { final TreatmentDto expected = new TreatmentDto("new_treatment", "this is a new treatment"); put(TREATMENTS_ENDPOINT, EXPERIMENT_BAD) .entity(expected) .assertStatus(Status.NOT_FOUND); put(TREATMENTS_ENDPOINT, EXPERIMENT_1) .entity(expected) .assertStatus(Status.CREATED); final TreatmentDto actual = MAPPER.toDto(experiment(EXPERIMENT_1).getTreatment(expected.getName()), TreatmentDto.class); assertEquals(expected, actual); }
@PUT public Response addTreatment(@PathParam("experimentName") String experimentName, @Valid TreatmentDto treatmentDto) { ensureExists(experiments.get(experimentName)) .addTreatment(treatmentDto.getName(), treatmentDto.getDescription()) .save(); return created(); }
TreatmentsResource extends BaseResource { @PUT public Response addTreatment(@PathParam("experimentName") String experimentName, @Valid TreatmentDto treatmentDto) { ensureExists(experiments.get(experimentName)) .addTreatment(treatmentDto.getName(), treatmentDto.getDescription()) .save(); return created(); } }
TreatmentsResource extends BaseResource { @PUT public Response addTreatment(@PathParam("experimentName") String experimentName, @Valid TreatmentDto treatmentDto) { ensureExists(experiments.get(experimentName)) .addTreatment(treatmentDto.getName(), treatmentDto.getDescription()) .save(); return created(); } @Inject  TreatmentsResource(Experiments experiments, Mappers mapper); }
TreatmentsResource extends BaseResource { @PUT public Response addTreatment(@PathParam("experimentName") String experimentName, @Valid TreatmentDto treatmentDto) { ensureExists(experiments.get(experimentName)) .addTreatment(treatmentDto.getName(), treatmentDto.getDescription()) .save(); return created(); } @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); }
TreatmentsResource extends BaseResource { @PUT public Response addTreatment(@PathParam("experimentName") String experimentName, @Valid TreatmentDto treatmentDto) { ensureExists(experiments.get(experimentName)) .addTreatment(treatmentDto.getName(), treatmentDto.getDescription()) .save(); return created(); } @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);  }