@Test public void testAddOverride() { final TreatmentOverrideRequest request = new TreatmentOverrideRequest("control", "qa", "qa_control"); put(ENDPOINT_OVERRIDES, EXPERIMENT_BAD) .entity(request) .assertStatus(Status.NOT_FOUND); final TreatmentOverrideDto expected = new TreatmentOverrideDto( request.getName(), request.getFilter(), request.getTreatment() ); put(ENDPOINT_OVERRIDES, EXPERIMENT_1) .entity(request) .assertStatus(Status.CREATED); final TreatmentOverrideDto actual = MAPPER.toDto( experiment(EXPERIMENT_1).getOverride(request.getName()), TreatmentOverrideDto.class ); assertEquals(expected, actual); }
@PUT public Response addOverride(@PathParam("experimentName") String experimentName, @Valid TreatmentOverrideRequest request) { ensureExists(experiments.get(experimentName)) .addOverride( request.getName(), request.getTreatment(), request.getFilter() ) .save(); return created(); }
TreatmentOverridesResource extends BaseResource { @PUT public Response addOverride(@PathParam("experimentName") String experimentName, @Valid TreatmentOverrideRequest request) { ensureExists(experiments.get(experimentName)) .addOverride( request.getName(), request.getTreatment(), request.getFilter() ) .save(); return created(); } }
TreatmentOverridesResource extends BaseResource { @PUT public Response addOverride(@PathParam("experimentName") String experimentName, @Valid TreatmentOverrideRequest request) { ensureExists(experiments.get(experimentName)) .addOverride( request.getName(), request.getTreatment(), request.getFilter() ) .save(); return created(); } @Inject  TreatmentOverridesResource(Experiments experiments, Mappers mapper); }
TreatmentOverridesResource extends BaseResource { @PUT public Response addOverride(@PathParam("experimentName") String experimentName, @Valid TreatmentOverrideRequest request) { ensureExists(experiments.get(experimentName)) .addOverride( request.getName(), request.getTreatment(), request.getFilter() ) .save(); return created(); } @Inject  TreatmentOverridesResource(Experiments experiments, Mappers mapper); @GET @Path("/{overrideName}") TreatmentOverrideDto getOverride(@PathParam("experimentName") String experimentName,
                                            @PathParam("overrideName") String overrideName); @GET Iterable<TreatmentOverrideDto> getOverrides(@PathParam("experimentName") String experimentName); @PUT Response addOverride(@PathParam("experimentName") String experimentName,
                                @Valid TreatmentOverrideRequest request); @DELETE void clearOverrides(@PathParam("experimentName") String experimentName); @DELETE @Path("/{overrideName}") void removeOverride(@PathParam("experimentName") String experimentName,
                               @PathParam("overrideName") String overrideName); }
TreatmentOverridesResource extends BaseResource { @PUT public Response addOverride(@PathParam("experimentName") String experimentName, @Valid TreatmentOverrideRequest request) { ensureExists(experiments.get(experimentName)) .addOverride( request.getName(), request.getTreatment(), request.getFilter() ) .save(); return created(); } @Inject  TreatmentOverridesResource(Experiments experiments, Mappers mapper); @GET @Path("/{overrideName}") TreatmentOverrideDto getOverride(@PathParam("experimentName") String experimentName,
                                            @PathParam("overrideName") String overrideName); @GET Iterable<TreatmentOverrideDto> getOverrides(@PathParam("experimentName") String experimentName); @PUT Response addOverride(@PathParam("experimentName") String experimentName,
                                @Valid TreatmentOverrideRequest request); @DELETE void clearOverrides(@PathParam("experimentName") String experimentName); @DELETE @Path("/{overrideName}") void removeOverride(@PathParam("experimentName") String experimentName,
                               @PathParam("overrideName") String overrideName);  }