Search in sources :

Example 1 with TestJavaEnum2

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

the class PackageDataModelOracleEnumTest method testJavaEnum2.

@Test
public void testJavaEnum2() throws IOException {
    final ModuleDataModelOracle projectLoader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addClass(TestJavaEnum2.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(TestJavaEnum2.class.getSimpleName(), oracle.getFactTypes()[1]);
    final DropDownData dd = oracle.getEnums(TestJavaEnum2.class.getSimpleName(), "field1");
    assertNotNull(dd);
    assertEquals(3, dd.getFixedList().length);
    assertEquals("TestExternalEnum.ZERO=TestExternalEnum.ZERO", dd.getFixedList()[0]);
    assertEquals("TestExternalEnum.ONE=TestExternalEnum.ONE", dd.getFixedList()[1]);
    assertEquals("TestExternalEnum.TWO=TestExternalEnum.TWO", dd.getFixedList()[2]);
    final String[] ddValues = oracle.getEnumValues(TestJavaEnum2.class.getSimpleName(), "field1");
    assertNotNull(ddValues);
    assertEquals(3, ddValues.length);
    assertEquals("TestExternalEnum.ZERO=TestExternalEnum.ZERO", ddValues[0]);
    assertEquals("TestExternalEnum.ONE=TestExternalEnum.ONE", ddValues[1]);
    assertEquals("TestExternalEnum.TWO=TestExternalEnum.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) TestJavaEnum2(org.kie.workbench.common.widgets.client.datamodel.testclasses.TestJavaEnum2) 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 TestJavaEnum2 (org.kie.workbench.common.widgets.client.datamodel.testclasses.TestJavaEnum2)1 Path (org.uberfire.backend.vfs.Path)1