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);
}
}
}
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)));
}
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)));
}
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)));
}
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());
}
Aggregations