@Test public void testGetActiveTreatment() { post(ENDPOINT_ACTIVE_TREATMENT, EXPERIMENT_BAD) .entity(userDto) .assertStatus(Status.NO_CONTENT); final TreatmentDto expected1 = MAPPER.toDto(experiment(EXPERIMENT_1).getTreatment(user, user.computeAttributes()), TreatmentDto.class); final TreatmentDto expected2 = MAPPER.toDto(experiment(EXPERIMENT_2).getTreatment(device, device.computeAttributes()), TreatmentDto.class); final TreatmentDto actual1 = post(ENDPOINT_ACTIVE_TREATMENT, EXPERIMENT_1) .entity(userDto) .assertStatus(Status.OK) .result(TreatmentDto.class); assertEquals(expected1, actual1); post(ENDPOINT_ACTIVE_TREATMENT, EXPERIMENT_1) .entity(deviceDto) .assertStatus(Status.NO_CONTENT); final TreatmentDto actual2 = post(ENDPOINT_ACTIVE_TREATMENT, EXPERIMENT_2) .entity(deviceDto) .assertStatus(Status.OK) .result(TreatmentDto.class); assertEquals(expected2, actual2); post(ENDPOINT_ACTIVE_TREATMENT, EXPERIMENT_3) .entity(userDto) .assertStatus(Status.NO_CONTENT); post(ENDPOINT_ACTIVE_TREATMENT, EXPERIMENT_4) .entity(userDto) .assertStatus(Status.NO_CONTENT); }
@POST @Timed @Path("/experiments/{experimentName}/treatment") public TreatmentDto getActiveTreatment(@PathParam("experimentName") String experimentName, @Valid IdentityDto identity) { return mapper.toDto( experiments.getActiveTreatment( experimentName, mapper.fromDto(identity, Identity.class) ), TreatmentDto.class ); }
ActiveTreatmentsResource extends BaseResource { @POST @Timed @Path("/experiments/{experimentName}/treatment") public TreatmentDto getActiveTreatment(@PathParam("experimentName") String experimentName, @Valid IdentityDto identity) { return mapper.toDto( experiments.getActiveTreatment( experimentName, mapper.fromDto(identity, Identity.class) ), TreatmentDto.class ); } }
ActiveTreatmentsResource extends BaseResource { @POST @Timed @Path("/experiments/{experimentName}/treatment") public TreatmentDto getActiveTreatment(@PathParam("experimentName") String experimentName, @Valid IdentityDto identity) { return mapper.toDto( experiments.getActiveTreatment( experimentName, mapper.fromDto(identity, Identity.class) ), TreatmentDto.class ); } @Inject  ActiveTreatmentsResource(Experiments experiments, Mappers mapper); }
ActiveTreatmentsResource extends BaseResource { @POST @Timed @Path("/experiments/{experimentName}/treatment") public TreatmentDto getActiveTreatment(@PathParam("experimentName") String experimentName, @Valid IdentityDto identity) { return mapper.toDto( experiments.getActiveTreatment( experimentName, mapper.fromDto(identity, Identity.class) ), TreatmentDto.class ); } @Inject  ActiveTreatmentsResource(Experiments experiments, Mappers mapper); @POST @Timed @Path("/experiments/{experimentName}/treatment") TreatmentDto getActiveTreatment(@PathParam("experimentName") String experimentName,
                                           @Valid IdentityDto identity); @POST @Timed @Path("/treatments") Map<String, TreatmentDto> getActiveTreatments(@Valid IdentityDto identityDto); }
ActiveTreatmentsResource extends BaseResource { @POST @Timed @Path("/experiments/{experimentName}/treatment") public TreatmentDto getActiveTreatment(@PathParam("experimentName") String experimentName, @Valid IdentityDto identity) { return mapper.toDto( experiments.getActiveTreatment( experimentName, mapper.fromDto(identity, Identity.class) ), TreatmentDto.class ); } @Inject  ActiveTreatmentsResource(Experiments experiments, Mappers mapper); @POST @Timed @Path("/experiments/{experimentName}/treatment") TreatmentDto getActiveTreatment(@PathParam("experimentName") String experimentName,
                                           @Valid IdentityDto identity); @POST @Timed @Path("/treatments") Map<String, TreatmentDto> getActiveTreatments(@Valid IdentityDto identityDto);  }