@Test public void getAssignmentsQueueDetails() throws Exception { Map<String, Object> queueDetailsMap = new HashMap<String, Object>(); try { queueDetailsMap.put(HOST_IP, InetAddress.getLocalHost().getHostAddress()); } catch (Exception e) { } Map<String, Object> testIngestionExecutorMap = new HashMap<String, Object>(); testIngestionExecutorMap.put(QUEUE_SIZE, new Integer(0)); Map<String, Object> ruleCacheMap = new HashMap<String, Object>(); ruleCacheMap.put(QUEUE_SIZE, new Integer(0)); queueDetailsMap.put(RULE_CACHE, ruleCacheMap); queueDetailsMap.put("test", testIngestionExecutorMap); assertThat(resource.getAssignmentsQueueDetails().getStatus(), is(HttpStatus.SC_OK)); when(assignments.queuesDetails()).thenReturn(queueDetailsMap); Response response = resource.getAssignmentsQueueDetails(); assertEquals(queueDetailsMap, response.getEntity()); }
@GET @Path("queueDetails") @Produces(APPLICATION_JSON) public Response getAssignmentsQueueDetails() { try { return httpHeader.headers().entity(assignments.queuesDetails()).build(); } catch (Exception exception) { LOGGER.error("getAssignmentsQueueDetails failed with error:", exception); throw exception; } }
AssignmentsResource { @GET @Path("queueDetails") @Produces(APPLICATION_JSON) public Response getAssignmentsQueueDetails() { try { return httpHeader.headers().entity(assignments.queuesDetails()).build(); } catch (Exception exception) { LOGGER.error("getAssignmentsQueueDetails failed with error:", exception); throw exception; } } }
AssignmentsResource { @GET @Path("queueDetails") @Produces(APPLICATION_JSON) public Response getAssignmentsQueueDetails() { try { return httpHeader.headers().entity(assignments.queuesDetails()).build(); } catch (Exception exception) { LOGGER.error("getAssignmentsQueueDetails failed with error:", exception); throw exception; } } @Inject  AssignmentsResource(final Assignments assignments, final HttpHeader httpHeader, Authorization authorization); }
AssignmentsResource { @GET @Path("queueDetails") @Produces(APPLICATION_JSON) public Response getAssignmentsQueueDetails() { try { return httpHeader.headers().entity(assignments.queuesDetails()).build(); } catch (Exception exception) { LOGGER.error("getAssignmentsQueueDetails failed with error:", exception); throw exception; } } @Inject  AssignmentsResource(final Assignments assignments, final HttpHeader httpHeader, Authorization authorization); @GET @Path("applications/{applicationName}/experiments/{experimentLabel}/users/{userID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignment for a user", notes = "Generate the assignment first if the user has no assignment " + "for this experiment. Return null if the user is not in the experiment.") @Timed Response getAssignment(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, e.g. PROD, QA")
            final Context context,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "whether an assignment should be generated if one doesn't exist",
                    defaultValue = "true")
            final Boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final Boolean ignoreSamplingPercent,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @POST @Path("applications/{applicationName}/experiments/{experimentLabel}/users/{userID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignment for a user", notes = "Generate the assignment first if the user has no assignment for this experiment. " + "Forces the user to be in the experiment (if eligible based on profile).") @Timed Response postAssignment(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "whether an assignment should be generated if one doesn't exist",
                    defaultValue = "true")
            final Boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final Boolean ignoreSamplingPercent,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, e.g. PROD, QA")
            final Context context,

            @ApiParam(name = "segmentationProfile", value = "Segmentation Profile")
            final SegmentationProfile segmentationProfile,

            @QueryParam("forceProfileCheck")
            @DefaultValue("false")
            @ApiParam(value = "whether to force user profile match",
                    defaultValue = "false")
            final Boolean forceProfileCheck,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @POST @Path("applications/{applicationName}/users/{userID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignments for a user across multiple experiments", notes = "Generate the assignments first if the user has no assignment for the specified experiments if the " + "CREATE flag is set to true and the user is eligible with respect to the segmentation profile. " + "Return null if the user is not in the experiment.") Response getBatchAssignments(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @QueryParam("create")
            @DefaultValue("true")
            final Boolean createAssignment,

            @ApiParam(required = true, defaultValue = DEFAULT_LABELLIST)
            final ExperimentBatch experimentBatch,

            @QueryParam("forceProfileCheck")
            @DefaultValue("false")
            @ApiParam(value = "whether to force user profile match",
                    defaultValue = "false")
            final Boolean forceProfileCheck,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @PUT @Path("applications/{applicationName}/experiments/{experimentLabel}/users/{userID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) /*@ApiOperation(value = "Set a bucket assignment for a user", notes = "Set assignment to null if the user is not in the experiment.")*/ @Timed Response updateAssignment(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @PathParam("userID")
            @ApiParam(value = "User ID")
            final User.ID userID,

            @ApiParam(value = "Submitted Data")
            final Map<String, Object> submittedData,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg \"QA\", \"PROD\"")
            final Context context); @GET @Path("applications/{applicationName}/pages/{pageName}/users/{userID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignments for a user for all the experiments associated with a page", notes = "If you want to pass segmentation information, use the POST-Call for this method") @Timed Response getBatchAssignmentForPage(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("pageName")
            @ApiParam(value = "Page Name")
            final Page.Name pageName,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "conditional to generate an assignment if one doesn't exist",
                    defaultValue = "true")
            final boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final boolean ignoreSamplingPercent,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @javax.ws.rs.core.Context
                    HttpHeaders headers); @POST @Path("applications/{applicationName}/pages/{pageName}/users/{userID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignments for a user for all the experiments associated with a page", notes = "The mutual exclusion and segmentation rules apply") @Timed Response postBatchAssignmentForPage(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("pageName")
            @ApiParam("Page Name")
                    Page.Name pageName,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "conditional to generate an assignment if one doesn't exist",
                    defaultValue = "true")
            final boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final boolean ignoreSamplingPercent,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @ApiParam(value = "Segmentation Profile")
            final SegmentationProfile segmentationProfile,

            @QueryParam("forceProfileCheck")
            @DefaultValue("false")
            @ApiParam(value = "whether to force user profile match",
                    defaultValue = "false")
            final Boolean forceProfileCheck,

            @javax.ws.rs.core.Context final HttpHeaders headers); @POST @Path("applications/{applicationName}/experiments/{experimentLabel}/ruletest") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Test the segmentation rule of an experiment") @Timed Response postAssignmentRuleTest(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @ApiParam(name = "segmentationProfile", value = "Segmentation Profile")
            final SegmentationProfile segmentationProfile,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @GET @Path("queueLength") @Produces(APPLICATION_JSON) Response getAssignmentsQueueLength(); @GET @Path("queueDetails") @Produces(APPLICATION_JSON) Response getAssignmentsQueueDetails(); @POST @Path("flushMessages") @Produces(APPLICATION_JSON) Response flushMessages(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("clearMetadataCache") @Produces(APPLICATION_JSON) @ApiOperation(value = "Clear assignments metadata cache...") @Timed Response clearMetadataCache(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("metadataCacheDetails") @Produces(APPLICATION_JSON) @ApiOperation(value = "Get assignments metadata cache details...") @Timed Response getMetadataCacheDetails(); }
AssignmentsResource { @GET @Path("queueDetails") @Produces(APPLICATION_JSON) public Response getAssignmentsQueueDetails() { try { return httpHeader.headers().entity(assignments.queuesDetails()).build(); } catch (Exception exception) { LOGGER.error("getAssignmentsQueueDetails failed with error:", exception); throw exception; } } @Inject  AssignmentsResource(final Assignments assignments, final HttpHeader httpHeader, Authorization authorization); @GET @Path("applications/{applicationName}/experiments/{experimentLabel}/users/{userID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignment for a user", notes = "Generate the assignment first if the user has no assignment " + "for this experiment. Return null if the user is not in the experiment.") @Timed Response getAssignment(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, e.g. PROD, QA")
            final Context context,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "whether an assignment should be generated if one doesn't exist",
                    defaultValue = "true")
            final Boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final Boolean ignoreSamplingPercent,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @POST @Path("applications/{applicationName}/experiments/{experimentLabel}/users/{userID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignment for a user", notes = "Generate the assignment first if the user has no assignment for this experiment. " + "Forces the user to be in the experiment (if eligible based on profile).") @Timed Response postAssignment(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "whether an assignment should be generated if one doesn't exist",
                    defaultValue = "true")
            final Boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final Boolean ignoreSamplingPercent,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, e.g. PROD, QA")
            final Context context,

            @ApiParam(name = "segmentationProfile", value = "Segmentation Profile")
            final SegmentationProfile segmentationProfile,

            @QueryParam("forceProfileCheck")
            @DefaultValue("false")
            @ApiParam(value = "whether to force user profile match",
                    defaultValue = "false")
            final Boolean forceProfileCheck,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @POST @Path("applications/{applicationName}/users/{userID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignments for a user across multiple experiments", notes = "Generate the assignments first if the user has no assignment for the specified experiments if the " + "CREATE flag is set to true and the user is eligible with respect to the segmentation profile. " + "Return null if the user is not in the experiment.") Response getBatchAssignments(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @QueryParam("create")
            @DefaultValue("true")
            final Boolean createAssignment,

            @ApiParam(required = true, defaultValue = DEFAULT_LABELLIST)
            final ExperimentBatch experimentBatch,

            @QueryParam("forceProfileCheck")
            @DefaultValue("false")
            @ApiParam(value = "whether to force user profile match",
                    defaultValue = "false")
            final Boolean forceProfileCheck,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @PUT @Path("applications/{applicationName}/experiments/{experimentLabel}/users/{userID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) /*@ApiOperation(value = "Set a bucket assignment for a user", notes = "Set assignment to null if the user is not in the experiment.")*/ @Timed Response updateAssignment(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @PathParam("userID")
            @ApiParam(value = "User ID")
            final User.ID userID,

            @ApiParam(value = "Submitted Data")
            final Map<String, Object> submittedData,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg \"QA\", \"PROD\"")
            final Context context); @GET @Path("applications/{applicationName}/pages/{pageName}/users/{userID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignments for a user for all the experiments associated with a page", notes = "If you want to pass segmentation information, use the POST-Call for this method") @Timed Response getBatchAssignmentForPage(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("pageName")
            @ApiParam(value = "Page Name")
            final Page.Name pageName,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "conditional to generate an assignment if one doesn't exist",
                    defaultValue = "true")
            final boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final boolean ignoreSamplingPercent,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @javax.ws.rs.core.Context
                    HttpHeaders headers); @POST @Path("applications/{applicationName}/pages/{pageName}/users/{userID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return bucket assignments for a user for all the experiments associated with a page", notes = "The mutual exclusion and segmentation rules apply") @Timed Response postBatchAssignmentForPage(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("pageName")
            @ApiParam("Page Name")
                    Page.Name pageName,

            @PathParam("userID")
            @ApiParam(value = "User(customer) ID")
            final User.ID userID,

            @QueryParam("createAssignment")
            @DefaultValue("true")
            @ApiParam(value = "conditional to generate an assignment if one doesn't exist",
                    defaultValue = "true")
            final boolean createAssignment,

            @QueryParam("ignoreSamplingPercent")
            @DefaultValue("false")
            @ApiParam(value = "whether the sampling percent for the experiment should be ignored, " +
                    "forcing the user into the experiment (if eligible)",
                    defaultValue = "false")
            final boolean ignoreSamplingPercent,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @ApiParam(value = "Segmentation Profile")
            final SegmentationProfile segmentationProfile,

            @QueryParam("forceProfileCheck")
            @DefaultValue("false")
            @ApiParam(value = "whether to force user profile match",
                    defaultValue = "false")
            final Boolean forceProfileCheck,

            @javax.ws.rs.core.Context final HttpHeaders headers); @POST @Path("applications/{applicationName}/experiments/{experimentLabel}/ruletest") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Test the segmentation rule of an experiment") @Timed Response postAssignmentRuleTest(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("experimentLabel")
            @ApiParam(value = "Experiment Label")
            final Experiment.Label experimentLabel,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @ApiParam(name = "segmentationProfile", value = "Segmentation Profile")
            final SegmentationProfile segmentationProfile,

            @javax.ws.rs.core.Context
            final HttpHeaders headers); @GET @Path("queueLength") @Produces(APPLICATION_JSON) Response getAssignmentsQueueLength(); @GET @Path("queueDetails") @Produces(APPLICATION_JSON) Response getAssignmentsQueueDetails(); @POST @Path("flushMessages") @Produces(APPLICATION_JSON) Response flushMessages(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("clearMetadataCache") @Produces(APPLICATION_JSON) @ApiOperation(value = "Clear assignments metadata cache...") @Timed Response clearMetadataCache(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("metadataCacheDetails") @Produces(APPLICATION_JSON) @ApiOperation(value = "Get assignments metadata cache details...") @Timed Response getMetadataCacheDetails();  }