@Test public void subTitleTest() throws Exception { try (InputStream is = GvkParserTest.class.getResourceAsStream("gvk_artificial_subtitle_test.xml")) { GvkParser parser = new GvkParser(); List<BibEntry> entries = parser.parseEntries(is); Assert.assertNotNull(entries); Assert.assertEquals(5, entries.size()); BibEntry entry = entries.get(0); Assert.assertEquals(Optional.empty(), entry.getField("subtitle")); entry = entries.get(1); Assert.assertEquals(Optional.of("C"), entry.getField("subtitle")); entry = entries.get(2); Assert.assertEquals(Optional.of("Word"), entry.getField("subtitle")); entry = entries.get(3); Assert.assertEquals(Optional.of("Word1 word2"), entry.getField("subtitle")); entry = entries.get(4); Assert.assertEquals(Optional.of("Word1 word2"), entry.getField("subtitle")); } }
private void doTest(String xmlName, int expectedSize, List<String> resourceNames) throws Exception { try (InputStream is = GvkParserTest.class.getResourceAsStream(xmlName)) { GvkParser parser = new GvkParser(); List<BibEntry> entries = parser.parseEntries(is); Assert.assertNotNull(entries); Assert.assertEquals(expectedSize, entries.size()); int i = 0; for (String resourceName : resourceNames) { BibEntryAssert.assertEquals(GvkParserTest.class, resourceName, entries.get(i)); i++; } } }