Vote { public JsonObject serialize() { JsonObject ret = new JsonObject(); ret.addProperty("serviceName", serviceName); ret.addProperty("username", username); ret.addProperty("address", address); ret.addProperty("timestamp", timeStamp); if (additionalData != null) ret.addProperty("additionalData", Base64.getEncoder().encodeToString(additionalData)); return ret; } @Deprecated  Vote();  Vote(String serviceName, String username, String address, String timeStamp);  Vote(String serviceName, String username, String address, String timeStamp, byte[] additionalData);  Vote(Vote vote);  Vote(JsonObject jsonObject); @Override String toString(); @Deprecated void setServiceName(String serviceName); String getServiceName(); @Deprecated void setUsername(String username); String getUsername(); @Deprecated void setAddress(String address); String getAddress(); @Deprecated void setTimeStamp(String timeStamp); String getTimeStamp(); byte[] getAdditionalData(); JsonObject serialize(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testVoteSerialize() { Vote v = new Vote("service", "username", "address", "1234"); JsonObject o = v.serialize(); assertEquals(4, o.size()); assertEquals("service", o.get("serviceName").getAsString()); assertEquals("username", o.get("username").getAsString()); assertEquals("address", o.get("address").getAsString()); assertEquals("1234", o.get("timestamp").getAsString()); }