PackageList { @Nonnull @MustNotContainNull public List<Package> getPackages() { return this.packages; } PackageList(@Nonnull @MustNotContainNull final File file, @Nonnull final String text, @Nonnull final ContentProvider contentProvider); @Nonnull @MustNotContainNull List<Package> getPackages();  }
@Test public void testTwoPackages() throws Exception { final PackageList parsed = new PackageList(FAKE_FILE, " + "package: github.com/gizak/termui + "package: some/pack , branch:445566, tag:sometag, revision: r.33.3434342323", STUB_CP); assertEquals(2, parsed.getPackages().size()); assertEquals("github.com/gizak/termui", parsed.getPackages().get(0).getPackage()); assertNull(parsed.getPackages().get(0).getBranch()); assertNull(parsed.getPackages().get(0).getRevision()); assertNull(parsed.getPackages().get(0).getTag()); assertEquals("some/pack", parsed.getPackages().get(1).getPackage()); assertEquals("445566", parsed.getPackages().get(1).getBranch()); assertEquals("sometag", parsed.getPackages().get(1).getTag()); assertEquals("r.33.3434342323", parsed.getPackages().get(1).getRevision()); }
@Test public void testInclude() throws Exception { final PackageList parsed = new PackageList(FAKE_FILE, "#include \"./another\" @Override @Nonnull public String readContent(@Nonnull final File pathElements) throws IOException { assertEquals("another", FilenameUtils.normalize(pathElements.getPath())); return "package: external"; } }); assertEquals(3,parsed.getPackages().size()); assertEquals("external", parsed.getPackages().get(0).getPackage()); assertEquals("one", parsed.getPackages().get(1).getPackage()); assertEquals("two", parsed.getPackages().get(2).getPackage()); }
@Test public void testEmptyText() throws Exception { assertEquals(0, new PackageList(FAKE_FILE, "", STUB_CP).getPackages().size()); }
@Test public void testOnlyCommentLine() throws Exception { assertEquals(0, new PackageList(FAKE_FILE, " }
@Test public void testOnlyPackageName() throws Exception { final PackageList parsed = new PackageList(FAKE_FILE, " assertEquals(1, parsed.getPackages().size()); assertEquals("github.com/gizak/termui", parsed.getPackages().get(0).getPackage()); assertNull(parsed.getPackages().get(0).getBranch()); assertNull(parsed.getPackages().get(0).getRevision()); assertNull(parsed.getPackages().get(0).getTag()); }