@Before
 public void setUp() {
   int nAssigns = nWorkers * (nObjects + nGold);
   int i;
   categories = new ArrayList<String>();
   categories.add("AAA");
   categories.add("BBB");
   workers = new ArrayList<Worker<String>>();
   for (i = 0; i < nWorkers; i++) {
     workers.add(new Worker<String>("worker" + i));
   }
   objects = new ArrayList<LObject<String>>();
   for (i = 0; i < nObjects; i++) {
     objects.add(new LObject<String>("object" + i));
   }
   goldObjects = new ArrayList<LObject<String>>();
   for (i = 0; i < nGold; i++) {
     LObject<String> gold = new LObject<String>("gObject" + i);
     gold.setGoldLabel("AAA");
     goldObjects.add(gold);
   }
   objects.addAll(goldObjects);
   assigns = new ArrayList<AssignedLabel<String>>();
   for (i = 0; i < nAssigns; i++) {
     assigns.add(
         new AssignedLabel<String>(
             workers.get(i % nWorkers),
             objects.get(i % (nObjects + nGold)),
             categories.get(i % categories.size())));
   }
 }
  @Test
  public void resultsSerializationTest() {
    ArrayList<String> categories = new ArrayList<String>();
    categories.add("category1");
    categories.add("category2");

    MemoryJobStorage js = new MemoryJobStorage();
    IResults<String, DatumResult, WorkerResult> results =
        js.getNominalResults("testid", categories);
    LObject<String> obj = new LObject<String>("obj");
    obj.setEvaluationLabel("category2");
    DatumResult dr = results.getOrCreateDatumResult(obj);
    Map<String, Double> categoryProb = new HashMap<String, Double>();
    categoryProb.put("category1", 0.3);
    categoryProb.put("category2", 0.7);
    dr.setCategoryProbabilites(categoryProb);
    results.addDatumResult(obj, dr);
    String serialized = gson.toJson(results);
    LObject<String> imaginaryObj = new LObject<String>("ImaginaryObj");
    Worker imaginaryWorker = new Worker("ImaginaryWorker");

    InMemoryResults<String, DatumResult, WorkerResult> deserialized =
        gson.fromJson(
            serialized,
            new TypeToken<InMemoryResults<String, DatumResult, WorkerResult>>() {}.getType());
    //		Assert.assertEquals(deserialized.getOrCreateDatumResult(imaginaryObj).getClass(),
    //				results.getOrCreateDatumResult(imaginaryObj).getClass());
    //		Assert.assertEquals(deserialized.getOrCreateWorkerResult(imaginaryWorker).getClass(),
    //				results.getOrCreateWorkerResult(imaginaryWorker).getClass());
    // ^^^ above doesn't work - it works when jsoned at job level
    Assert.assertNotNull(deserialized.getDatumResult(obj));
    DatumResult ddr = deserialized.getDatumResult(obj);
    Assert.assertEquals(ddr.getCategoryProbabilites(), dr.getCategoryProbabilites());
    Assert.assertEquals(gson.toJson(deserialized), serialized);
  }