(META: This issue is reserved for a university course. Please only work on it if it is part of your assignment)
The class org.jabref.logic.util.io.DatabaseFileLookup is used to check for existing files. The current tests do not do anything with files.
Some context:
User-facing thing
(draftish - hope, you understand)
- "general" AKA library-specific:
C:\TEMP\JabRef\linked-files\general AKA library-specific
- "user-specific":
C:\TEMP\JabRef\linked-files\user-specific

Main file directory
One needs to set the main file directory, too:

C:\TEMP\JabRef\linked-files\global
Example:
@Article{test,
file = {:test.pdf},
}
Where is test.pdf located?
Is it C:\TEMP\JabRef\linked-files\global, C:\TEMP\JabRef\linked-files\general AKA library-specific, is it C:\TEMP\JabRef\linked-files\user-specific? Which directory is JabRef finding? What if the file is in two of these directories?
Task
Create a test for DatabaseFileLookup covering both a present and an absent file.
Hints:
- Use
@TempDir tmpDir and create file there
- Create on file
x.txt there (Files.write(...))
- Set the
tmpDir as metaData.getDefaultFileDirectory() (mockito!)
- Crete a
BibDatabaseContext with a BibDatabase with two entries. Both entries with an attached file. The first one with x.txt, the other one with y.txt
assert that x.txt is found, but not y.txt. (org.jabref.logic.util.io.DatabaseFileLookup#lookupDatabase)
- Use IntellIjs code coverage feature to check if all lines of DatabaseFileLookup were covered. If not: create more test cases...
Hints:
- First write the initial test
- Then, use the debugger to step though and check how the code of
org.jabref.logic.util.io.DatabaseFileLookup works
- Finish the test
(META: This issue is reserved for a university course. Please only work on it if it is part of your assignment)
The class
org.jabref.logic.util.io.DatabaseFileLookupis used to check for existing files. The current tests do not do anything with files.Some context:
User-facing thing
(draftish - hope, you understand)
C:\TEMP\JabRef\linked-files\general AKA library-specificC:\TEMP\JabRef\linked-files\user-specificMain file directory
One needs to set the main file directory, too:
C:\TEMP\JabRef\linked-files\globalExample:
Where is
test.pdflocated?Is it
C:\TEMP\JabRef\linked-files\global,C:\TEMP\JabRef\linked-files\general AKA library-specific, is itC:\TEMP\JabRef\linked-files\user-specific? Which directory is JabRef finding? What if the file is in two of these directories?Task
Create a test for
DatabaseFileLookupcovering both a present and an absent file.Hints:
@TempDir tmpDirand create file therex.txtthere (Files.write(...))tmpDirasmetaData.getDefaultFileDirectory()(mockito!)BibDatabaseContextwith aBibDatabasewith two entries. Both entries with an attached file. The first one withx.txt, the other one withy.txtassertthatx.txtis found, but noty.txt. (org.jabref.logic.util.io.DatabaseFileLookup#lookupDatabase)Hints:
org.jabref.logic.util.io.DatabaseFileLookupworks