diff --git a/build.gradle b/build.gradle index d86e39c8..afeca55d 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group 'com.docutools' -version = '1.4.0-rc.6' +version = '1.4.0-rc.7' sourceCompatibility = "17" targetCompatibility = "17" diff --git a/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java b/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java index 80dec8e6..148daa73 100644 --- a/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java +++ b/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java @@ -175,7 +175,8 @@ protected Optional doResolve(String placeholderName, Locale loc } private String strip(String placeholderName) { - return placeholderMapper.tryToMap(placeholderName).substring(0, placeholderName.length() - 1); + var placeholder = placeholderMapper.tryToMap(placeholderName); + return placeholder.substring(0, placeholder.length() - 1); } private Optional resolveStripped(Locale locale, String placeholder) { diff --git a/src/test/java/com/docutools/jocument/impl/word/WordGeneratorTest.java b/src/test/java/com/docutools/jocument/impl/word/WordGeneratorTest.java index e1b10780..e38199e1 100644 --- a/src/test/java/com/docutools/jocument/impl/word/WordGeneratorTest.java +++ b/src/test/java/com/docutools/jocument/impl/word/WordGeneratorTest.java @@ -210,17 +210,18 @@ void shouldResolveLegacy() throws IOException, InterruptedException { xwpfDocument = TestUtils.getXWPFDocumentFromDocument(document); var documentWrapper = new XWPFDocumentWrapper(xwpfDocument); assertThat(documentWrapper.bodyElement(0).asParagraph().text(), equalTo("Captain: Jean-Luc Picard")); - assertThat(documentWrapper.bodyElement(2).asParagraph().text(), equalTo("First Officer")); - assertThat(documentWrapper.bodyElement(3).asTable().row(0).cell(0).bodyElement(0).asParagraph().text(), equalTo("Name")); - assertThat(documentWrapper.bodyElement(3).asTable().row(0).cell(1).bodyElement(0).asParagraph().text(), equalTo("Rank")); - assertThat(documentWrapper.bodyElement(3).asTable().row(0).cell(2).bodyElement(0).asParagraph().text(), equalTo("Uniform")); - assertThat(documentWrapper.bodyElement(3).asTable().row(1).cell(0).bodyElement(0).asParagraph().text(), equalTo("Riker")); - assertThat(documentWrapper.bodyElement(3).asTable().row(1).cell(1).bodyElement(0).asParagraph().text(), equalTo("3")); - assertThat(documentWrapper.bodyElement(3).asTable().row(1).cell(2).bodyElement(0).asParagraph().text(), equalTo("Red")); - assertThat(documentWrapper.bodyElement(6).asParagraph().text(), equalTo("Services")); - assertThat(documentWrapper.bodyElement(8).asParagraph().text(), equalTo("USS Enterprise")); - assertThat(documentWrapper.bodyElement(9).asParagraph().text(), equalTo("US Defiant")); - assertThat(documentWrapper.bodyElement(11).asParagraph().text(), equalTo("And that’s that.")); + assertThat(documentWrapper.bodyElement(1).asParagraph().text(), equalTo("Riker")); + assertThat(documentWrapper.bodyElement(3).asParagraph().text(), equalTo("First Officer")); + assertThat(documentWrapper.bodyElement(4).asTable().row(0).cell(0).bodyElement(0).asParagraph().text(), equalTo("Name")); + assertThat(documentWrapper.bodyElement(4).asTable().row(0).cell(1).bodyElement(0).asParagraph().text(), equalTo("Rank")); + assertThat(documentWrapper.bodyElement(4).asTable().row(0).cell(2).bodyElement(0).asParagraph().text(), equalTo("Uniform")); + assertThat(documentWrapper.bodyElement(4).asTable().row(1).cell(0).bodyElement(0).asParagraph().text(), equalTo("Riker")); + assertThat(documentWrapper.bodyElement(4).asTable().row(1).cell(1).bodyElement(0).asParagraph().text(), equalTo("3")); + assertThat(documentWrapper.bodyElement(4).asTable().row(1).cell(2).bodyElement(0).asParagraph().text(), equalTo("Red")); + assertThat(documentWrapper.bodyElement(7).asParagraph().text(), equalTo("Services")); + assertThat(documentWrapper.bodyElement(9).asParagraph().text(), equalTo("USS Enterprise")); + assertThat(documentWrapper.bodyElement(10).asParagraph().text(), equalTo("US Defiant")); + assertThat(documentWrapper.bodyElement(12).asParagraph().text(), equalTo("And that’s that.")); } @Test diff --git a/src/test/resources/mappings.txt b/src/test/resources/mappings.txt index b5725a56..166912ba 100644 --- a/src/test/resources/mappings.txt +++ b/src/test/resources/mappings.txt @@ -1,5 +1,6 @@ //Captain Data captain-name:name +captain-first-officer-name:officer.name // Officer Data officer-name:name diff --git a/src/test/resources/templates/word/LegacyCollectionsTemplate.docx b/src/test/resources/templates/word/LegacyCollectionsTemplate.docx index b79ddfb4..b91c4682 100644 Binary files a/src/test/resources/templates/word/LegacyCollectionsTemplate.docx and b/src/test/resources/templates/word/LegacyCollectionsTemplate.docx differ