use of com.haulmont.cuba.gui.components.TextField in project cuba by cuba-platform.
the class TextFieldDsTest method testDatasourceRepeatableAssign.
@Test
public void testDatasourceRepeatableAssign() {
TextField textField = (TextField) factory.createComponent(TextField.NAME);
textField.setDatasource(null, null);
textField.setDatasource(null, null);
Datasource<User> userDs1 = getTestUserDatasource();
boolean exceptionWasThrown = false;
try {
textField.setDatasource(userDs1, null);
} catch (Exception e) {
exceptionWasThrown = true;
}
assertTrue(exceptionWasThrown);
exceptionWasThrown = false;
try {
textField.setDatasource(null, "name");
} catch (Exception e) {
exceptionWasThrown = true;
}
assertTrue(exceptionWasThrown);
textField.setDatasource(userDs1, "name");
textField.setDatasource(userDs1, "name");
userDs1.getItem().setName("Test name");
textField.setDatasource(userDs1, "name");
Datasource<User> userDs2 = getTestUserDatasource();
textField.setDatasource(userDs2, "name");
textField.setValue(false);
assertEquals("Test name", userDs1.getItem().getName());
}
Aggregations