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;
}
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())));
}
Aggregations