Skip to content

Commit 378ebdb

Browse files
committed
changed input file regexp
1 parent f14189a commit 378ebdb

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

post-processing-tool/src/main/java/com/bc/fiduceo/post/PostProcessingTool.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static PostProcessingContext initializeContext(CommandLine commandLine) throws I
110110

111111
void runPostProcessing() throws Exception {
112112
final Path inputDirectory = context.getMmdInputDirectory();
113-
final Pattern pattern = Pattern.compile("mmd\\d{1,2}.*_.*_.*_\\d{4}-\\d{3}_\\d{4}-\\d{3}.nc");
113+
final Pattern pattern = getFileNamePattern();
114114

115115
try (Stream<Path> pathStream = Files.walk(inputDirectory)) {
116116
final Stream<Path> regularFiles = pathStream.filter(path -> Files.isRegularFile(path));
@@ -132,6 +132,11 @@ static String getDate(CommandLine commandLine, final String optionName) {
132132
return dateString;
133133
}
134134

135+
136+
static Pattern getFileNamePattern() {
137+
return Pattern.compile("\\w*\\d{1,2}.*_.*_.*_\\d{4}-\\d{3}_\\d{4}-\\d{3}.nc");
138+
}
139+
135140
// package access for testing only se 2016-11-28
136141
static void printUsageTo(OutputStream outputStream) {
137142
final PrintWriter writer = new PrintWriter(outputStream);

post-processing-tool/src/test/java/com/bc/fiduceo/post/PostProcessingToolTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import java.util.ArrayList;
4343
import java.util.Arrays;
4444
import java.util.List;
45+
import java.util.regex.Pattern;
4546

4647
import static org.hamcrest.Matchers.equalToIgnoringWhiteSpace;
4748
import static org.junit.Assert.assertEquals;
@@ -351,6 +352,18 @@ public void testGetVariableRemoveNamesList_twoPostProcessings_duplicateNames() {
351352
assertTrue(namesList.contains("Hermann"));
352353
}
353354

355+
@Test
356+
public void testFileNamePattern() {
357+
final Pattern pattern = PostProcessingTool.getFileNamePattern();
358+
359+
assertTrue(pattern.matcher("mmd08_aatsr-en_avhrr-frac-ma_2012-092_2012-092.nc").matches());
360+
assertTrue(pattern.matcher("mmd09_slstr-s3a-nt_avhrr-frac-ma_2019-115_2019-115.nc").matches());
361+
assertTrue(pattern.matcher("coo_2_slstr-s3a-nt_avhrr-frac-mb_2020-241_2020-241.nc").matches());
362+
363+
assertFalse(pattern.matcher("NSS.FRAC.M3.D19261.S1708.E1849.B0448586.SV").matches());
364+
assertFalse(pattern.matcher("20161122200700-ESACCI-L1C-AVHRR18_G-fv01.0.nc").matches());
365+
}
366+
354367
private PostProcessingConfig getConfig() throws Exception {
355368
final Document document = new Document(root);
356369

0 commit comments

Comments
 (0)