Search in sources :

Example 1 with TestEnum

use of org.linkki.core.binding.TestEnum in project linkki by linkki-framework.

the class UIComboBoxIntegrationTest method testNullSelection.

@Test
public void testNullSelection() {
    assertThat(getStaticComponent().isNullSelectionAllowed(), is(false));
    List<TestEnum> availableValues = new ArrayList<>(getDefaultPmo().getValueAvailableValues());
    ComboBox comboBox = getDynamicComponent();
    assertThat(availableValues.contains(null), is(false));
    assertThat(comboBox.isNullSelectionAllowed(), is(false));
    availableValues.add(null);
    assertThat(availableValues.contains(null), is(true));
    getDefaultPmo().setValueAvailableValues(availableValues);
    updateUi();
    assertThat(comboBox.getItemIds(), contains(TestEnum.ONE, TestEnum.TWO, TestEnum.THREE, comboBox.getNullSelectionItemId()));
}
Also used : LinkkiComboBox(org.linkki.core.ui.components.LinkkiComboBox) ComboBox(com.vaadin.ui.ComboBox) ArrayList(java.util.ArrayList) TestEnum(org.linkki.core.binding.TestEnum) Test(org.junit.Test)

Example 2 with TestEnum

use of org.linkki.core.binding.TestEnum in project linkki by linkki-framework.

the class UISubsetChooserTest method testAddObjectToRightLineAndRemoveItAgain.

@Test
public void testAddObjectToRightLineAndRemoveItAgain() {
    SubsetChooser subsetChooser = createSubsetChooser(new TestPmo());
    Map<String, Object> variables = new HashMap<>();
    variables.put("selected", new String[] { "1" });
    subsetChooser.changeVariables(null, variables);
    @SuppressWarnings("unchecked") Set<TestEnum> selectedValuesResult = (Set<TestEnum>) subsetChooser.getValue();
    assertThat(selectedValuesResult, containsInAnyOrder(TestEnum.ONE));
    variables.put("selected", new String[] {});
    subsetChooser.changeVariables(null, variables);
    @SuppressWarnings("unchecked") Set<TestEnum> selectedValuesResultEmpty = (Set<TestEnum>) subsetChooser.getValue();
    assertThat(selectedValuesResultEmpty, empty());
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) TestEnum(org.linkki.core.binding.TestEnum) SubsetChooser(org.linkki.core.ui.components.SubsetChooser) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 TestEnum (org.linkki.core.binding.TestEnum)2 ComboBox (com.vaadin.ui.ComboBox)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 LinkkiComboBox (org.linkki.core.ui.components.LinkkiComboBox)1 SubsetChooser (org.linkki.core.ui.components.SubsetChooser)1