public String toString(OrgParserSettings settings) { StringBuilder str = new StringBuilder(); OrgParserWriter parserWriter = new OrgParserWriter(settings); str.append(parserWriter.whiteSpacedFilePreface(file.getPreface())); for (OrgNodeInList nodeInList : headsInList) { str.append(parserWriter.whiteSpacedHead(nodeInList, file.getSettings().isIndented())); } return str.toString(); } }
if (orgFile.getSettings().parseLine(line)) { orgFile.getSettings().setIndented(indentedCount > 0); listener.onFile(orgFile);
@Test public void testFileSettingsKeywords() throws IOException { OrgParsedFile file = parserBuilder.setInput("#+TITLE: Wrong title\n#+NEWKEYWORD:\n#+TITLE: Org Title\n\n* TODO Note\n").build().parse(); Assert.assertNotNull(file.getFile().getSettings()); Assert.assertNotNull(file.getFile().getSettings().getTitle()); Assert.assertEquals("Org Title", file.getFile().getSettings().getTitle()); Assert.assertNull(file.getFile().getSettings().getKeywordValues(OrgFileSettings.TITLE)); Assert.assertNull(file.getFile().getSettings().getLastKeywordValue("NEWKEYWORD")); Assert.assertTrue(file.getFile().getSettings().getKeywordValues("NEWKEYWORD").isEmpty()); }
@Test public void testFileSettingsTitle() throws IOException { OrgParsedFile file = parserBuilder.setInput("#+TITLE: Org Title\n\n* TODO Note\n").build().parse(); Assert.assertNotNull(file.getFile().getSettings()); Assert.assertNotNull(file.getFile().getSettings().getTitle()); Assert.assertEquals("Org Title", file.getFile().getSettings().getTitle()); }
@Test public void testFileSettingsAlwaysNonNull() throws IOException { OrgParsedFile file = parserBuilder.setInput("* TODO Note").build().parse(); Assert.assertNotNull(file.getFile().getSettings()); Assert.assertNull(file.getFile().getSettings().getTitle()); }
@Test public void testFileSettingsTrimUnsupportedKeyword() throws IOException { OrgParsedFile file = parserBuilder.setInput("#+NAME: value value ").build().parse(); Assert.assertEquals("value value", file.getFile().getSettings().getLastKeywordValue("NAME")); }
@Test public void testNotIndented() throws IOException { OrgParsedFile file = parserBuilder.setInput("* TODO Title\nSCHEDULED: <2015-02-11 Wed +1d>").build().parse(); Assert.assertFalse(file.getFile().getSettings().isIndented()); }
@Test public void testFileSettingsTrimSupportedKeyword() throws IOException { OrgParsedFile file = parserBuilder.setInput("#+TITLE: Title ").build().parse(); Assert.assertEquals("Title", file.getFile().getSettings().getTitle()); }
@Test public void testIndented() throws IOException { OrgParsedFile file = parserBuilder.setInput("* TODO Title\n SCHEDULED: <2015-02-11 Wed +1d>").build().parse(); Assert.assertTrue(file.getFile().getSettings().isIndented()); }
@Test public void testFileSettingsUnsupportedKeyword() throws IOException { OrgParsedFile file = parserBuilder.setInput("#+FOO: bar").build().parse(); Assert.assertEquals("bar", file.getFile().getSettings().getLastKeywordValue("FOO")); }
@Test public void testIndentedAfterCounting() throws IOException { OrgParsedFile file = parserBuilder.setInput("* TODO Title\n SCHEDULED: <2015-02-11 Wed +1d>\nDEADLINE: <2015-02-08 Sun>\n CLOSED: [2015-02-08 Sun]").build().parse(); Assert.assertTrue(file.getFile().getSettings().isIndented()); }
@Test public void testNotIndentedAfterCounting() throws IOException { OrgParsedFile file = parserBuilder.setInput("* TODO Title\nSCHEDULED: <2015-02-11 Wed +1d>\nDEADLINE: <2015-02-08 Sun>\n CLOCK: [2015-02-07 Sat 20:47]--[2015-02-07 Sat 20:47] => 0:00").build().parse(); Assert.assertFalse(file.getFile().getSettings().isIndented()); }