package com.indeed.proctor.service;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.indeed.proctor.common.model.Payload;
import com.indeed.proctor.common.model.TestBucket;

/**
 * Representation of TestBucket intended for serialization into JSON.
 *
 * Mostly a rewriting of TestBucket with a few extras like skipping nulls and included test version for caching.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonTestBucket {
    final private String name;
    final private int value;
    final private Payload payload;
    final private int version;

    /**
     * Serializes the object using an existing bucket and a separate version.
     *
     * Version needs to be obtained outside of the bucket through ProctorResult.getTestVersions()
     */
    public JsonTestBucket(final TestBucket bucket, final int version) {
        name = bucket.getName();
        value = bucket.getValue();
        payload = bucket.getPayload();
        this.version = version;
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

    public Payload getPayload() {
        return payload;
    }

    public int getVersion() {
        return version;
    }
}

@@ -528,23 +528,22 @@
 private 
-Payload
+Object
  payload
@@ -927,70 +927,489 @@
     
-payload = bucket.getPayload();%0A        this.version = version;
+this.version = version;%0A%0A        // The json serializer will automatically make this into whatever json type it should be.%0A        // So we don't have to worry about figuring out the type of the payload.%0A        // TODO: The serializer converts 0.0 to 0. Is this a problem?%0A        final Payload bucketPayload = bucket.getPayload();%0A        if (bucketPayload != null) %7B%0A            payload = bucket.getPayload().fetchAValue();%0A        %7D else %7B%0A            payload = null;%0A        %7D
 %0A   
@@ -1538,23 +1538,22 @@
  public 
-Payload
+Object
  getPayl

Support arbitrary payloads.