@Test void conditionalsTest() { Variables variables = new Variables(); variables.put("var", "world"); variables.put("counter", "42"); variables.put("endlessLoop2", "... ${endlessLoop} ..."); variables.put("endlessLoop3", "....................................... ${endlessLoop} ..."); XWPFDocument doc = new XWPFDocument(); List<WordDocumentTestEntry> exptected = new ArrayList<>(); add(exptected, TestHelper.createParagraph(doc, "1: Hello {if var = 'world'}Super world{endif}{if var != 'world'}${world}{endif}."), new String[]{"1: Hello Super world."}); add(exptected, TestHelper.createParagraph(doc, "2: {if counter > 5}We have more than 5 elements: ${counter}{endif}"), new String[]{"2: We have more than 5 elements: 42"}); add(exptected, TestHelper.createParagraph(doc, "3: {if counter > 5}Hello {if var = 'world'}Super world{endif}{if var != 'world'}${world}{endif}.{endif}"), new String[]{"3: Hello Super world."}); add(exptected, TestHelper.createParagraph(doc, "4: {if counter <= 42}42 or less: ${counter}{endif}"), new String[]{"4: 42 or less: 42"}); add(exptected, TestHelper.createParagraph(doc, "5: {if counter <= 41.99}---{endif}{if counter < 42}---{endif}{if counter > 42}---{endif}{if counter >= 42.1}---{endif}"), new String[]{"5: "}); add(exptected, TestHelper.createParagraph(doc, "5: {if counter <= 42}${counter}<=42{endif}, {if counter < 42.5}${counter}<42.5{endif}, {if counter > 41.8}${counter}>41.8{endif}, {if counter >= 42}42>=42{endif}" + ", {if counter = 42}${counter}=42{endif}"), new String[]{"5: 42<=42, 42<42.5, 42>41.8, 42>=42, 42=42"}); 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();  }