### Question:
QuickLinksProfileParser { public QuickLinksProfile parse(byte[] input) throws IOException { return mapper.readValue(input, QuickLinksProfile.class); } QuickLinksProfileParser(); QuickLinksProfile parse(byte[] input); QuickLinksProfile parse(URL url); String encode(QuickLinksProfile profile);  }### Answer:
@Test public void testParseProfile() throws Exception { String profileName = "example_quicklinks_profile.json"; QuickLinksProfileParser parser = new QuickLinksProfileParser(); QuickLinksProfile profile = parser.parse(Resources.getResource(profileName)); assertEquals(1, profile.getFilters().size()); assertEquals( Filter.linkAttributeFilter("sso", true), profile.getFilters().get(0)); assertEquals(3, profile.getServices().size()); Service hdfs = profile.getServices().get(0); assertEquals("HDFS", hdfs.getName()); assertEquals(1, hdfs.getFilters().size()); assertEquals(1, hdfs.getComponents().size()); assertEquals( Filter.linkAttributeFilter("authenticated", true), hdfs.getFilters().get(0)); Component nameNode = hdfs.getComponents().get(0); assertEquals(2, nameNode.getFilters().size()); assertEquals( Filter.linkNameFilter("namenode_ui", "http: nameNode.getFilters().get(0)); Component historyServer = profile.getServices().get(1).getComponents().get(0); assertEquals(1, historyServer.getFilters().size()); assertEquals( Filter.acceptAllFilter(true), historyServer.getFilters().get(0)); Service yarn = profile.getServices().get(2); assertEquals(1, yarn.getFilters().size()); assertEquals( Filter.linkNameFilter("resourcemanager_ui", "http: yarn.getFilters().get(0)); }
@Test(expected = JsonProcessingException.class) public void testParseInconsistentProfile_ambigousFilterDefinition() throws Exception { String profileName = "inconsistent_quicklinks_profile.json"; QuickLinksProfileParser parser = new QuickLinksProfileParser(); parser.parse(Resources.getResource(profileName)); }
@Test(expected = JsonProcessingException.class) public void testParseInconsistentProfile_invalidLinkUrl() throws Exception { String profileName = "inconsistent_quicklinks_profile_4.json"; QuickLinksProfileParser parser = new QuickLinksProfileParser(); parser.parse(Resources.getResource(profileName)); }
@Test(expected = JsonProcessingException.class) public void testParseInconsistentProfile_misspelledFilerDefinition() throws Exception { String profileName = "inconsistent_quicklinks_profile_3.json"; QuickLinksProfileParser parser = new QuickLinksProfileParser(); parser.parse(Resources.getResource(profileName)); }