EscEvents implements ToJsonCapable { @Override public final JsonArray toJson() { final JsonArrayBuilder builder = Json.createArrayBuilder(); for (final EscEvent event : list) { builder.add(event.toJson()); } return builder.build(); } protected  EscEvents();  EscEvents(@NotNull final EscEvent... events);  EscEvents(@NotNull final List<EscEvent> events); final List<EscEvent> getList(); @Override final JsonArray toJson(); static EscEvents create(final JsonArray jsonArray); static final TypeName TYPE; static final SerializedDataType SER_TYPE; }
@Test public void testMarshalJsonB() throws Exception { final String expectedJson = IOUtils.toString(this.getClass().getResourceAsStream("/esc-events.json")); final SimpleSerializedDataTypeRegistry typeRegistry = new SimpleSerializedDataTypeRegistry(); typeRegistry.add(MyEvent.SER_TYPE, MyEvent.class); typeRegistry.add(MyMeta.SER_TYPE, MyMeta.class); final EscEvents events = new EscEvents(createEvent1(), createEvent2()); final JsonbDeSerializer jsonbDeSer = JsonbDeSerializer.builder() .withSerializers(EscSpiUtils.createEscJsonbSerializers()) .withPropertyVisibilityStrategy(new FieldAccessStrategy()) .withEncoding(Charset.forName("utf-8")) .build(); jsonbDeSer.init(typeRegistry); try (final Jsonb jsonb = jsonbDeSer.getJsonb()) { final String currentJson = jsonb.toJson(events); assertThatJson(currentJson).isEqualTo(expectedJson); } }