@Test public void test() throws IOException { StubClass stubClass = new StubClass(); stubClass.setI1(1); stubClass.setI2(2); stubClass.setL1(3L); stubClass.setL2(4L); stubClass.getList1().add("str1"); stubClass.getList1().add("str2"); stubClass.getM1().put("key1", 5); stubClass.getM1().put("key2", 6); stubClass.getM1().put("key3", 7); stubClass.setSeverity(SeverityLevel.Critical); stubClass.setB1(true); stubClass.setSh1((short)4); stubClass.setF1(5.0f); stubClass.setF2(6.0f); stubClass.setD1(7.0); stubClass.setD2(8.0); Buffer buffer = new Buffer(); JsonWriter writer = JsonWriter.of(buffer); JsonTelemetryDataSerializer tested = new JsonTelemetryDataSerializer(writer); stubClass.serialize(tested); tested.close(); writer.close(); String str = new String(buffer.readByteArray(), Charsets.UTF_8); System.out.println("[test] Serialized StubClass: " + str); Gson gson = new Gson(); StubClass bac = gson.fromJson(str, StubClass.class); assertEquals(bac.i1, stubClass.i1); assertEquals(bac.i2, stubClass.i2); assertEquals(bac.l1, stubClass.l1); assertEquals(bac.l2, stubClass.l2); assertEquals(bac.list1, stubClass.list1); assertEquals(bac.m1, stubClass.m1); assertEquals(bac.severity, stubClass.severity); assertEquals(bac.b1, stubClass.b1); assertEquals(bac.sh1, stubClass.sh1); assertEquals(bac.f1, stubClass.f1, 0.001); assertEquals(bac.f2, stubClass.f2, 0.001); assertEquals(bac.d1, stubClass.d1, 0.001); assertEquals(bac.d2, stubClass.d2, 0.001); assertEquals(str, gson.toJson(bac)); }
public void close() throws IOException { out.endObject(); }
JsonTelemetryDataSerializer { public void close() throws IOException { out.endObject(); } }
JsonTelemetryDataSerializer { public void close() throws IOException { out.endObject(); } JsonTelemetryDataSerializer(JsonWriter out); }
JsonTelemetryDataSerializer { public void close() throws IOException { out.endObject(); } JsonTelemetryDataSerializer(JsonWriter out); void reset(JsonWriter out); void close(); void write(String name, Duration value); void write(String name, DataPointType value); void write(String name, int value); void write(String name, com.microsoft.applicationinsights.internal.schemav2.SeverityLevel value); void write(String name, Integer value); void write(String name, double value); void write(String name, Double value); void write(String name, short value); void write(String name, Short value); void write(String name, long value); void write(String name, Long value); void write(String name, boolean value); void write(String name, Boolean value); void write(String name, Date value); void write(String name, String value, int len); void writeRequired(String name, String value, int len); void write(String name, T value); void write(String name, Map<String, T> map); void write(String name, List<T> list); }
JsonTelemetryDataSerializer { public void close() throws IOException { out.endObject(); } JsonTelemetryDataSerializer(JsonWriter out); void reset(JsonWriter out); void close(); void write(String name, Duration value); void write(String name, DataPointType value); void write(String name, int value); void write(String name, com.microsoft.applicationinsights.internal.schemav2.SeverityLevel value); void write(String name, Integer value); void write(String name, double value); void write(String name, Double value); void write(String name, short value); void write(String name, Short value); void write(String name, long value); void write(String name, Long value); void write(String name, boolean value); void write(String name, Boolean value); void write(String name, Date value); void write(String name, String value, int len); void writeRequired(String name, String value, int len); void write(String name, T value); void write(String name, Map<String, T> map); void write(String name, List<T> list);  }