Search in sources :

Example 1 with Abbreviation

use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.

the class ManageJournalAbbreviationsViewModel method editAbbreviation.

/**
     * Method to change the currentAbbrevaition property to a new abbreviation.
     *
     * @param name         of the abbreviation object
     * @param abbreviation of the abbreviation object
     */
public void editAbbreviation(String name, String abbreviation) {
    if (isAbbreviationEditableAndRemovable.get()) {
        Abbreviation abbreviationObject = new Abbreviation(name, abbreviation);
        AbbreviationViewModel abbViewModel = new AbbreviationViewModel(abbreviationObject);
        if (abbreviations.contains(abbViewModel)) {
            if (!abbViewModel.equals(currentAbbreviation.get())) {
                dialogService.showErrorDialogAndWait(Localization.lang("Duplicated Journal Abbreviation"), Localization.lang("Abbreviation %s for journal %s already defined.", abbreviation, name));
            } else {
                setCurrentAbbreviationNameAndAbbreviationIfValid(name, abbreviation);
            }
        } else {
            setCurrentAbbreviationNameAndAbbreviationIfValid(name, abbreviation);
        }
    }
}
Also used : Abbreviation(org.jabref.logic.journals.Abbreviation)

Example 2 with Abbreviation

use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.

the class ManageJournalAbbreviationsViewModelTest method testEditAbbreviationIncludesNewAbbreviationInAbbreviationsList.

@Test
public void testEditAbbreviationIncludesNewAbbreviationInAbbreviationsList() throws Exception {
    when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile4Entries));
    viewModel.addNewFile();
    when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile5EntriesWithDuplicate));
    viewModel.addNewFile();
    viewModel.selectLastJournalFile();
    selectLastAbbreviation();
    Abbreviation testAbbreviation = new Abbreviation("YetAnotherEntry", "YAE");
    editAbbreviation(testAbbreviation);
    Assert.assertEquals(5, viewModel.abbreviationsProperty().size());
    Assert.assertTrue(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation)));
    when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(emptyTestFile));
    viewModel.addNewFile();
    viewModel.selectLastJournalFile();
    editAbbreviation(testAbbreviation);
    Assert.assertEquals(1, viewModel.abbreviationsProperty().size());
    Assert.assertFalse(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation)));
}
Also used : Abbreviation(org.jabref.logic.journals.Abbreviation) Test(org.junit.Test)

Example 3 with Abbreviation

use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.

the class ManageJournalAbbreviationsViewModelTest method testOpenValidFileContainsTheSpecificEntryAndEnoughAbbreviations.

@Test
public void testOpenValidFileContainsTheSpecificEntryAndEnoughAbbreviations() throws Exception {
    Abbreviation testAbbreviation = new Abbreviation("Test Entry", "TE");
    when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile3Entries));
    viewModel.addNewFile();
    viewModel.selectLastJournalFile();
    Assert.assertEquals(1, viewModel.journalFilesProperty().size());
    // our test file has 3 abbreviations and one pseudo abbreviation
    Assert.assertEquals(4, viewModel.abbreviationsProperty().size());
    Assert.assertTrue(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation)));
}
Also used : Abbreviation(org.jabref.logic.journals.Abbreviation) Test(org.junit.Test)

Example 4 with Abbreviation

use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.

the class ManageJournalAbbreviationsViewModelTest method testAddAbbreviationIncludesAbbreviationsInAbbreviationList.

@Test
public void testAddAbbreviationIncludesAbbreviationsInAbbreviationList() throws Exception {
    when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile4Entries));
    viewModel.addNewFile();
    when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile5EntriesWithDuplicate));
    viewModel.addNewFile();
    viewModel.selectLastJournalFile();
    Abbreviation testAbbreviation = new Abbreviation("YetAnotherEntry", "YAE");
    addAbbrevaition(testAbbreviation);
    Assert.assertEquals(6, viewModel.abbreviationsProperty().size());
    Assert.assertTrue(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation)));
}
Also used : Abbreviation(org.jabref.logic.journals.Abbreviation) Test(org.junit.Test)

Example 5 with Abbreviation

use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.

the class IntegrityCheckTest method assertWrong.

private void assertWrong(BibDatabaseContext context) {
    List<IntegrityMessage> messages = new IntegrityCheck(context, mock(FileDirectoryPreferences.class), createBibtexKeyPatternPreferences(), new JournalAbbreviationRepository(new Abbreviation("IEEE Software", "IEEE SW"))).checkBibtexDatabase();
    assertFalse(messages.toString(), messages.isEmpty());
}
Also used : Abbreviation(org.jabref.logic.journals.Abbreviation) JournalAbbreviationRepository(org.jabref.logic.journals.JournalAbbreviationRepository)

Aggregations

Abbreviation (org.jabref.logic.journals.Abbreviation)15 Test (org.junit.Test)9 JournalAbbreviationRepository (org.jabref.logic.journals.JournalAbbreviationRepository)3 DefaultTableModel (javax.swing.table.DefaultTableModel)1 UndoableFieldChange (org.jabref.gui.undo.UndoableFieldChange)1 Defaults (org.jabref.model.Defaults)1 BibDatabase (org.jabref.model.database.BibDatabase)1 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)1 BibEntry (org.jabref.model.entry.BibEntry)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1