use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class PathUtilsTest method testGetBagitDirUsingBag.
@Test
public void testGetBagitDirUsingBag() {
Bag bag = new Bag(new Version(2, 0));
bag.setRootDir(Paths.get("foo"));
Path expectedPath = bag.getRootDir().resolve(".bagit");
Path actualPath = PathUtils.getBagitDir(bag);
assertEquals(expectedPath, actualPath);
bag = new Bag(new Version(0, 97));
bag.setRootDir(Paths.get("foo"));
expectedPath = bag.getRootDir();
actualPath = PathUtils.getBagitDir(bag);
assertEquals(expectedPath, actualPath);
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagLinterTest method testCheckAgainstProfile.
@Test
public void testCheckAgainstProfile() throws Exception {
Path profileJson = new File("src/test/resources/bagitProfiles/exampleProfile.json").toPath();
Path bagRootPath = new File("src/test/resources/bagitProfileTestBags/profileConformantBag").toPath();
BagReader reader = new BagReader();
Bag bag = reader.read(bagRootPath);
try (InputStream inputStream = Files.newInputStream(profileJson, StandardOpenOption.READ)) {
BagLinter.checkAgainstProfile(inputStream, bag);
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagProfileCheckerTest method testRequiredTagManifestNotPresentException.
@Test(expected = RequiredManifestNotPresentException.class)
public void testRequiredTagManifestNotPresentException() throws Exception {
Path bagRootPath = new File("src/test/resources/bagitProfileTestBags/missingRequiredTagManifestBag").toPath();
Bag bag = reader.read(bagRootPath);
try (InputStream inputStream = Files.newInputStream(profileJson, StandardOpenOption.READ)) {
BagProfileChecker.bagConformsToProfile(inputStream, bag);
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagProfileCheckerTest method testBagitVersionIsNotAcceptableException.
@Test(expected = BagitVersionIsNotAcceptableException.class)
public void testBagitVersionIsNotAcceptableException() throws Exception {
Path bagRootPath = new File("src/test/resources/bagitProfileTestBags/wrongBagitVersionBag").toPath();
Bag bag = reader.read(bagRootPath);
try (InputStream inputStream = Files.newInputStream(profileJson, StandardOpenOption.READ)) {
BagProfileChecker.bagConformsToProfile(inputStream, bag);
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagProfileCheckerTest method testMetatdataValueIsNotAcceptableException.
@Test(expected = MetatdataValueIsNotAcceptableException.class)
public void testMetatdataValueIsNotAcceptableException() throws Exception {
Path bagRootPath = new File("src/test/resources/bagitProfileTestBags/wrongValueForContactNameBag").toPath();
Bag bag = reader.read(bagRootPath);
try (InputStream inputStream = Files.newInputStream(profileJson, StandardOpenOption.READ)) {
BagProfileChecker.bagConformsToProfile(inputStream, bag);
}
}
Aggregations