@Test public void testToJsonMethod() { EventEnvelopePayload payload = new EventEnvelopePayload( name, label, assignment, event) { @Override protected UUID makeUUID() { return UUID.fromString("d9f92dd0-05be-11e6-86e9-0bf850ef5299"); } }; String jsonpayload = payload.toJson(); assertThat(jsonpayload, is("{\"experimentLabel\":\"l1\",\"eventPayload\":null,\"eventType\":\"null\",\"userID\":null,\"epochTimestamp\":0,\"messageType\":\"EVENT\",\"context\":null,\"eventName\":\"null\",\"experimentID\":null,\"time_uuid\":\"d9f92dd0-05be-11e6-86e9-0bf850ef5299\",\"value\":null,\"applicationName\":\"a1\",\"bucketLabel\":null}")); }
@Override public String toJson() { JSONObject eventJson = new JSONObject(); eventJson.put("messageType", MessageType.EVENT.toString()); eventJson.put("applicationName", applicationName != null ? applicationName.toString(): null); eventJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString(): null); eventJson.put("userID", assignment != null && assignment.getUserID() != null ? assignment.getUserID().toString(): null); eventJson.put("bucketLabel", assignment != null && assignment.getBucketLabel() != null ? assignment.getBucketLabel().toString(): null); eventJson.put("time_uuid", makeUUID().toString()); eventJson.put("experimentID", assignment != null && assignment.getExperimentID() != null ? assignment.getExperimentID().toString(): null); eventJson.put("context", assignment != null && assignment.getContext() != null ? assignment.getContext().toString(): null); eventJson.put("epochTimestamp", event != null && event.getTimestamp() != null ? event.getTimestamp().getTime(): null); eventJson.put("eventType", event != null ? event.getType() + "": "null"); eventJson.put("eventName", event != null ? event.getName() + "": "null"); eventJson.put("eventPayload", event != null && event.getPayload() != null ? event.getPayload().toString(): null); eventJson.put("value", event != null ? event.getValue(): null); return eventJson.toString(); }
EventEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject eventJson = new JSONObject(); eventJson.put("messageType", MessageType.EVENT.toString()); eventJson.put("applicationName", applicationName != null ? applicationName.toString(): null); eventJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString(): null); eventJson.put("userID", assignment != null && assignment.getUserID() != null ? assignment.getUserID().toString(): null); eventJson.put("bucketLabel", assignment != null && assignment.getBucketLabel() != null ? assignment.getBucketLabel().toString(): null); eventJson.put("time_uuid", makeUUID().toString()); eventJson.put("experimentID", assignment != null && assignment.getExperimentID() != null ? assignment.getExperimentID().toString(): null); eventJson.put("context", assignment != null && assignment.getContext() != null ? assignment.getContext().toString(): null); eventJson.put("epochTimestamp", event != null && event.getTimestamp() != null ? event.getTimestamp().getTime(): null); eventJson.put("eventType", event != null ? event.getType() + "": "null"); eventJson.put("eventName", event != null ? event.getName() + "": "null"); eventJson.put("eventPayload", event != null && event.getPayload() != null ? event.getPayload().toString(): null); eventJson.put("value", event != null ? event.getValue(): null); return eventJson.toString(); } }
EventEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject eventJson = new JSONObject(); eventJson.put("messageType", MessageType.EVENT.toString()); eventJson.put("applicationName", applicationName != null ? applicationName.toString(): null); eventJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString(): null); eventJson.put("userID", assignment != null && assignment.getUserID() != null ? assignment.getUserID().toString(): null); eventJson.put("bucketLabel", assignment != null && assignment.getBucketLabel() != null ? assignment.getBucketLabel().toString(): null); eventJson.put("time_uuid", makeUUID().toString()); eventJson.put("experimentID", assignment != null && assignment.getExperimentID() != null ? assignment.getExperimentID().toString(): null); eventJson.put("context", assignment != null && assignment.getContext() != null ? assignment.getContext().toString(): null); eventJson.put("epochTimestamp", event != null && event.getTimestamp() != null ? event.getTimestamp().getTime(): null); eventJson.put("eventType", event != null ? event.getType() + "": "null"); eventJson.put("eventName", event != null ? event.getName() + "": "null"); eventJson.put("eventPayload", event != null && event.getPayload() != null ? event.getPayload().toString(): null); eventJson.put("value", event != null ? event.getValue(): null); return eventJson.toString(); } EventEnvelopePayload(Name applicationName, Label experimentLabel,
                                Assignment assignment, Event event); }
EventEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject eventJson = new JSONObject(); eventJson.put("messageType", MessageType.EVENT.toString()); eventJson.put("applicationName", applicationName != null ? applicationName.toString(): null); eventJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString(): null); eventJson.put("userID", assignment != null && assignment.getUserID() != null ? assignment.getUserID().toString(): null); eventJson.put("bucketLabel", assignment != null && assignment.getBucketLabel() != null ? assignment.getBucketLabel().toString(): null); eventJson.put("time_uuid", makeUUID().toString()); eventJson.put("experimentID", assignment != null && assignment.getExperimentID() != null ? assignment.getExperimentID().toString(): null); eventJson.put("context", assignment != null && assignment.getContext() != null ? assignment.getContext().toString(): null); eventJson.put("epochTimestamp", event != null && event.getTimestamp() != null ? event.getTimestamp().getTime(): null); eventJson.put("eventType", event != null ? event.getType() + "": "null"); eventJson.put("eventName", event != null ? event.getName() + "": "null"); eventJson.put("eventPayload", event != null && event.getPayload() != null ? event.getPayload().toString(): null); eventJson.put("value", event != null ? event.getValue(): null); return eventJson.toString(); } EventEnvelopePayload(Name applicationName, Label experimentLabel,
                                Assignment assignment, Event event); Name getApplicationName(); void setApplicationName(Name applicationName); Label getExperimentLabel(); void setExperimentLabel(Label experimentLabel); Assignment getAssignment(); void setAssignment(Assignment assignment); Event getEvent(); void setEvent(Event event); @Override String toJson(); }
EventEnvelopePayload implements EnvelopePayload { @Override public String toJson() { JSONObject eventJson = new JSONObject(); eventJson.put("messageType", MessageType.EVENT.toString()); eventJson.put("applicationName", applicationName != null ? applicationName.toString(): null); eventJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString(): null); eventJson.put("userID", assignment != null && assignment.getUserID() != null ? assignment.getUserID().toString(): null); eventJson.put("bucketLabel", assignment != null && assignment.getBucketLabel() != null ? assignment.getBucketLabel().toString(): null); eventJson.put("time_uuid", makeUUID().toString()); eventJson.put("experimentID", assignment != null && assignment.getExperimentID() != null ? assignment.getExperimentID().toString(): null); eventJson.put("context", assignment != null && assignment.getContext() != null ? assignment.getContext().toString(): null); eventJson.put("epochTimestamp", event != null && event.getTimestamp() != null ? event.getTimestamp().getTime(): null); eventJson.put("eventType", event != null ? event.getType() + "": "null"); eventJson.put("eventName", event != null ? event.getName() + "": "null"); eventJson.put("eventPayload", event != null && event.getPayload() != null ? event.getPayload().toString(): null); eventJson.put("value", event != null ? event.getValue(): null); return eventJson.toString(); } EventEnvelopePayload(Name applicationName, Label experimentLabel,
                                Assignment assignment, Event event); Name getApplicationName(); void setApplicationName(Name applicationName); Label getExperimentLabel(); void setExperimentLabel(Label experimentLabel); Assignment getAssignment(); void setAssignment(Assignment assignment); Event getEvent(); void setEvent(Event event); @Override String toJson();  }