Search in sources :

Example 1 with EnumDropdownServiceImpl

use of org.kie.workbench.common.services.backend.enums.EnumDropdownServiceImpl in project drools-wb by kiegroup.

the class EnumDropDownServiceTest method testLoadDropDown.

@Test
public void testLoadDropDown() throws Exception {
    // Override code that converts Path to ClassLoader for test
    final ClassLoader cl = Thread.currentThread().getContextClassLoader();
    final EnumDropdownService service = new EnumDropdownServiceImpl() {

        @Override
        public String[] loadDropDownExpression(final Path resource, final String[] valuePairs, final String expression) {
            return super.loadDropDownExpression(cl, new RawMVELEvaluator(), valuePairs, expression);
        }
    };
    final String[] pairs = new String[] { "f1=x", "f2=2" };
    final String expression = "['@{f1}', '@{f2}']";
    final String[] r = service.loadDropDownExpression(mock(Path.class), pairs, expression);
    assertEquals(2, r.length);
    assertEquals("x", r[0]);
    assertEquals("2", r[1]);
}
Also used : Path(org.uberfire.backend.vfs.Path) EnumDropdownServiceImpl(org.kie.workbench.common.services.backend.enums.EnumDropdownServiceImpl) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) EnumDropdownService(org.kie.workbench.common.services.shared.enums.EnumDropdownService) Test(org.junit.Test)

Example 2 with EnumDropdownServiceImpl

use of org.kie.workbench.common.services.backend.enums.EnumDropdownServiceImpl in project drools-wb by kiegroup.

the class EnumDropDownServiceTest method testLoadDropDownNoValuePairs.

@Test
public void testLoadDropDownNoValuePairs() throws Exception {
    // Override code that converts Path to ClassLoader for test
    final ClassLoader cl = Thread.currentThread().getContextClassLoader();
    final EnumDropdownService service = new EnumDropdownServiceImpl() {

        @Override
        public String[] loadDropDownExpression(final Path resource, final String[] valuePairs, final String expression) {
            return super.loadDropDownExpression(cl, new RawMVELEvaluator(), valuePairs, expression);
        }
    };
    final String[] pairs = new String[] { null };
    final String expression = "['@{f1}', '@{f2}']";
    final String[] r = service.loadDropDownExpression(mock(Path.class), pairs, expression);
    assertEquals(0, r.length);
}
Also used : Path(org.uberfire.backend.vfs.Path) EnumDropdownServiceImpl(org.kie.workbench.common.services.backend.enums.EnumDropdownServiceImpl) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) EnumDropdownService(org.kie.workbench.common.services.shared.enums.EnumDropdownService) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)2 EnumDropdownServiceImpl (org.kie.workbench.common.services.backend.enums.EnumDropdownServiceImpl)2 EnumDropdownService (org.kie.workbench.common.services.shared.enums.EnumDropdownService)2 Path (org.uberfire.backend.vfs.Path)2