From a504d39d40597978f2c403c6dce2408421e1eaa2 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 13 Feb 2016 18:55:28 +0000 Subject: Check warning is produced when failing to find run style --- .../java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/test/java/org/zwobble') diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java index e734d42..49d906f 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -79,7 +79,7 @@ public class BodyXmlTests { } @Test - public void paragraphHasStyleIdReadFromParagraphPropertiesIfPresent() { + public void warningIsEmittedWhenParagraphStyleCannotBeFound() { XmlElement element = paragraphXml(list( element("w:pPr", list( element("w:pStyle", map("w:val", "Heading1")))))); @@ -166,6 +166,19 @@ public class BodyXmlTests { hasStyle(Optional.of(style))); } + @Test + public void warningIsEmittedWhenRunStyleCannotBeFound() { + XmlElement element = runXml(list( + element("w:rPr", list( + element("w:rStyle", map("w:val", "Heading1Char")))))); + + assertThat( + read(a(bodyReader), element), + isResult( + hasStyle(Optional.of(new Style("Heading1Char", Optional.empty()))), + list(warning("Run style with ID Heading1Char was referenced but not defined in the document")))); + } + private static DocumentElement readSuccess(Maker reader, XmlElement element) { Result result = read(reader, element); assertThat(result.getWarnings(), deepEquals(list())); -- cgit v1.2.3