Search in sources :

Example 6 with OptionsList

use of com.haulmont.cuba.gui.components.OptionsList in project cuba by cuba-platform.

the class OptionsListDsTest method testUnsubscribeSubscribeDsListener.

@Test
public void testUnsubscribeSubscribeDsListener() {
    OptionsList optionsList = (OptionsList) factory.createComponent(OptionsList.NAME);
    Datasource<Role> roleDs = getTestRoleDatasource();
    roleDs.getItem().setType(RoleType.DENYING);
    optionsList.setDatasource(roleDs, "type");
    optionsList.setDatasource(null, null);
    boolean[] valueWasChanged = { false };
    Datasource.ItemPropertyChangeListener<Role> listener = e -> valueWasChanged[0] = true;
    roleDs.addItemPropertyChangeListener(listener);
    optionsList.setDatasource(roleDs, "type");
    optionsList.setValue(RoleType.STANDARD);
    assertTrue(valueWasChanged[0]);
}
Also used : Role(com.haulmont.cuba.security.entity.Role) Datasource(com.haulmont.cuba.gui.data.Datasource) Datasource(com.haulmont.cuba.gui.data.Datasource) OptionsList(com.haulmont.cuba.gui.components.OptionsList) Ignore(org.junit.Ignore) Role(com.haulmont.cuba.security.entity.Role) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Assert(org.junit.Assert) Component(com.haulmont.cuba.gui.components.Component) RoleType(com.haulmont.cuba.security.entity.RoleType) TestCase.assertEquals(junit.framework.TestCase.assertEquals) OptionsList(com.haulmont.cuba.gui.components.OptionsList) Test(org.junit.Test)

Aggregations

OptionsList (com.haulmont.cuba.gui.components.OptionsList)6 Role (com.haulmont.cuba.security.entity.Role)6 Test (org.junit.Test)6 Component (com.haulmont.cuba.gui.components.Component)5 Datasource (com.haulmont.cuba.gui.data.Datasource)5 RoleType (com.haulmont.cuba.security.entity.RoleType)5 TestCase.assertEquals (junit.framework.TestCase.assertEquals)5 Assert (org.junit.Assert)5 Assert.assertTrue (org.junit.Assert.assertTrue)5 Ignore (org.junit.Ignore)5