Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alter test assertion to allow for ocfl 1.0 and 1.1 #192

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/test/java/org/fcrepo/migration/PicocliIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public void tearDown() throws IOException {
}
}

private boolean checkDirForNamaste(final Path targetDir) throws IOException {
return Files.list(targetDir).map(Path::getFileName).map(Path::toString)
.anyMatch(e -> e.startsWith("0=ocfl_1."));
}

@Test
public void testPlainOcfl() throws Exception {
final String[] args = {"--target-dir", targetDir.toString(), "--working-dir", workingDir.toString(),
Expand All @@ -74,7 +79,7 @@ public void testPlainOcfl() throws Exception {
final CommandLine cmd = new CommandLine(migrator);

cmd.execute(args);
assertTrue(Files.list(targetDir).anyMatch(element -> element.endsWith("0=ocfl_1.0")));
assertTrue(checkDirForNamaste(targetDir));
final Path baseDir = targetDir.resolve("5b5").resolve("62d").resolve("d69")
.resolve("5b562dd698f17e3198e007e6f77f9e48f20a556c6bae84e6fc8d98544831daa6");
final File inventory = baseDir.resolve("inventory.json").toFile();
Expand All @@ -95,7 +100,7 @@ public void testPlainOcflEmptyIdPrefix() throws Exception {

final int result = cmd.execute(args);
assertEquals(0, result);
assertTrue(Files.list(targetDir).anyMatch(element -> element.endsWith("0=ocfl_1.0")));
assertTrue(checkDirForNamaste(targetDir));
final Path baseDir = targetDir.resolve("750").resolve("677").resolve("e9b")
.resolve("750677e9b953845ba5069d27a3775fbced186987fd0f4a8c968ac457a7d415a8");
final File inventory = baseDir.resolve("inventory.json").toFile();
Expand Down Expand Up @@ -129,7 +134,7 @@ public void testPlainOcflNoWorkingDirOption() throws Exception {

cmd.execute(args);
final Path workingDir = Path.of(System.getProperty("user.dir"));
assertTrue(Files.list(targetDir).anyMatch(element -> element.endsWith("0=ocfl_1.0")));
assertTrue(checkDirForNamaste(targetDir));
assertTrue(Files.list(workingDir).anyMatch(element -> element.endsWith("index")));
assertTrue(Files.list(workingDir).anyMatch(element -> element.endsWith("pid")));
}
Expand All @@ -144,8 +149,7 @@ public void testFedoraOcfl() throws Exception {
final CommandLine cmd = new CommandLine(migrator);

cmd.execute(args);
assertTrue(Files.list(targetDir.resolve("data").resolve("ocfl-root"))
.anyMatch(element -> element.endsWith("0=ocfl_1.0")));
assertTrue(checkDirForNamaste(targetDir.resolve("data").resolve("ocfl-root")));
assertTrue(Files.list(workingDir).anyMatch(element -> element.endsWith("index")));
assertTrue(Files.list(workingDir).anyMatch(element -> element.endsWith("pid")));
}
Expand All @@ -158,7 +162,7 @@ public void testExistingRepoDifferentStorageLayout() throws Exception {
.storage(OcflStorageBuilder.builder().fileSystem(targetDir).build())
.workDir(tmpDir)
.build();
assertTrue(Files.list(targetDir).anyMatch(element -> element.endsWith("0=ocfl_1.0")));
assertTrue(checkDirForNamaste(targetDir));

//migrate object into it
final Path workingDir = tmpDir.resolve("working");
Expand Down Expand Up @@ -212,8 +216,8 @@ public void testMigrateFoxmlFileInsteadOfPropertyFiles() throws Exception {
//now check for a FOXML, which should show up in a previous version
final var versions = ocflRepo.describeObject("example:1").getVersionMap().values();
boolean foundFoxml = false;
for (VersionDetails v : versions) {
for (FileDetails f : v.getFiles()) {
for (final VersionDetails v : versions) {
for (final FileDetails f : v.getFiles()) {
if (f.getPath().equals("FOXML")) {
foundFoxml = true;
break;
Expand Down Expand Up @@ -266,7 +270,7 @@ public void testSha256DigestAlgorithm() throws Exception {

final int result = cmd.execute(args);
assertEquals(0, result);
assertTrue(Files.list(targetDir).anyMatch(element -> element.endsWith("0=ocfl_1.0")));
assertTrue(checkDirForNamaste(targetDir));
final Path baseDir = targetDir.resolve("5b5").resolve("62d").resolve("d69")
.resolve("5b562dd698f17e3198e007e6f77f9e48f20a556c6bae84e6fc8d98544831daa6");
final File inventory = baseDir.resolve("inventory.json").toFile();
Expand Down