@Test public void testReadStream() throws Exception { { Feed feedV4 = loadFromResource("/feeds/ninite-v4.json"); assertNumAppsAndRecipes(feedV4, 88, 0); Application appExpected = createExpectedApp(feedV4); Application app = feedV4.getApplications().get(0); Assert.assertEquals(appExpected, app); Application otherApp = feedV4.getApplications().get(1); assertThat(otherApp, is(not(equalTo(appExpected)))); appExpected.setLastRemoteUpdate(-1L); assertThat(app, is(not(equalTo(appExpected)))); testRoundTripThroughJson(feedV4,Feed.class); testRoundTripThroughJson(app,Application.class); testRoundTripThroughJson(otherApp,Application.class); } { Feed feedV3 = loadFromResource("/feeds/ninite-v3.json"); assertNumAppsAndRecipes(feedV3, 88, 0); Application appExpected = createExpectedApp(feedV3); Application app = feedV3.getApplications().get(0); Assert.assertEquals(appExpected, app); Application otherApp = feedV3.getApplications().get(1); assertThat(otherApp , is(not(equalTo(appExpected)))); } { Feed feedOffice = loadFromResource("/feeds/office2010.json"); assertNumAppsAndRecipes(feedOffice, 0, 1); } { Feed feedOffice = loadFromResource("/feeds/office2007.json"); assertNumAppsAndRecipes(feedOffice, 0, 1); } { Feed feedViewClient = loadFromResource("/feeds/view-client.json"); assertNumAppsAndRecipes(feedViewClient, 1, 1); } }
public static Feed readStream(InputStream is) throws IOException, FeedJsonFormatException { JsonNode node; try { node = AfJson.ObjectMapper().readTree(is); } catch(JsonParseException ex) { throw new FeedJsonFormatException( null, "JSON parse error: " + ex.getMessage(), ex); } finally { is.close(); } FeedJsonParser parser = new FeedJsonParser(); return parser.parse(node); }
FeedJsonParser { public static Feed readStream(InputStream is) throws IOException, FeedJsonFormatException { JsonNode node; try { node = AfJson.ObjectMapper().readTree(is); } catch(JsonParseException ex) { throw new FeedJsonFormatException( null, "JSON parse error: " + ex.getMessage(), ex); } finally { is.close(); } FeedJsonParser parser = new FeedJsonParser(); return parser.parse(node); } }
FeedJsonParser { public static Feed readStream(InputStream is) throws IOException, FeedJsonFormatException { JsonNode node; try { node = AfJson.ObjectMapper().readTree(is); } catch(JsonParseException ex) { throw new FeedJsonFormatException( null, "JSON parse error: " + ex.getMessage(), ex); } finally { is.close(); } FeedJsonParser parser = new FeedJsonParser(); return parser.parse(node); }  }
FeedJsonParser { public static Feed readStream(InputStream is) throws IOException, FeedJsonFormatException { JsonNode node; try { node = AfJson.ObjectMapper().readTree(is); } catch(JsonParseException ex) { throw new FeedJsonFormatException( null, "JSON parse error: " + ex.getMessage(), ex); } finally { is.close(); } FeedJsonParser parser = new FeedJsonParser(); return parser.parse(node); }  Feed parse(JsonNode rootNode); static Feed readStream(InputStream is); }
FeedJsonParser { public static Feed readStream(InputStream is) throws IOException, FeedJsonFormatException { JsonNode node; try { node = AfJson.ObjectMapper().readTree(is); } catch(JsonParseException ex) { throw new FeedJsonFormatException( null, "JSON parse error: " + ex.getMessage(), ex); } finally { is.close(); } FeedJsonParser parser = new FeedJsonParser(); return parser.parse(node); }  Feed parse(JsonNode rootNode); static Feed readStream(InputStream is);  }