use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.
the class IntegrityCheckTest method assertCorrect.
private void assertCorrect(BibDatabaseContext context) {
List<IntegrityMessage> messages = new IntegrityCheck(context, mock(FileDirectoryPreferences.class), createBibtexKeyPatternPreferences(), new JournalAbbreviationRepository(new Abbreviation("IEEE Software", "IEEE SW"))).checkBibtexDatabase();
assertEquals(Collections.emptyList(), messages);
}
use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.
the class IntegrityCheckTest method testEntryIsUnchangedAfterChecks.
@Test
public void testEntryIsUnchangedAfterChecks() {
BibEntry entry = new BibEntry();
// populate with all known fields
for (String fieldName : InternalBibtexFields.getAllPublicAndInternalFieldNames()) {
entry.setField(fieldName, UUID.randomUUID().toString());
}
// add a random field
entry.setField(UUID.randomUUID().toString(), UUID.randomUUID().toString());
// duplicate entry
BibEntry clonedEntry = (BibEntry) entry.clone();
BibDatabase bibDatabase = new BibDatabase();
bibDatabase.insertEntry(entry);
BibDatabaseContext context = new BibDatabaseContext(bibDatabase, new Defaults());
new IntegrityCheck(context, mock(FileDirectoryPreferences.class), createBibtexKeyPatternPreferences(), new JournalAbbreviationRepository(new Abbreviation("IEEE Software", "IEEE SW"))).checkBibtexDatabase();
assertEquals(clonedEntry, entry);
}
use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.
the class ManageJournalAbbreviationsViewModelTest method testDeleteAbbreviationSelectsPreviousOne.
@Test
public void testDeleteAbbreviationSelectsPreviousOne() 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.assertTrue(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation)));
Assert.assertEquals(new AbbreviationViewModel(testAbbreviation), viewModel.currentAbbreviationProperty().get());
viewModel.deleteAbbreviation();
Assert.assertEquals(5, viewModel.abbreviationsProperty().size());
// check if the previous (the last) element is the current abbreviation
Assert.assertEquals(viewModel.currentAbbreviationProperty().get(), viewModel.abbreviationsProperty().get(4));
}
use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.
the class ManageJournalAbbreviationsViewModelTest method testSaveAbbreviationsToFilesCreatesNewFilesWithWrittenAbbreviations.
@Test
public void testSaveAbbreviationsToFilesCreatesNewFilesWithWrittenAbbreviations() throws Exception {
when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile4Entries));
viewModel.addNewFile();
viewModel.selectLastJournalFile();
selectLastAbbreviation();
Abbreviation testAbbreviation = new Abbreviation("JabRefTestEntry", "JTE");
editAbbreviation(testAbbreviation);
Assert.assertEquals(5, viewModel.abbreviationsProperty().size());
Assert.assertTrue(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation)));
when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile5EntriesWithDuplicate));
viewModel.addNewFile();
viewModel.selectLastJournalFile();
selectLastAbbreviation();
viewModel.deleteAbbreviation();
Abbreviation testAbbreviation1 = new Abbreviation("SomeOtherEntry", "SOE");
addAbbrevaition(testAbbreviation1);
Assert.assertEquals(5, viewModel.abbreviationsProperty().size());
Assert.assertTrue(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation1)));
viewModel.saveJournalAbbreviationFiles();
String expected = "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "JabRefTestEntry = JTE" + NEWLINE + "";
String actual = Files.contentOf(testFile4Entries.toFile(), StandardCharsets.UTF_8);
Assert.assertEquals(expected, actual);
expected = "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "SomeOtherEntry = SOE" + NEWLINE + "";
actual = Files.contentOf(testFile5EntriesWithDuplicate.toFile(), StandardCharsets.UTF_8);
Assert.assertEquals(expected, actual);
}
use of org.jabref.logic.journals.Abbreviation in project jabref by JabRef.
the class ManageJournalAbbreviationsViewModelTest method testEditSameAbbreviationWithNoChangeDoesNotResultInException.
@Test
public void testEditSameAbbreviationWithNoChangeDoesNotResultInException() throws Exception {
when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(emptyTestFile));
viewModel.addNewFile();
viewModel.selectLastJournalFile();
Abbreviation testAbbreviation = new Abbreviation("YetAnotherEntry", "YAE");
addAbbrevaition(testAbbreviation);
editAbbreviation(testAbbreviation);
Assert.assertTrue(viewModel.abbreviationsProperty().contains(new AbbreviationViewModel(testAbbreviation)));
}
Aggregations