@Test public void duplicateBibDatabaseConfiguration() throws URISyntaxException, IOException { InputStream originalStream = AuxParserTest.class.getResourceAsStream("config.bib"); File auxFile = Paths.get(AuxParserTest.class.getResource("paper.aux").toURI()).toFile(); try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) { ParserResult result = new BibtexParser(importFormatPreferences).parse(originalReader); AuxParser auxParser = new AuxParser(auxFile.getAbsolutePath(), result.getDatabase()); AuxParserResult auxResult = auxParser.parse(); BibDatabase db = auxResult.getGeneratedBibDatabase(); assertEquals(Optional.of("\"Maintained by \" # maintainer"), db.getPreamble()); assertEquals(1, db.getStringCount()); } }
@Test public void testFileNotFound() { AuxParser auxParser = new AuxParser("unknownfile.bib", new BibDatabase()); AuxParserResult auxResult = auxParser.parse(); assertFalse(auxResult.getGeneratedBibDatabase().hasEntries()); assertEquals(0, auxResult.getUnresolvedKeysCount()); BibDatabase newDB = auxResult.getGeneratedBibDatabase(); assertEquals(0, newDB.getEntries().size()); assertEquals(0, auxResult.getResolvedKeysCount()); assertEquals(0, auxResult.getFoundKeysInAux()); assertEquals( auxResult.getFoundKeysInAux() + auxResult.getCrossRefEntriesCount(), auxResult.getResolvedKeysCount() + auxResult.getUnresolvedKeysCount()); assertEquals(0, auxResult.getCrossRefEntriesCount()); }
@Test public void testNormal() throws URISyntaxException, IOException { InputStream originalStream = AuxParserTest.class.getResourceAsStream("origin.bib"); File auxFile = Paths.get(AuxParserTest.class.getResource("paper.aux").toURI()).toFile(); try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) { ParserResult result = new BibtexParser(importFormatPreferences).parse(originalReader); AuxParser auxParser = new AuxParser(auxFile.getAbsolutePath(), result.getDatabase()); AuxParserResult auxResult = auxParser.parse(); assertTrue(auxResult.getGeneratedBibDatabase().hasEntries()); assertEquals(0, auxResult.getUnresolvedKeysCount()); BibDatabase newDB = auxResult.getGeneratedBibDatabase(); assertEquals(2, newDB.getEntries().size()); assertEquals(2, auxResult.getResolvedKeysCount()); assertEquals(2, auxResult.getFoundKeysInAux()); assertEquals( auxResult.getFoundKeysInAux() + auxResult.getCrossRefEntriesCount(), auxResult.getResolvedKeysCount() + auxResult.getUnresolvedKeysCount()); assertEquals(0, auxResult.getCrossRefEntriesCount()); } }