@Test public void shouldReturnFalseStringWhenFalseBooleanIsSupplied() throws Exception { BooleanField field = new BooleanField(new HashMap<String, Object>(), _spanishLocale, _usLocale); assertEquals("false", field.convertToData(false)); }
@Test public void shouldReturnBooleanWhenFalseStringIsSupplied() throws Exception { BooleanField field = new BooleanField(new HashMap<String, Object>(), _spanishLocale, _usLocale); assertFalse(field.convertFromString("false")); }
@Test public void shouldReturnNullWhenNullBooleanIsSupplied() throws Exception { BooleanField field = new BooleanField(new HashMap<String, Object>(), _spanishLocale, _usLocale); assertNull(field.convertToData(null)); }
@Test public void shouldReturnNullWhenNullBooleanIsSupplied() throws Exception { BooleanField field = new BooleanField(new HashMap<String, Object>(), _usLocale, _usLocale); field.setCurrentValue(null); assertNull(field.toFormattedString()); }
@Test public void shouldReturnFalseStringWhenFalseBooleanIsSupplied() throws Exception { BooleanField field = new BooleanField(new HashMap<String, Object>(), _usLocale, _usLocale); field.setCurrentValue(false); assertEquals("No", field.toFormattedString()); }
@Test public void shouldReturnTrueStringWhenTrueBooleanIsSupplied() throws Exception { BooleanField field = new BooleanField(new HashMap<String, Object>(), _spanishLocale, _usLocale); field.setCurrentValue(true); assertEquals("true", field.toData()); }
@Test public void shouldUseFalseAsDefaultValueWhenNoPredefinedValue() throws Exception { String xsd = "<root available-locales=\"en_US\" default-locale=\"en_US\"> " + "<dynamic-element " + "dataType=\"boolean\" " + "type=\"checkbox\" " + "name=\"A_Bool\" > " + "</dynamic-element>" + "</root>"; List<Field> resultList = new XSDParser().parse(xsd, _usLocale); BooleanField booleanField = (BooleanField) resultList.get(0); assertFalse(booleanField.getCurrentValue()); }
private void createFields() { chargeField = new CurrencyField(); chargeField.setCaption("Charge"); chargeField.setSimpleName("proccharge"); unitsField = new IntegerField("procunits", "Units"); unitsField.setMinValue(1); unitsField.setSize(6); // unitsField.setDefaultValue(); unitsField.setFlag(DialogField.FLDFLAG_REQUIRED); emgField = new BooleanField(); emgField.setSimpleName("emg"); emgField.setCaption("EMG"); emgField.setStyle(BooleanField.BOOLSTYLE_CHECK); /* Add fields to the composite */ addChildField(chargeField); addChildField(unitsField); addChildField(emgField); }
@Test public void shouldReturnStringFieldObject() throws Exception { String xsd = "<root available-locales=\"en_US\" default-locale=\"en_US\"> " + "<dynamic-element " + "dataType=\"boolean\" " + "type=\"checkbox\" " + "name=\"A_Bool\" > " + "<meta-data locale=\"en_US\"> " + "<entry name=\"predefinedValue\"><![CDATA[false]]></entry> " + "</meta-data> " + "</dynamic-element>" + "</root>"; List<Field> resultList = new XSDParser().parse(xsd, _usLocale); assertNotNull(resultList); assertEquals(1, resultList.size()); Field resultField = resultList.get(0); assertTrue(resultField instanceof BooleanField); BooleanField booleanField = (BooleanField) resultField; assertEquals(Field.DataType.BOOLEAN.getValue(), booleanField.getDataType().getValue()); assertEquals(Field.EditorType.CHECKBOX.getValue(), booleanField.getEditorType().getValue()); assertEquals("A_Bool", booleanField.getName()); assertFalse(booleanField.getCurrentValue()); assertFalse(booleanField.getPredefinedValue()); }
@Test public void shouldReturnTrueStringWhenTrueBooleanIsSupplied() throws Exception { BooleanField field = new BooleanField(new HashMap<String, Object>(), _usLocale, _usLocale); assertEquals("Yes", field.convertToFormattedString(true)); }
public Object getData() { return (Boolean) fld.getValue(); }
public void setProperty(Object val) { Boolean v = (Boolean) val; fld.setField(v); }