@Test void regExpTest() { Variables variables = new Variables(); variables.put("var", "world"); variables.put("endlessLoop", "${endlessLoop}"); variables.put("endlessLoop2", "... ${endlessLoop} ..."); variables.put("endlessLoop3", "....................................... ${endlessLoop} ..."); XWPFDocument doc = new XWPFDocument(); List<WordDocumentTestEntry> exptected = new ArrayList<>(); add(exptected, TestHelper.createParagraph(doc, "1: Hello ${var}."), new String[]{"1: Hello world."}); add(exptected, TestHelper.createParagraph(doc, "2: Hello ${var}"), new String[]{"2: Hello world"}); add(exptected, TestHelper.createParagraph(doc, "${var}"), new String[]{"world"}); add(exptected, TestHelper.createParagraph(doc, "4: Hello ", "$", "{var}"), new String[]{"4: Hello ", "world"}); add(exptected, TestHelper.createParagraph(doc, ""), new String[]{""}); add(exptected, TestHelper.createParagraph(doc, "", null, "5: Hello ${", "var}"), new String[]{"", null, "5: Hello world"}); add(exptected, TestHelper.createParagraph(doc, "", null, "6: Hello ", "$", "{", "v", "ar", "}", "test"), new String[]{"", null, "6: Hello ", "world", "test"}); add(exptected, TestHelper.createParagraph(doc, "", null, "7: Hello ${", "var}. What about ${name}?"), new String[]{"", null, "7: Hello world", ". What about ${name}?"}); add(exptected, TestHelper.createParagraph(doc, "8: Hello ${var}. What about $", "{name}?"), new String[]{"8: Hello world. What about $", "{name}?"}); add(exptected, TestHelper.createParagraph(doc, "${name}", "9: Hello ${var}."), new String[]{"${name}", "9: Hello world."}); add(exptected, TestHelper.createParagraph(doc, "$", "{name}", "10: Hello ${var}."), new String[]{"$", "{name}", "10: Hello world."}); add(exptected, TestHelper.createParagraph(doc, "11: Endless loop test: ${endlessLoop}."), new String[]{"11: Endless loop test: ${endlessLoop}."}); add(exptected, TestHelper.createParagraph(doc, "12: Endless loop test 2: ${endlessLoop2}."), new String[]{"12: Endless loop test 2: ... ${endlessLoop} ...."}); add(exptected, TestHelper.createParagraph(doc, "13: Endless loop test 3: ${endlessLoop3}."), new String[]{"13: Endless loop test 3: ....................................... ${endlessLoop} ...."}); add(exptected, TestHelper.createParagraph(doc, "14: Endless loop test 3: ${end", "lessLoop3}."), new String[]{"14: Endless loop test 3: ....................................... ${endlessLoop} ...", "."}); WordDocument word = new WordDocument(doc); word.process(variables); int no = 0; for (WordDocumentTestEntry entry : exptected) { TestHelper.assertRuns(entry.par, no++, entry.expected); } }
public void process(Variables variables) { Conditionals conditionals = getConditionals(); conditionals.process(variables); replaceVariables(variables); }
WordDocument implements AutoCloseable { public void process(Variables variables) { Conditionals conditionals = getConditionals(); conditionals.process(variables); replaceVariables(variables); } }
WordDocument implements AutoCloseable { public void process(Variables variables) { Conditionals conditionals = getConditionals(); conditionals.process(variables); replaceVariables(variables); } WordDocument(XWPFDocument document);  WordDocument(String filename);  WordDocument(File wordFile);  WordDocument(InputStream inputStream, String filename); }
WordDocument implements AutoCloseable { public void process(Variables variables) { Conditionals conditionals = getConditionals(); conditionals.process(variables); replaceVariables(variables); } WordDocument(XWPFDocument document);  WordDocument(String filename);  WordDocument(File wordFile);  WordDocument(InputStream inputStream, String filename); static WordDocument load(Path path); @Override void close(); XWPFDocument getDocument(); void process(Variables variables); String scanForTemplateDefinitionReference(); String scanForTemplateId(); Conditionals getConditionals(); Set<String> getVariables(); ByteArrayOutputStream getAsByteArrayOutputStream(); String getFilename(); void setFilename(String filename); Long getLength(); }
WordDocument implements AutoCloseable { public void process(Variables variables) { Conditionals conditionals = getConditionals(); conditionals.process(variables); replaceVariables(variables); } WordDocument(XWPFDocument document);  WordDocument(String filename);  WordDocument(File wordFile);  WordDocument(InputStream inputStream, String filename); static WordDocument load(Path path); @Override void close(); XWPFDocument getDocument(); void process(Variables variables); String scanForTemplateDefinitionReference(); String scanForTemplateId(); Conditionals getConditionals(); Set<String> getVariables(); ByteArrayOutputStream getAsByteArrayOutputStream(); String getFilename(); void setFilename(String filename); Long getLength();  }