AtomFeedJsonReader implements AtomFeedReader { public final AtomEntry<JsonObject> readAtomEntry(final InputStream in) { try (final JsonReader jsonReader = Json.createReader(new InputStreamReader(in))) { final JsonObject jsonObj = jsonReader.readObject(); try { final String eventStreamId = ((JsonString) JsonPath.read(jsonObj, "$.content.eventStreamId")).getString(); final int eventNumber = ((JsonNumber) JsonPath.read(jsonObj, "$.content.eventNumber")).intValue(); final String eventType = ((JsonString) JsonPath.read(jsonObj, "$.content.eventType")).getString(); final String eventId = ((JsonString) JsonPath.read(jsonObj, "$.content.eventId")).getString(); final JsonObject escMetaObj = JsonPath.read(jsonObj, "$.content.metadata"); final String dataContentTypeStr = escMetaObj.getString("data-content-type"); final EnhancedMimeType dataContentType = EnhancedMimeType.create(dataContentTypeStr); final JsonObject data = JsonPath.read(jsonObj, "$.content.data"); final EnhancedMimeType metaContentType; final String metaTypeStr; final JsonObject meta; if (escMetaObj.containsKey("meta-type")) { metaTypeStr = escMetaObj.getString("meta-type"); final String metaContentTypeStr = escMetaObj.getString("meta-content-type"); metaContentType = EnhancedMimeType.create(metaContentTypeStr); meta = escMetaObj; } else { metaTypeStr = null; metaContentType = null; meta = null; } return new AtomEntry<JsonObject>(eventStreamId, eventNumber, eventType, eventId, dataContentType, metaContentType, metaTypeStr, data, meta); } catch (final RuntimeException ex) { LOG.error("Failed to parse JSON atom feed: " + jsonObj); throw ex; } } }  @Override final List<URI> readAtomFeed(final InputStream in); @Override final CommonEvent readEvent(final DeserializerRegistry desRegistry, final InputStream in); final AtomEntry<JsonObject> readAtomEntry(final InputStream in);  }
@Test public void testReadAtomEntryContent() throws IOException { final AtomFeedJsonReader testee = new AtomFeedJsonReader(); final InputStream in = this.getClass().getResourceAsStream("/atom-feed-event-0.json"); try { final AtomEntry<?> entry = testee.readAtomEntry(in); assertThat(entry.getEventStreamId()).isEqualTo("MyStreamA"); assertThat(entry.getEventNumber()).isEqualTo(0); assertThat(entry.getEventType()).isEqualTo("MyEvent"); assertThat(entry.getEventId()).isEqualTo("8faef866-b80f-4952-9124-62819a6517aa"); assertThat(entry.getDataContentType()).isEqualTo( EnhancedMimeType.create("application/xml; encoding=utf-8")); assertThat(entry.getMetaContentType()).isEqualTo( EnhancedMimeType.create("application/xml; encoding=utf-8")); assertThat(entry.getData()).isInstanceOf(JsonObject.class); assertThat(entry.getMeta()).isInstanceOf(JsonObject.class); } finally { in.close(); } }