diff options
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/styles/ParagraphMatcherTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/styles/ParagraphMatcherTests.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/styles/ParagraphMatcherTests.java b/src/test/java/org/zwobble/mammoth/tests/styles/ParagraphMatcherTests.java index fdaa075..436dc62 100644 --- a/src/test/java/org/zwobble/mammoth/tests/styles/ParagraphMatcherTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/styles/ParagraphMatcherTests.java @@ -1,6 +1,7 @@ package org.zwobble.mammoth.tests.styles; import org.junit.Test; +import org.zwobble.mammoth.documents.NumberingLevel; import org.zwobble.mammoth.documents.Paragraph; import org.zwobble.mammoth.documents.Style; import org.zwobble.mammoth.styles.ParagraphMatcher; @@ -12,6 +13,7 @@ import static com.natpryce.makeiteasy.MakeItEasy.make; import static com.natpryce.makeiteasy.MakeItEasy.with; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.NUMBERING; import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.PARAGRAPH; import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.STYLE; @@ -70,4 +72,40 @@ public class ParagraphMatcherTests { with(STYLE, Optional.of(new Style("TipsParagraph", Optional.of("Tips Paragraph")))))); assertTrue(matcher.matches(paragraphWithCorrectStyleName)); } + + @Test + public void matcherWithOrderedListOnlyMatchesParagraphsWithOrderedListAtThatLeve() { + ParagraphMatcher matcher = ParagraphMatcher.orderedList("4"); + assertFalse(matcher.matches(make(a(PARAGRAPH)))); + + Paragraph paragraphWithCorrectNumbering = make(a(PARAGRAPH, + with(NUMBERING, Optional.of(NumberingLevel.ordered("4"))))); + assertTrue(matcher.matches(paragraphWithCorrectNumbering)); + + Paragraph paragraphWithIncorrectLevel = make(a(PARAGRAPH, + with(NUMBERING, Optional.of(NumberingLevel.ordered("3"))))); + assertFalse(matcher.matches(paragraphWithIncorrectLevel)); + + Paragraph paragraphWithIncorrectOrdering = make(a(PARAGRAPH, + with(NUMBERING, Optional.of(NumberingLevel.unordered("4"))))); + assertFalse(matcher.matches(paragraphWithIncorrectOrdering)); + } + + @Test + public void matcherWithUnorderedListOnlyMatchesParagraphsWithUnrderedListAtThatLeve() { + ParagraphMatcher matcher = ParagraphMatcher.unorderedList("4"); + assertFalse(matcher.matches(make(a(PARAGRAPH)))); + + Paragraph paragraphWithCorrectNumbering = make(a(PARAGRAPH, + with(NUMBERING, Optional.of(NumberingLevel.unordered("4"))))); + assertTrue(matcher.matches(paragraphWithCorrectNumbering)); + + Paragraph paragraphWithIncorrectLevel = make(a(PARAGRAPH, + with(NUMBERING, Optional.of(NumberingLevel.unordered("3"))))); + assertFalse(matcher.matches(paragraphWithIncorrectLevel)); + + Paragraph paragraphWithIncorrectOrdering = make(a(PARAGRAPH, + with(NUMBERING, Optional.of(NumberingLevel.ordered("4"))))); + assertFalse(matcher.matches(paragraphWithIncorrectOrdering)); + } } |
