public static void validatePersonMapJsonCodec(JsonCodec<Map<String, ImmutablePerson>> jsonCodec) { ImmutableMap<String, ImmutablePerson> expected = ImmutableMap.<String, ImmutablePerson>builder() .put("dain", new ImmutablePerson("dain", true)) .put("martin", new ImmutablePerson("martin", true)) .put("mark", new ImmutablePerson("mark", true)) .build(); String json = jsonCodec.toJson(expected); assertEquals(jsonCodec.fromJson(json), expected); byte[] bytes = jsonCodec.toJsonBytes(expected); assertEquals(jsonCodec.fromJson(bytes), expected); }
@Test public void testImmutableJsonCodec() throws Exception { JsonCodec<ImmutablePerson> jsonCodec = jsonCodec(ImmutablePerson.class); ImmutablePerson.validatePersonJsonCodec(jsonCodec); }
@Test public void testImmutableTypeTokenList() throws Exception { JsonCodec<List<ImmutablePerson>> jsonCodec = jsonCodec(new TypeToken<List<ImmutablePerson>>() {}); ImmutablePerson.validatePersonListJsonCodec(jsonCodec); }
@Test public void testImmutableTypeTokenMap() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = jsonCodec(new TypeToken<Map<String, ImmutablePerson>>() {}); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testAsymmetricJsonCodec() throws Exception { JsonCodec<ImmutablePerson> jsonCodec = jsonCodec(ImmutablePerson.class); ImmutablePerson immutablePerson = jsonCodec.fromJson("{ \"notWritable\": \"foo\" }"); assertNull(immutablePerson.getNotWritable()); }
@Test public void testImmutableMapJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, ImmutablePerson.class); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testAsymmetricJsonCodec() throws Exception { JsonCodec<ImmutablePerson> jsonCodec = jsonCodec(ImmutablePerson.class); ImmutablePerson immutablePerson = jsonCodec.fromJson("{ \"notWritable\": \"foo\" }"); assertNull(immutablePerson.getNotWritable()); }
public static void validatePersonMapJsonCodec(JsonCodec<Map<String, ImmutablePerson>> jsonCodec) { ImmutableMap<String, ImmutablePerson> expected = ImmutableMap.<String, ImmutablePerson>builder() .put("dain", new ImmutablePerson("dain", true)) .put("martin", new ImmutablePerson("martin", true)) .put("mark", new ImmutablePerson("mark", true)) .build(); String json = jsonCodec.toJson(expected); assertEquals(jsonCodec.fromJson(json), expected); byte[] bytes = jsonCodec.toJsonBytes(expected); assertEquals(jsonCodec.fromJson(bytes), expected); }
@Test public void testImmutableTypeTokenMap() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = jsonCodec(new TypeToken<Map<String, ImmutablePerson>>() {}); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testImmutableListJsonCodec() throws Exception { JsonCodec<List<ImmutablePerson>> jsonCodec = listJsonCodec(ImmutablePerson.class); ImmutablePerson.validatePersonListJsonCodec(jsonCodec); }
@Test public void testImmutableJsonCodec() throws Exception { JsonCodec<ImmutablePerson> jsonCodec = jsonCodec(ImmutablePerson.class); ImmutablePerson.validatePersonJsonCodec(jsonCodec); }
@Test public void testAsymmetricJsonCodec() throws Exception { JsonCodec<ImmutablePerson> jsonCodec = jsonCodec(ImmutablePerson.class); ImmutablePerson immutablePerson = jsonCodec.fromJson("{ \"notWritable\": \"foo\" }"); assertNull(immutablePerson.getNotWritable()); }
public static void validatePersonListJsonCodec(JsonCodec<List<ImmutablePerson>> jsonCodec) { ImmutableList<ImmutablePerson> expected = ImmutableList.of( new ImmutablePerson("dain", true), new ImmutablePerson("martin", true), new ImmutablePerson("mark", true)); String json = jsonCodec.toJson(expected); assertEquals(jsonCodec.fromJson(json), expected); byte[] bytes = jsonCodec.toJsonBytes(expected); assertEquals(jsonCodec.fromJson(bytes), expected); }
@Test public void testImmutableMapJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, ImmutablePerson.class); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testImmutableListJsonCodec() throws Exception { JsonCodec<List<ImmutablePerson>> jsonCodec = listJsonCodec(ImmutablePerson.class); ImmutablePerson.validatePersonListJsonCodec(jsonCodec); }
@Test public void testImmutableJsonCodec() throws Exception { JsonCodec<ImmutablePerson> jsonCodec = jsonCodec(ImmutablePerson.class); ImmutablePerson.validatePersonJsonCodec(jsonCodec); }
public static void validatePersonListJsonCodec(JsonCodec<List<ImmutablePerson>> jsonCodec) { ImmutableList<ImmutablePerson> expected = ImmutableList.of( new ImmutablePerson("dain", true), new ImmutablePerson("martin", true), new ImmutablePerson("mark", true)); String json = jsonCodec.toJson(expected); assertEquals(jsonCodec.fromJson(json), expected); byte[] bytes = jsonCodec.toJsonBytes(expected); assertEquals(jsonCodec.fromJson(bytes), expected); }
@Test public void testImmutableMapJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, ImmutablePerson.class); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testImmutableTypeTokenList() throws Exception { JsonCodec<List<ImmutablePerson>> jsonCodec = jsonCodec(new TypeToken<List<ImmutablePerson>>() {}); ImmutablePerson.validatePersonListJsonCodec(jsonCodec); }
public static void validatePersonMapJsonCodec(JsonCodec<Map<String, ImmutablePerson>> jsonCodec) { ImmutableMap<String, ImmutablePerson> expected = ImmutableMap.<String, ImmutablePerson>builder() .put("dain", new ImmutablePerson("dain", true)) .put("martin", new ImmutablePerson("martin", true)) .put("mark", new ImmutablePerson("mark", true)) .build(); String json = jsonCodec.toJson(expected); assertEquals(jsonCodec.fromJson(json), expected); byte[] bytes = jsonCodec.toJsonBytes(expected); assertEquals(jsonCodec.fromJson(bytes), expected); }