ConditionField extends Field { public void updateTrueText(String text) { conditionalTextElement.setTextStringValueIfTrueAttribute(text); } ConditionField(OdfElement odfElement, String condition, String trueText, String falseText, boolean isHiddenTextField); void updateCondition(String condition); void updateTrueText(String text); void updateFalseText(String text); @Override OdfElement getOdfElement(); @Override FieldType getFieldType();  }
@Test public void testUpdateTrueText() { try { TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT)); VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_con_variable"); Paragraph varParagraph = doc.addParagraph("test_con_variable:"); simpleVariableField.updateField("true", varParagraph.getOdfElement()); Paragraph newParagraph = doc.addParagraph("Condition Field Test:"); ConditionField conditionField = Fields.createConditionField(newParagraph.getOdfElement(), "test_con_variable == \"true\"", "trueText", "falseText"); Assert.assertNotNull(conditionField); conditionField.updateTrueText("trueTextUpdate"); TextConditionalTextElement conditionalTextElement = (TextConditionalTextElement) conditionField.getOdfElement(); conditionalTextElement.getTextStringValueIfTrueAttribute(); Assert.assertEquals("trueTextUpdate", conditionalTextElement.getTextStringValueIfTrueAttribute()); } catch (Exception e) { Logger.getLogger(ConditionFieldTest.class.getName()).log(Level.SEVERE, null, e); Assert.fail(e.getMessage()); } }