ProfilerConfig implements Serializable { public static ProfilerConfig fromJSON(String json) throws IOException { return JSONUtils.INSTANCE.load(json, ProfilerConfig.class); }  List<ProfileConfig> getProfiles(); void setProfiles(List<ProfileConfig> profiles); ProfilerConfig withProfile(ProfileConfig profileConfig); @JsonGetter("timestampField") String getTimestampFieldForJson(); Optional<String> getTimestampField(); @JsonSetter("timestampField") void setTimestampField(String timestampField); void setTimestampField(Optional<String> timestampField); ProfilerConfig withTimestampField(Optional<String> timestampField); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static ProfilerConfig fromBytes(byte[] bytes); static ProfilerConfig fromJSON(String json); String toJSON();  }
@Test public void testFromJSON() throws IOException { ProfilerConfig conf = ProfilerConfig.fromJSON(profile); assertFalse(conf.getTimestampField().isPresent()); assertEquals(1, conf.getProfiles().size()); }
@Test public void testKryoSerialization() throws Exception { ProfilerConfig expected = ProfilerConfig.fromJSON(profilesToSerialize); assertNotNull(expected); Kryo kryo = new Kryo(); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Output output = new Output(byteStream); kryo.writeObject(output, expected); byte[] bits = output.toBytes(); assertNotNull(bits); Input input = new Input(new ByteArrayInputStream(bits)); ProfilerConfig actual = kryo.readObject(input, ProfilerConfig.class); assertNotNull(actual); assertEquals(expected, actual); }
@Test public void testJavaSerialization() throws Exception { ProfilerConfig expected = ProfilerConfig.fromJSON(profilesToSerialize); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bytes); out.writeObject(expected); byte[] raw = bytes.toByteArray(); assertTrue(raw.length > 0); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(raw)); Object actual = in.readObject(); assertEquals(expected, actual); }