44import edu .kit .datamanager .ro_crate .RoCrate ;
55import edu .kit .datamanager .ro_crate .entities .data .DataSetEntity ;
66
7+ import edu .kit .datamanager .ro_crate .entities .data .FileEntity ;
78import org .apache .commons .io .FileUtils ;
89import org .junit .jupiter .api .Test ;
910import org .junit .jupiter .api .io .TempDir ;
@@ -34,6 +35,7 @@ default void testFilesBeingAdjusted(@TempDir Path tempDir) throws IOException {
3435
3536 Path writtenCrate = tempDir .resolve ("written-crate" );
3637 Path extractionPath = tempDir .resolve ("checkMe" );
38+ String id = "id will be encoded" ;
3739 {
3840 RoCrate builtCrate = getCrateWithFileAndDir (pathToFile , pathToDir )
3941 .addDataEntity (new DataSetEntity .DataSetBuilder ()
@@ -43,6 +45,11 @@ default void testFilesBeingAdjusted(@TempDir Path tempDir) throws IOException {
4345 .setId ("lots_of_little_files/subdir-renamed/" )
4446 .build ()
4547 )
48+ .addDataEntity (new FileEntity .FileEntityBuilder ()
49+ .setId (id )
50+ .setLocation (pathToFile )
51+ .build ()
52+ )
4653 .build ();
4754 this .saveCrate (builtCrate , writtenCrate );
4855 ensureCrateIsExtractedIn (writtenCrate , extractionPath );
@@ -51,6 +58,12 @@ default void testFilesBeingAdjusted(@TempDir Path tempDir) throws IOException {
5158 HelpFunctions .printFileTree (correctCrate );
5259 HelpFunctions .printFileTree (extractionPath );
5360
61+ // Ensure the file uses the id, not the encoded id as a file name
62+ assertTrue (
63+ Files .exists (extractionPath .resolve (id )),
64+ "The file '%s' should exist, because this is the ID of the entity" .formatted (id )
65+ );
66+
5467 // The actual file name should **not** appear in the crate
5568 String fileName = pathToFile .getFileName ().toString ();
5669 assertFalse (
0 commit comments