### Question:
UnitBoxItem extends FormItem<T> implements ChoiceItem<String> { @Override public boolean validate(T value) { if (valueClass.equals(Long.class)) return (Long) value != -1l; if (valueClass.equals(Integer.class)) return (Integer) value != -1; if (valueClass.equals(String.class)) { String strVal = (String) value; if (isRequired() && strVal.equals("")) return false; else return !strVal.contains(" "); } return false; } UnitBoxItem(String propertyName, String title, Class<T> cls); void setUnitPropertyName(String name); @Override Widget asWidget(); @Override @SuppressWarnings("unchecked") T getValue(); @Override void setValue(T value); @Override void setEnabled(boolean b); @Override void setErroneous(boolean b); @Override String getErrMessage(); @Override boolean validate(T value); @Override void clearValue(); @Override void setChoices(Collection<String> units, String defUnit); FormItem<String> getUnitItem();  }### Answer:
@Test public void testValidate() { UnitBoxItem<String> ubi = new UnitBoxItem<String>("x", "X", String.class); assertFalse(ubi.validate("")); assertTrue(ubi.validate("Hi")); assertFalse(ubi.validate("x y")); UnitBoxItem<Long> ubil = new UnitBoxItem<Long>("y", "Y", Long.class); assertTrue(ubil.validate(1l)); assertTrue(ubil.validate(Long.MAX_VALUE)); assertFalse(ubil.validate(-1l)); UnitBoxItem<Integer> ubii = new UnitBoxItem<Integer>("z", "Z", Integer.class); assertTrue(ubii.validate(0)); assertTrue(ubii.validate(Integer.MAX_VALUE)); assertFalse(ubii.validate(-1)); }