@Test public void testJson() { payload = new AssignmentEnvelopePayload(userID, context, createAssignment, putAssignment, ignoreSamplingPercent, segmentationProfile, assignmentStatus, bucketLabel, pageName, applicationName, experimentLabel, experimentID, date, httpHeaders); String payloadJson = payload.toJson(); assertThat(payloadJson, containsString(userID.toString())); assertThat(payloadJson, containsString(context.toString())); assertThat(payloadJson, containsString(String.valueOf(createAssignment))); assertThat(payloadJson, containsString(String.valueOf(putAssignment))); assertThat(payloadJson, containsString(String.valueOf(ignoreSamplingPercent))); assertThat(payloadJson, containsString(segmentationProfile.getProfile().toString())); assertThat(payloadJson, containsString(assignmentStatus.toString())); assertThat(payloadJson, containsString(bucketLabel.toString())); assertThat(payloadJson, containsString(pageName.toString())); assertThat(payloadJson, containsString(applicationName.toString())); assertThat(payloadJson, containsString(experimentLabel.toString())); assertThat(payloadJson, containsString(experimentID.toString())); assertThat(payloadJson, containsString(String.valueOf(date.getTime()))); }
@Override public String toJson() { JSONObject assignmentJson = new JSONObject(); assignmentJson.put("userID", userID != null ? userID.toString() : ""); assignmentJson.put("applicationName", applicationName != null ? applicationName.toString() : ""); assignmentJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString() : ""); assignmentJson.put("context", context != null ? context.toString() : "PROD"); assignmentJson.put("createAssignment", createAssignment); assignmentJson.put("putAssignment", putAssignment); assignmentJson.put("ignoreSamplingPercent", ignoreSamplingPercent); assignmentJson.put("segmentationProfile", segmentationProfile != null && segmentationProfile.getProfile() != null ? segmentationProfile.getProfile().toString() : ""); assignmentJson.put("experimentID", experimentID != null ? experimentID.toString() : ""); assignmentJson.put("pageName", pageName != null ? pageName.toString() : ""); assignmentJson.put("assignmentStatus", assignmentStatus != null ? assignmentStatus.toString() : ""); assignmentJson.put("bucketLabel", bucketLabel != null ? bucketLabel.toString() : "NULL"); assignmentJson.put("time_uuid", UUIDGen.getTimeUUID()); assignmentJson.put("epochTimestamp", date != null ? date.getTime() : ""); assignmentJson.put("messageType", MessageType.ASSIGNMENT.toString()); return assignmentJson.toString(); }
AssignmentEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject assignmentJson = new JSONObject(); assignmentJson.put("userID", userID != null ? userID.toString() : ""); assignmentJson.put("applicationName", applicationName != null ? applicationName.toString() : ""); assignmentJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString() : ""); assignmentJson.put("context", context != null ? context.toString() : "PROD"); assignmentJson.put("createAssignment", createAssignment); assignmentJson.put("putAssignment", putAssignment); assignmentJson.put("ignoreSamplingPercent", ignoreSamplingPercent); assignmentJson.put("segmentationProfile", segmentationProfile != null && segmentationProfile.getProfile() != null ? segmentationProfile.getProfile().toString() : ""); assignmentJson.put("experimentID", experimentID != null ? experimentID.toString() : ""); assignmentJson.put("pageName", pageName != null ? pageName.toString() : ""); assignmentJson.put("assignmentStatus", assignmentStatus != null ? assignmentStatus.toString() : ""); assignmentJson.put("bucketLabel", bucketLabel != null ? bucketLabel.toString() : "NULL"); assignmentJson.put("time_uuid", UUIDGen.getTimeUUID()); assignmentJson.put("epochTimestamp", date != null ? date.getTime() : ""); assignmentJson.put("messageType", MessageType.ASSIGNMENT.toString()); return assignmentJson.toString(); } }
AssignmentEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject assignmentJson = new JSONObject(); assignmentJson.put("userID", userID != null ? userID.toString() : ""); assignmentJson.put("applicationName", applicationName != null ? applicationName.toString() : ""); assignmentJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString() : ""); assignmentJson.put("context", context != null ? context.toString() : "PROD"); assignmentJson.put("createAssignment", createAssignment); assignmentJson.put("putAssignment", putAssignment); assignmentJson.put("ignoreSamplingPercent", ignoreSamplingPercent); assignmentJson.put("segmentationProfile", segmentationProfile != null && segmentationProfile.getProfile() != null ? segmentationProfile.getProfile().toString() : ""); assignmentJson.put("experimentID", experimentID != null ? experimentID.toString() : ""); assignmentJson.put("pageName", pageName != null ? pageName.toString() : ""); assignmentJson.put("assignmentStatus", assignmentStatus != null ? assignmentStatus.toString() : ""); assignmentJson.put("bucketLabel", bucketLabel != null ? bucketLabel.toString() : "NULL"); assignmentJson.put("time_uuid", UUIDGen.getTimeUUID()); assignmentJson.put("epochTimestamp", date != null ? date.getTime() : ""); assignmentJson.put("messageType", MessageType.ASSIGNMENT.toString()); return assignmentJson.toString(); } AssignmentEnvelopePayload();  AssignmentEnvelopePayload(User.ID userID,
                                     Context context, SegmentationProfile segmentationProfile,
                                     Bucket.Label bucketLabel, Page.Name pageName, HttpHeaders httpHeaders,
                                     Application.Name applicationName, Experiment.Label experimentLabel);  AssignmentEnvelopePayload(
            ID userID,
            Context context,
            boolean createAssignment,
            boolean putAssignment,
            boolean ignoreSamplingPercent,
            SegmentationProfile segmentationProfile,
            Status assignmentStatus,
            Bucket.Label bucketLabel,
            Page.Name pageName,
            Name applicationName,
            Label experimentLabel,
            Experiment.ID experimentID,
            Date date,
            HttpHeaders httpHeaders); }
AssignmentEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject assignmentJson = new JSONObject(); assignmentJson.put("userID", userID != null ? userID.toString() : ""); assignmentJson.put("applicationName", applicationName != null ? applicationName.toString() : ""); assignmentJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString() : ""); assignmentJson.put("context", context != null ? context.toString() : "PROD"); assignmentJson.put("createAssignment", createAssignment); assignmentJson.put("putAssignment", putAssignment); assignmentJson.put("ignoreSamplingPercent", ignoreSamplingPercent); assignmentJson.put("segmentationProfile", segmentationProfile != null && segmentationProfile.getProfile() != null ? segmentationProfile.getProfile().toString() : ""); assignmentJson.put("experimentID", experimentID != null ? experimentID.toString() : ""); assignmentJson.put("pageName", pageName != null ? pageName.toString() : ""); assignmentJson.put("assignmentStatus", assignmentStatus != null ? assignmentStatus.toString() : ""); assignmentJson.put("bucketLabel", bucketLabel != null ? bucketLabel.toString() : "NULL"); assignmentJson.put("time_uuid", UUIDGen.getTimeUUID()); assignmentJson.put("epochTimestamp", date != null ? date.getTime() : ""); assignmentJson.put("messageType", MessageType.ASSIGNMENT.toString()); return assignmentJson.toString(); } AssignmentEnvelopePayload();  AssignmentEnvelopePayload(User.ID userID,
                                     Context context, SegmentationProfile segmentationProfile,
                                     Bucket.Label bucketLabel, Page.Name pageName, HttpHeaders httpHeaders,
                                     Application.Name applicationName, Experiment.Label experimentLabel);  AssignmentEnvelopePayload(
            ID userID,
            Context context,
            boolean createAssignment,
            boolean putAssignment,
            boolean ignoreSamplingPercent,
            SegmentationProfile segmentationProfile,
            Status assignmentStatus,
            Bucket.Label bucketLabel,
            Page.Name pageName,
            Name applicationName,
            Label experimentLabel,
            Experiment.ID experimentID,
            Date date,
            HttpHeaders httpHeaders); User.ID getUserID(); void setUserID(User.ID userID); Context getContext(); void setContext(Context context); boolean isCreateAssignment(); void setCreateAssignment(boolean createAssignment); boolean isPutAssignment(); void setPutAssignment(boolean putAssignment); boolean isIgnoreSamplingPercent(); void setIgnoreSamplingPercent(boolean ignoreSamplingPercent); SegmentationProfile getSegmentationProfile(); void setSegmentationProfile(SegmentationProfile segmentationProfile); Assignment.Status getAssignmentStatus(); void setAssignmentStatus(Assignment.Status assignmentStatus); Bucket.Label getBucketLabel(); void setBucketLabel(Bucket.Label bucketLabel); Page.Name getPageName(); void setPageName(Page.Name pageName); Application.Name getApplicationName(); void setApplicationName(Application.Name applicationName); Experiment.Label getExperimentLabel(); void setExperimentLabel(Experiment.Label experimentLabel); Experiment.ID getExperimentID(); void setExperimentID(Experiment.ID experimentID); Date getDate(); void setDate(Date date); HttpHeaders getHttpHeaders(); void setHttpHeaders(HttpHeaders httpHeaders); @Override String toJson(); }
AssignmentEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject assignmentJson = new JSONObject(); assignmentJson.put("userID", userID != null ? userID.toString() : ""); assignmentJson.put("applicationName", applicationName != null ? applicationName.toString() : ""); assignmentJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString() : ""); assignmentJson.put("context", context != null ? context.toString() : "PROD"); assignmentJson.put("createAssignment", createAssignment); assignmentJson.put("putAssignment", putAssignment); assignmentJson.put("ignoreSamplingPercent", ignoreSamplingPercent); assignmentJson.put("segmentationProfile", segmentationProfile != null && segmentationProfile.getProfile() != null ? segmentationProfile.getProfile().toString() : ""); assignmentJson.put("experimentID", experimentID != null ? experimentID.toString() : ""); assignmentJson.put("pageName", pageName != null ? pageName.toString() : ""); assignmentJson.put("assignmentStatus", assignmentStatus != null ? assignmentStatus.toString() : ""); assignmentJson.put("bucketLabel", bucketLabel != null ? bucketLabel.toString() : "NULL"); assignmentJson.put("time_uuid", UUIDGen.getTimeUUID()); assignmentJson.put("epochTimestamp", date != null ? date.getTime() : ""); assignmentJson.put("messageType", MessageType.ASSIGNMENT.toString()); return assignmentJson.toString(); } AssignmentEnvelopePayload();  AssignmentEnvelopePayload(User.ID userID,
                                     Context context, SegmentationProfile segmentationProfile,
                                     Bucket.Label bucketLabel, Page.Name pageName, HttpHeaders httpHeaders,
                                     Application.Name applicationName, Experiment.Label experimentLabel);  AssignmentEnvelopePayload(
            ID userID,
            Context context,
            boolean createAssignment,
            boolean putAssignment,
            boolean ignoreSamplingPercent,
            SegmentationProfile segmentationProfile,
            Status assignmentStatus,
            Bucket.Label bucketLabel,
            Page.Name pageName,
            Name applicationName,
            Label experimentLabel,
            Experiment.ID experimentID,
            Date date,
            HttpHeaders httpHeaders); User.ID getUserID(); void setUserID(User.ID userID); Context getContext(); void setContext(Context context); boolean isCreateAssignment(); void setCreateAssignment(boolean createAssignment); boolean isPutAssignment(); void setPutAssignment(boolean putAssignment); boolean isIgnoreSamplingPercent(); void setIgnoreSamplingPercent(boolean ignoreSamplingPercent); SegmentationProfile getSegmentationProfile(); void setSegmentationProfile(SegmentationProfile segmentationProfile); Assignment.Status getAssignmentStatus(); void setAssignmentStatus(Assignment.Status assignmentStatus); Bucket.Label getBucketLabel(); void setBucketLabel(Bucket.Label bucketLabel); Page.Name getPageName(); void setPageName(Page.Name pageName); Application.Name getApplicationName(); void setApplicationName(Application.Name applicationName); Experiment.Label getExperimentLabel(); void setExperimentLabel(Experiment.Label experimentLabel); Experiment.ID getExperimentID(); void setExperimentID(Experiment.ID experimentID); Date getDate(); void setDate(Date date); HttpHeaders getHttpHeaders(); void setHttpHeaders(HttpHeaders httpHeaders); @Override String toJson();  }