ActiveTreatmentsResource extends BaseResource { @POST @Timed @Path("/treatments") public Map<String, TreatmentDto> getActiveTreatments(@Valid IdentityDto identityDto) { final Map<String, TreatmentDto> treatments = Maps.newHashMap(); final Map<Experiment, Treatment> activeTreatments = experiments.getActiveTreatments( mapper.fromDto(identityDto, Identity.class) ); for (final Map.Entry<Experiment, Treatment> entry : activeTreatments.entrySet()) { treatments.put(entry.getKey().getName(), mapper.toDto(entry.getValue(), TreatmentDto.class)); } return treatments; } @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);  }
@Test public void testGetActiveTreatments() { final Map<String, TreatmentDto> expected = ImmutableMap.of( EXPERIMENT_1, MAPPER.toDto(experiment(EXPERIMENT_1).getTreatment(user, user.computeAttributes()), TreatmentDto.class) ); final Map<String, TreatmentDto> actual = post(ENDPOINT_ACTIVE_TREATMENTS) .entity(userDto) .assertStatus(Status.OK) .result(map(String.class, TreatmentDto.class)); assertEquals(expected, actual); }