Java Code Examples for com.haulmont.cuba.security.entity.User#setUpdateTs()

The following examples show how to use com.haulmont.cuba.security.entity.User#setUpdateTs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatePickerDsTest.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnsubscribeComponentListener() {
    DatePicker datePicker = uiComponents.create(DatePicker.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();

    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    datePicker.setDatasource(userDs, "updateTs");

    // unbind
    datePicker.setDatasource(null, null);

    Consumer<HasValue.ValueChangeEvent> valueChangeListener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    datePicker.addValueChangeListener(valueChangeListener);

    user.setUpdateTs(new Date());
    assertEquals(updateTs, datePicker.getValue());
}
 
Example 2
Source File: DatePickerDsTest.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnsubscribeDsListener() {
    DatePicker datePicker = uiComponents.create(DatePicker.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    datePicker.setDatasource(userDs, "updateTs");

    // unbind
    datePicker.setDatasource(null, null);

    Datasource.ItemPropertyChangeListener<User> propertyChangeListener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    userDs.addItemPropertyChangeListener(propertyChangeListener);

    datePicker.setValue(new Date());
    assertEquals(updateTs, user.getUpdateTs());
}
 
Example 3
Source File: DatePickerDsTest.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnsubscribeSubscribeDsListener() {
    DatePicker datePicker = uiComponents.create(DatePicker.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    datePicker.setDatasource(userDs, "updateTs");

    // unbind
    datePicker.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Datasource.ItemPropertyChangeListener<User> listener = e ->
            valueWasChanged[0] = true;
    userDs.addItemPropertyChangeListener(listener);
    datePicker.setDatasource(userDs, "updateTs");

    Date updateTs2 = new Date();
    datePicker.setValue(updateTs2);
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, user.getUpdateTs());
}
 
Example 4
Source File: DateFieldDsTest.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnsubscribeComponentListener() {
    DateField dateField = uiComponents.create(DateField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();

    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    dateField.setDatasource(userDs, "updateTs");
    dateField.setResolution(DateField.Resolution.SEC);

    // unbind
    dateField.setDatasource(null, null);

    Consumer<HasValue.ValueChangeEvent> valueChangeListener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    dateField.addValueChangeListener(valueChangeListener);

    user.setUpdateTs(new Date());
    assertEquals(updateTs, dateField.getValue());
}
 
Example 5
Source File: DateFieldDsTest.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnsubscribeDsListener() {
    DateField dateField = uiComponents.create(DateField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    dateField.setDatasource(userDs, "updateTs");

    // unbind
    dateField.setDatasource(null, null);

    Datasource.ItemPropertyChangeListener<User> propertyChangeListener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    userDs.addItemPropertyChangeListener(propertyChangeListener);

    dateField.setValue(new Date());
    assertEquals(updateTs, user.getUpdateTs());
}
 
Example 6
Source File: DateFieldDsTest.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnsubscribeSubscribeDsListener() {
    DateField dateField = uiComponents.create(DateField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    dateField.setDatasource(userDs, "updateTs");

    // unbind
    dateField.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Datasource.ItemPropertyChangeListener<User> listener = e -> valueWasChanged[0] = true;
    userDs.addItemPropertyChangeListener(listener);
    dateField.setDatasource(userDs, "updateTs");
    dateField.setResolution(DateField.Resolution.SEC);

    Date updateTs2 = new Date();
    dateField.setValue(updateTs2);
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, user.getUpdateTs());
}
 
Example 7
Source File: DatePickerDsTest.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnsubscribeSubscribeComponentListener() {
    DatePicker datePicker = uiComponents.create(DatePicker.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    datePicker.setDatasource(userDs, "updateTs");

    // unbind
    datePicker.setDatasource(null, null);

    // datasource before listener
    datePicker.setDatasource(userDs, "updateTs");
    assertEquals(updateTs, datePicker.getValue());

    boolean[] valueWasChanged = {false};
    Consumer<HasValue.ValueChangeEvent> listener = e -> valueWasChanged[0] = true;
    datePicker.addValueChangeListener(listener);

    Date updateTs2 = new Date();
    user.setUpdateTs(updateTs2);
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, datePicker.getValue());

    // reset state
    datePicker.removeValueChangeListener(listener);
    datePicker.setDatasource(null, null);
    valueWasChanged[0] = false;
    datePicker.setValue(updateTs);

    // listener before datasource

    datePicker.addValueChangeListener(listener);
    datePicker.setDatasource(userDs, "updateTs");
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, datePicker.getValue());
}
 
Example 8
Source File: DatePickerDsTest.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Test
public void testValueChangeListener() {
    DatePicker datePicker = uiComponents.create(DatePicker.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setUpdateTs(new Date());

    // listener before datasource
    Boolean[] valueWasChanged = {false};
    Consumer<HasValue.ValueChangeEvent> listener = e -> valueWasChanged[0] = true;
    datePicker.addValueChangeListener(listener);

    datePicker.setDatasource(userDs, "updateTs");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    datePicker.setDatasource(null, null);
    datePicker.removeValueChangeListener(listener);
    valueWasChanged[0] = false;

    // datasource before listener
    datePicker.setDatasource(userDs, "updateTs");
    datePicker.addValueChangeListener(listener);

    user.setUpdateTs(new Date());
    assertEquals(true, valueWasChanged[0]);
}
 
Example 9
Source File: DateFieldDsTest.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Test
public void testValueChangeListener() {
    DateField dateField = uiComponents.create(DateField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setUpdateTs(new Date());

    // listener before datasource
    Boolean[] valueWasChanged = {false};
    Consumer<HasValue.ValueChangeEvent> listener = e -> valueWasChanged[0] = true;
    dateField.addValueChangeListener(listener);

    dateField.setDatasource(userDs, "updateTs");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    dateField.setDatasource(null, null);
    dateField.removeValueChangeListener(listener);
    valueWasChanged[0] = false;

    // datasource before listener
    dateField.setDatasource(userDs, "updateTs");
    dateField.addValueChangeListener(listener);

    user.setUpdateTs(new Date());
    assertEquals(true, valueWasChanged[0]);
}
 
Example 10
Source File: DateFieldDsTest.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Test
public void testUnsubscribeSubscribeComponentListener() {
    DateField dateField = uiComponents.create(DateField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    dateField.setDatasource(userDs, "updateTs");

    // unbind
    dateField.setDatasource(null, null);

    // datasource before listener
    dateField.setDatasource(userDs, "updateTs");
    dateField.setResolution(DateField.Resolution.SEC);
    assertEquals(updateTs, dateField.getValue());

    boolean[] valueWasChanged = {false};
    Consumer<HasValue.ValueChangeEvent> listener = e -> valueWasChanged[0] = true;
    dateField.addValueChangeListener(listener);

    Date updateTs2 = new Date();
    user.setUpdateTs(updateTs2);
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, dateField.getValue());

    // reset state
    dateField.removeValueChangeListener(listener);
    dateField.setDatasource(null, null);
    valueWasChanged[0] = false;
    dateField.setValue(updateTs);

    // listener before datasource

    dateField.addValueChangeListener(listener);
    dateField.setDatasource(userDs, "updateTs");
    dateField.setResolution(DateField.Resolution.SEC);
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, dateField.getValue());
}