Search in sources :

Example 31 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.

the class IntegrityCheckTest method testBibtexkeyChecks.

@Test
public void testBibtexkeyChecks() {
    final BibDatabaseContext correctContext = createContext("bibtexkey", "Knuth2014");
    correctContext.getDatabase().getEntries().get(0).setField("author", "Knuth");
    correctContext.getDatabase().getEntries().get(0).setField("year", "2014");
    assertCorrect(correctContext);
    final BibDatabaseContext wrongContext = createContext("bibtexkey", "Knuth2014a");
    wrongContext.getDatabase().getEntries().get(0).setField("author", "Knuth");
    wrongContext.getDatabase().getEntries().get(0).setField("year", "2014");
    assertWrong(wrongContext);
}
Also used : BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Test(org.junit.Test)

Example 32 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.

the class SynchronizationTestSimulator method setUp.

@Before
public void setUp() throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
    this.dbmsConnection = TestConnector.getTestDBMSConnection(dbmsType);
    GlobalBibtexKeyPattern pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]");
    clientContextA = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX), DatabaseLocation.SHARED, ',', pattern);
    clientContextA.getDBMSSynchronizer().openSharedDatabase(dbmsConnection);
    clientContextB = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX), DatabaseLocation.SHARED, ',', pattern);
    clientContextB.getDBMSSynchronizer().openSharedDatabase(dbmsConnection);
    eventListenerB = new SynchronizationTestEventListener();
    clientContextB.getDBMSSynchronizer().registerListener(eventListenerB);
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) Defaults(org.jabref.model.Defaults) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Before(org.junit.Before)

Example 33 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.

the class BibDatabaseContextTest method testTypeBasedOnDefaultBibtex.

@Test
public void testTypeBasedOnDefaultBibtex() {
    BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new BibDatabase(), new MetaData(), new Defaults(BibDatabaseMode.BIBTEX));
    assertEquals(BibDatabaseMode.BIBTEX, bibDatabaseContext.getMode());
    bibDatabaseContext.setMode(BibDatabaseMode.BIBLATEX);
    assertEquals(BibDatabaseMode.BIBLATEX, bibDatabaseContext.getMode());
}
Also used : MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 34 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.

the class GroupNodeViewModelTest method setUp.

@Before
public void setUp() throws Exception {
    stateManager = mock(StateManager.class);
    when(stateManager.getSelectedEntries()).thenReturn(FXCollections.emptyObservableList());
    databaseContext = new BibDatabaseContext();
    taskExecutor = new CurrentThreadTaskExecutor();
    viewModel = getViewModelForGroup(new WordKeywordGroup("Test group", GroupHierarchyType.INDEPENDENT, "test", "search", true, ',', false));
}
Also used : StateManager(org.jabref.gui.StateManager) CurrentThreadTaskExecutor(org.jabref.gui.util.CurrentThreadTaskExecutor) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup) Before(org.junit.Before)

Example 35 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.

the class GroupTreeViewModelTest method setUp.

@Before
public void setUp() throws Exception {
    databaseContext = new BibDatabaseContext();
    stateManager = new StateManager();
    stateManager.activeDatabaseProperty().setValue(Optional.of(databaseContext));
    taskExecutor = new CurrentThreadTaskExecutor();
    groupTree = new GroupTreeViewModel(stateManager, mock(DialogService.class), taskExecutor);
}
Also used : StateManager(org.jabref.gui.StateManager) CurrentThreadTaskExecutor(org.jabref.gui.util.CurrentThreadTaskExecutor) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Before(org.junit.Before)

Aggregations

BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)48 Defaults (org.jabref.model.Defaults)24 Before (org.junit.Before)16 BibDatabase (org.jabref.model.database.BibDatabase)15 Test (org.junit.Test)13 BibEntry (org.jabref.model.entry.BibEntry)11 ParserResult (org.jabref.logic.importer.ParserResult)9 MetaData (org.jabref.model.metadata.MetaData)8 Charset (java.nio.charset.Charset)6 BibtexParser (org.jabref.logic.importer.fileformat.BibtexParser)6 Path (java.nio.file.Path)5 Scanner (java.util.Scanner)5 BibtexDatabaseWriter (org.jabref.logic.exporter.BibtexDatabaseWriter)5 SavePreferences (org.jabref.logic.exporter.SavePreferences)5 IOException (java.io.IOException)4 SaveException (org.jabref.logic.exporter.SaveException)4 BibtexImporter (org.jabref.logic.importer.fileformat.BibtexImporter)4 LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)4 FileSaveSession (org.jabref.logic.exporter.FileSaveSession)3 SaveSession (org.jabref.logic.exporter.SaveSession)3