InstantAppUrlFinder { @NotNull public ImmutableCollection<String> getAllUrls() { TreeMultimap<Integer, String> allUrls = TreeMultimap.create(); for (Element activity : myActivities) { Node node = activity.getFirstChild(); while (node != null) { InstantAppIntentFilterWrapper wrapper = new InstantAppIntentFilterWrapper(myResolver, node); UrlData urlData = wrapper.getUrlData(); if (urlData.isValid()) { allUrls.put(wrapper.getOrder(), urlData.getUrl()); } node = node.getNextSibling(); } } return ImmutableList.copyOf(allUrls.values()); } InstantAppUrlFinder(@NotNull Module module); @VisibleForTesting  InstantAppUrlFinder(@NotNull AttributesResolver resolver, @NotNull Collection<Element> activities); @NotNull ImmutableCollection<String> getAllUrls(); @NotNull String getDefaultUrl(); boolean matchesUrl(@NotNull String url);  }
@Test public void testGetAllUrls() throws Exception { InstantAppUrlFinder finder = new InstantAppUrlFinder(myResolver, createDummyValidData()); assertEquals(4, finder.getAllUrls().size()); Collection<String> urls = finder.getAllUrls(); assertThat(urls, CoreMatchers.hasItem(CoreMatchers.anyOf( CoreMatchers.equalTo("scheme1: CoreMatchers.equalTo("scheme2: assertThat(urls, CoreMatchers.hasItem("scheme1: assertThat(urls, CoreMatchers.hasItem(CoreMatchers.anyOf( CoreMatchers.equalTo("scheme1: CoreMatchers.equalTo("scheme2: assertThat(urls, CoreMatchers.hasItem(CoreMatchers.anyOf( CoreMatchers.equalTo("scheme1: CoreMatchers.equalTo("scheme2: }
@Test public void testGetAllUrlsInvalidInput() throws Exception { InstantAppUrlFinder invalidFinder = new InstantAppUrlFinder(myResolver, ImmutableList.of((Element)createXMLContent("<intent-filter/>"))); assertEquals(0, invalidFinder.getAllUrls().size()); }