From 4e7fd5ab17814043a6611ed6012b6d6e9a8bac80 Mon Sep 17 00:00:00 2001 From: sharonl <6546457+sharonluong@users.noreply.github.com> Date: Wed, 9 Sep 2026 17:01:08 -0400 Subject: [PATCH 1/2] BXC-5896 add test --- .../cdm/services/SourceFileServiceTest.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java index 61cf8f1d..764f20d6 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java @@ -190,6 +190,25 @@ public void generateNestedMatchesTest() throws Exception { assertMappedDatePresent(); } + @Test + public void generateBasePathMatchesTest() throws Exception { + testHelper.indexExportData("mini_gilmer"); + GenerateSourceFileMappingOptions options = makeDefaultOptions(); + options.setPathPattern("*.tif"); + // add nested path + testHelper.addSourceFile("nested/path/276_182_E.tif"); + Path basePath = testHelper.addSourceFile("276_183_E.tif"); + + service.generateMapping(options); + + SourceFilesInfo info = service.loadMappings(); + assertMappingPresent(info, "25", "276_182_E.tif", null); + assertMappingPresent(info, "26", "276_183_E.tif", basePath); + assertMappingPresent(info, "27", "276_203_E.tif", null); + + assertMappedDatePresent(); + } + @Test public void generateTransformedNestedMatchTest() throws Exception { testHelper.indexExportData("mini_gilmer"); @@ -822,11 +841,6 @@ private void assertExceptionContains(String expected, Exception e) { "Expected message exception to contain '" + expected + "', but was: " + e.getMessage()); } - private void setIndexedDate() throws Exception { - project.getProjectProperties().setIndexedDate(Instant.now()); - ProjectPropertiesSerialization.write(project); - } - private void assertMappedDatePresent() throws Exception { MigrationProjectProperties props = ProjectPropertiesSerialization.read(project.getProjectPropertiesPath()); assertNotNull(props.getSourceFilesUpdatedDate()); From b77617350b51b5f77b51b5c5220004745b0cfbac Mon Sep 17 00:00:00 2001 From: sharonl <6546457+sharonluong@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:22:25 -0400 Subject: [PATCH 2/2] BXC-5896 glob match to relative path --- .../lib/boxc/migration/cdm/services/SourceFileService.java | 6 ++++-- .../boxc/migration/cdm/services/SourceFileServiceTest.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileService.java b/src/main/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileService.java index 89c0d24d..9200c5cb 100644 --- a/src/main/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileService.java +++ b/src/main/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileService.java @@ -20,6 +20,7 @@ import org.slf4j.Logger; import java.io.BufferedWriter; +import java.io.File; import java.io.IOException; import java.io.Reader; import java.nio.file.FileSystems; @@ -222,13 +223,14 @@ private Map> gatherCandidatePaths(GenerateSourceFileMapping Files.walkFileTree(basePath, new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { - if (pathPattern == null || pathMatcher.matches(path)) { + var relativePath = basePath.relativize(path); + if (pathPattern == null || pathMatcher.matches(relativePath)) { String filename = path.getFileName().toString(); if (options.isLowercaseTemplate()) { filename = filename.toLowerCase(); } List paths = candidatePaths.computeIfAbsent(filename, f -> new ArrayList<>()); - paths.add(basePath.relativize(path).toString()); + paths.add(relativePath.toString()); } return FileVisitResult.CONTINUE; } diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java index 764f20d6..b03b4d88 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java @@ -194,7 +194,8 @@ public void generateNestedMatchesTest() throws Exception { public void generateBasePathMatchesTest() throws Exception { testHelper.indexExportData("mini_gilmer"); GenerateSourceFileMappingOptions options = makeDefaultOptions(); - options.setPathPattern("*.tif"); + // test source files are in the source subdirectory of the base path + options.setPathPattern("source/*.tif"); // add nested path testHelper.addSourceFile("nested/path/276_182_E.tif"); Path basePath = testHelper.addSourceFile("276_183_E.tif");