Search in sources :

Example 1 with TestJavaEnum1

use of org.kie.workbench.common.widgets.client.datamodel.testclasses.TestJavaEnum1 in project kie-wb-common by kiegroup.

the class PackageDataModelOracleEnumTest method testJavaEnum1.

@Test
public void testJavaEnum1() throws IOException {
    final ModuleDataModelOracle projectLoader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addClass(TestJavaEnum1.class).build();
    final PackageDataModelOracle packageLoader = PackageDataModelOracleBuilder.newPackageOracleBuilder(new RawMVELEvaluator(), "org.kie.workbench.common.widgets.client.datamodel.testclasses").setModuleOracle(projectLoader).build();
    // Emulate server-to-client conversions
    final Caller<IncrementalDataModelService> service = new MockIncrementalDataModelServiceCaller(packageLoader);
    final AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(service, validatorInstance);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    dataModel.setPackageName(packageLoader.getPackageName());
    dataModel.setModelFields(packageLoader.getModuleModelFields());
    dataModel.setJavaEnumDefinitions(packageLoader.getModuleJavaEnumDefinitions());
    dataModel.setWorkbenchEnumDefinitions(packageLoader.getPackageWorkbenchDefinitions());
    PackageDataModelOracleTestUtils.populateDataModelOracle(mock(Path.class), new MockHasImports(), oracle, dataModel);
    assertEquals(2, oracle.getFactTypes().length);
    assertEquals("TestJavaEnum1.TestEnum", oracle.getFactTypes()[1]);
    final DropDownData dd = oracle.getEnums(TestJavaEnum1.class.getSimpleName(), "field1");
    assertNotNull(dd);
    assertEquals(3, dd.getFixedList().length);
    assertEquals("TestJavaEnum1.TestEnum.ZERO=TestJavaEnum1.TestEnum.ZERO", dd.getFixedList()[0]);
    assertEquals("TestJavaEnum1.TestEnum.ONE=TestJavaEnum1.TestEnum.ONE", dd.getFixedList()[1]);
    assertEquals("TestJavaEnum1.TestEnum.TWO=TestJavaEnum1.TestEnum.TWO", dd.getFixedList()[2]);
    final String[] ddValues = oracle.getEnumValues(TestJavaEnum1.class.getSimpleName(), "field1");
    assertNotNull(ddValues);
    assertEquals(3, ddValues.length);
    assertEquals("TestJavaEnum1.TestEnum.ZERO=TestJavaEnum1.TestEnum.ZERO", ddValues[0]);
    assertEquals("TestJavaEnum1.TestEnum.ONE=TestJavaEnum1.TestEnum.ONE", ddValues[1]);
    assertEquals("TestJavaEnum1.TestEnum.TWO=TestJavaEnum1.TestEnum.TWO", ddValues[2]);
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalDataModelService(org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) TestJavaEnum1(org.kie.workbench.common.widgets.client.datamodel.testclasses.TestJavaEnum1) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)1 DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)1 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)1 IncrementalDataModelService (org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService)1 TestJavaEnum1 (org.kie.workbench.common.widgets.client.datamodel.testclasses.TestJavaEnum1)1 Path (org.uberfire.backend.vfs.Path)1