Search in sources :

Example 6 with OptionsGroup

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

the class OptionsGroupDsTest method testUnsubscribeDsListener.

@Test
public void testUnsubscribeDsListener() {
    OptionsGroup optionsGroup = (OptionsGroup) factory.createComponent(OptionsGroup.NAME);
    Datasource<Role> roleDs = getTestRoleDatasource();
    optionsGroup.setDatasource(roleDs, "type");
    optionsGroup.setValue(RoleType.STANDARD);
    optionsGroup.setDatasource(null, null);
    Datasource.ItemPropertyChangeListener<Role> listener = e -> {
        throw new RuntimeException("");
    };
    roleDs.addItemPropertyChangeListener(listener);
    optionsGroup.setValue(RoleType.DENYING);
    assertEquals(RoleType.STANDARD, roleDs.getItem().getType());
}
Also used : Role(com.haulmont.cuba.security.entity.Role) Datasource(com.haulmont.cuba.gui.data.Datasource) OptionsGroup(com.haulmont.cuba.gui.components.OptionsGroup) Datasource(com.haulmont.cuba.gui.data.Datasource) Ignore(org.junit.Ignore) Role(com.haulmont.cuba.security.entity.Role) Test(org.junit.Test) Assert(org.junit.Assert) Component(com.haulmont.cuba.gui.components.Component) RoleType(com.haulmont.cuba.security.entity.RoleType) OptionsGroup(com.haulmont.cuba.gui.components.OptionsGroup) Test(org.junit.Test)

Example 7 with OptionsGroup

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

the class OptionsGroupDsTest method testSetValue.

@Test
public void testSetValue() {
    OptionsGroup optionsGroup = (OptionsGroup) factory.createComponent(OptionsGroup.NAME);
    Datasource<Role> roleDs = getTestRoleDatasource();
    optionsGroup.setDatasource(roleDs, "type");
    optionsGroup.setValue(RoleType.DENYING);
    assertNotNull(optionsGroup.getValue());
}
Also used : Role(com.haulmont.cuba.security.entity.Role) OptionsGroup(com.haulmont.cuba.gui.components.OptionsGroup) Test(org.junit.Test)

Aggregations

OptionsGroup (com.haulmont.cuba.gui.components.OptionsGroup)7 Role (com.haulmont.cuba.security.entity.Role)7 Test (org.junit.Test)7 Component (com.haulmont.cuba.gui.components.Component)5 Datasource (com.haulmont.cuba.gui.data.Datasource)5 RoleType (com.haulmont.cuba.security.entity.RoleType)5 Assert (org.junit.Assert)5 Ignore (org.junit.Ignore)5