Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for DatabaseFileLookup #678

Open
koppor opened this issue Feb 13, 2024 · 1 comment · Fixed by arfazhxss/jabref#1
Open

Add tests for DatabaseFileLookup #678

koppor opened this issue Feb 13, 2024 · 1 comment · Fixed by arfazhxss/jabref#1
Labels

Comments

@koppor
Copy link
Member

koppor commented Feb 13, 2024

(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

image

Main file directory

One needs to set the main file directory, too:

image

  • 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
@koppor
Copy link
Member Author

koppor commented Apr 11, 2024

I am so sorry that my "hints" section above that the task list was complete.

The intention of the task was that students think of test cases.

Here some hints:

  • JabRef has 3 different file directories
    • global one
    • library-specific
    • user-specific

Thus, file can be placed in

  • global one
  • library-specific
  • user-specific
  • directory of other user

File can exist in multiple directories.

The work should cover all cases derived from that.

These are:

  • file in user-specific directory and global directory. Found in user-specific dir.
  • file in user-specific directory and library-specific directory. Found in user-specific dir.
  • file in user-specific directory and library-specific directory and global directory. Found in user-specific dir.
  • file in user-specific directory of other user and library-specific directory and global directory. Found in library-specific dir.
  • file in user-specific directory of other user and global directory. Found in global dir.
  • file in library-specific directory and global directory. Found in library-specific dir.
  • File in global-directory only. Found there.
  • File in user-specific directory. Found there.
  • File in library-specific directory. Found there.

(that list is complete IMHO)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant