Skip to content

Add tests for DatabaseFileLookup #678

Description

@koppor

(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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions