@@ -115,7 +115,7 @@ public void isValidUriDoesNotExist() throws Exception {
115
115
116
116
URI testUri = Paths .get (sourceFolderPath .toString (), "someSubPath" ).toUri ();
117
117
118
- assertFalse (ingestSource .isValidUri (testUri ));
118
+ assertTrue (ingestSource .isValidUri (testUri ));
119
119
}
120
120
121
121
@ Test
@@ -184,6 +184,31 @@ public void isValidUriNonFileUri() throws Exception {
184
184
assertFalse (ingestSource .isValidUri (uri ));
185
185
}
186
186
187
+ @ Test
188
+ public void existsNotInBase () throws Exception {
189
+ ingestSource .setBase (sourceFolderPath .toUri ().toString ());
190
+
191
+ URI uri = URI .create ("file:///some/weird/path" );
192
+ assertFalse (ingestSource .exists (uri ));
193
+ }
194
+
195
+ @ Test
196
+ public void existsInBaseNotFound () throws Exception {
197
+ ingestSource .setBase (sourceFolderPath .toUri ().toString ());
198
+
199
+ URI uri = sourceFolderPath .resolve ("unknown/path.txt" ).toUri ();
200
+ assertFalse (ingestSource .exists (uri ));
201
+ }
202
+
203
+ @ Test
204
+ public void existsSubpathExists () throws Exception {
205
+ ingestSource .setBase (sourceFolderPath .toUri ().toString ());
206
+
207
+ Path path = sourceFolderPath .resolve ("someSubPath/child" );
208
+ Files .createDirectories (path );
209
+ assertTrue (ingestSource .exists (path .toUri ()));
210
+ }
211
+
187
212
@ Test
188
213
public void listCandidatesBag () throws Exception {
189
214
ingestSource .setId ("testsource" );
@@ -307,6 +332,29 @@ public void resolveRelativePathBag() throws Exception {
307
332
assertEquals (sourceFolderPath .resolve ("bag_with_files" ).toUri (), candUri );
308
333
}
309
334
335
+ @ Test
336
+ public void resolveRelativePathBagNested () throws Exception {
337
+ ingestSource .setId ("testsource" );
338
+ ingestSource .setBase (sourceFolderPath .toUri ().toString ());
339
+ ingestSource .setPatterns (asList ("*" ));
340
+
341
+ addBagToSource (sourceFolderPath );
342
+
343
+ URI candUri = ingestSource .resolveRelativePath ("bag_with_files/data/test1.txt" );
344
+ assertEquals (sourceFolderPath .resolve ("bag_with_files/data/test1.txt" ).toUri (), candUri );
345
+ }
346
+
347
+ @ Test (expected = InvalidIngestSourceCandidateException .class )
348
+ public void resolveRelativePathBagNestedNotExist () throws Exception {
349
+ ingestSource .setId ("testsource" );
350
+ ingestSource .setBase (sourceFolderPath .toUri ().toString ());
351
+ ingestSource .setPatterns (asList ("*" ));
352
+
353
+ addBagToSource (sourceFolderPath );
354
+
355
+ ingestSource .resolveRelativePath ("bag_with_files/data/ohno.txt" );
356
+ }
357
+
310
358
@ Test (expected = InvalidIngestSourceCandidateException .class )
311
359
public void resolveRelativePathOutsideOfSource () throws Exception {
312
360
ingestSource .setId ("testsource" );
0 commit comments