use of com.haulmont.cuba.gui.components.DatePicker in project cuba by cuba-platform.
the class DatePickerDsTest method testDatasourceRepeatableAssign.
@Test
public void testDatasourceRepeatableAssign() {
DatePicker datePicker = (DatePicker) factory.createComponent(DatePicker.NAME);
datePicker.setDatasource(null, null);
datePicker.setDatasource(null, null);
Datasource<User> userDs1 = getTestUserDatasource();
datePicker.setDatasource(userDs1, "updateTs");
datePicker.setDatasource(userDs1, "updateTs");
boolean exceptionWasThrown = false;
try {
datePicker.setDatasource(userDs1, null);
} catch (Exception e) {
exceptionWasThrown = true;
}
assertTrue(exceptionWasThrown);
exceptionWasThrown = false;
try {
datePicker.setDatasource(null, "updateTs");
} catch (Exception e) {
exceptionWasThrown = true;
}
assertTrue(exceptionWasThrown);
Date updateTs = new Date();
userDs1.getItem().setUpdateTs(updateTs);
datePicker.setDatasource(userDs1, "updateTs");
Datasource<User> userDs2 = getTestUserDatasource();
datePicker.setDatasource(userDs2, "updateTs");
datePicker.setValue(new Date());
assertEquals(updateTs, userDs1.getItem().getUpdateTs());
}
Aggregations