Search in sources :

Example 1 with SelectOption

use of org.uberfire.ext.widgets.common.client.select.SelectOption in project kie-wb-common by kiegroup.

the class CategoryUtils method createCategories.

/**
 * Create a list of SelectOptions  with all the categories and the ALL Option, to be used
 * in {@link SelectComponent}
 * @return the list of SelectOptions
 */
public List<SelectOption> createCategories() {
    List<SelectOption> options = new ArrayList<>();
    options.add(new SelectOptionImpl("ALL", ts.getTranslation(LibraryConstants.ALL)));
    options.addAll(categoriesManagerCache.getCategories().stream().map(category -> new SelectOptionImpl(category.getName(), ts.getTranslation(category.getName()))).collect(Collectors.toList()));
    return options;
}
Also used : SelectOption(org.uberfire.ext.widgets.common.client.select.SelectOption) ArrayList(java.util.ArrayList) SelectOptionImpl(org.uberfire.ext.widgets.common.client.select.SelectOptionImpl)

Example 2 with SelectOption

use of org.uberfire.ext.widgets.common.client.select.SelectOption in project kie-wb-common by kiegroup.

the class CategoryUtilsTest method testCreateCategories.

@Test
public void testCreateCategories() {
    when(this.categoriesManagerCache.getCategories()).thenReturn(new HashSet<>(Arrays.asList(new Others(), new Decision())));
    List<SelectOption> categories = this.categoryUtils.createCategories();
    assertEquals(3, categories.size());
    assertTrue(categories.stream().anyMatch(selectOption -> selectOption.getSelector().equals("ALL")));
    assertTrue(categories.stream().anyMatch(selectOption -> selectOption.getSelector().equals(new Others().getName())));
    assertTrue(categories.stream().anyMatch(selectOption -> selectOption.getSelector().equals(new Decision().getName())));
}
Also used : Arrays(java.util.Arrays) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) SelectOptionImpl(org.uberfire.ext.widgets.common.client.select.SelectOptionImpl) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) SelectOption(org.uberfire.ext.widgets.common.client.select.SelectOption) HashSet(java.util.HashSet) Mockito(org.mockito.Mockito) List(java.util.List) CategoriesManagerCache(org.uberfire.client.mvp.CategoriesManagerCache) Others(org.uberfire.workbench.category.Others) Decision(org.guvnor.common.services.project.categories.Decision) Assert(org.junit.Assert) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Before(org.junit.Before) Others(org.uberfire.workbench.category.Others) SelectOption(org.uberfire.ext.widgets.common.client.select.SelectOption) Decision(org.guvnor.common.services.project.categories.Decision) Test(org.junit.Test)

Aggregations

SelectOption (org.uberfire.ext.widgets.common.client.select.SelectOption)2 SelectOptionImpl (org.uberfire.ext.widgets.common.client.select.SelectOptionImpl)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Decision (org.guvnor.common.services.project.categories.Decision)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 Mock (org.mockito.Mock)1 Mockito (org.mockito.Mockito)1 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)1 CategoriesManagerCache (org.uberfire.client.mvp.CategoriesManagerCache)1 Others (org.uberfire.workbench.category.Others)1