Search in sources :

Example 1 with TestDataTypes

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

the class PackageDataModelOracleTest method testDataTypes.

@Test
public void testDataTypes() throws IOException {
    final ModuleDataModelOracle moduleLoader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addClass(TestDataTypes.class).build();
    final PackageDataModelOracle packageLoader = PackageDataModelOracleBuilder.newPackageOracleBuilder(new RawMVELEvaluator(), "org.kie.workbench.common.widgets.client.datamodel.testclasses").setModuleOracle(moduleLoader).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.setFieldParametersType(packageLoader.getModuleFieldParametersType());
    PackageDataModelOracleTestUtils.populateDataModelOracle(mock(Path.class), new MockHasImports(), oracle, dataModel);
    assertEquals(1, oracle.getFactTypes().length);
    assertEquals(TestDataTypes.class.getSimpleName(), oracle.getFactTypes()[0]);
    oracle.getFieldCompletions(TestDataTypes.class.getSimpleName(), new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            assertEquals(20, fields.length);
        }
    });
    assertEquals(DataType.TYPE_THIS, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "this"));
    assertEquals(DataType.TYPE_STRING, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldString"));
    assertEquals(DataType.TYPE_BOOLEAN, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldBooleanObject"));
    assertEquals(DataType.TYPE_DATE, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldDate"));
    assertEquals(DataType.TYPE_NUMERIC_BIGDECIMAL, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldNumeric"));
    assertEquals(DataType.TYPE_NUMERIC_BIGDECIMAL, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldBigDecimal"));
    assertEquals(DataType.TYPE_NUMERIC_BIGINTEGER, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldBigInteger"));
    assertEquals(DataType.TYPE_NUMERIC_BYTE, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldByteObject"));
    assertEquals(DataType.TYPE_NUMERIC_DOUBLE, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldDoubleObject"));
    assertEquals(DataType.TYPE_NUMERIC_FLOAT, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldFloatObject"));
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldIntegerObject"));
    assertEquals(DataType.TYPE_NUMERIC_LONG, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldLongObject"));
    assertEquals(DataType.TYPE_NUMERIC_SHORT, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldShortObject"));
    assertEquals(DataType.TYPE_BOOLEAN, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldBooleanPrimitive"));
    assertEquals(DataType.TYPE_NUMERIC_BYTE, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldBytePrimitive"));
    assertEquals(DataType.TYPE_NUMERIC_DOUBLE, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldDoublePrimitive"));
    assertEquals(DataType.TYPE_NUMERIC_FLOAT, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldFloatPrimitive"));
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldIntegerPrimitive"));
    assertEquals(DataType.TYPE_NUMERIC_LONG, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldLongPrimitive"));
    assertEquals(DataType.TYPE_NUMERIC_SHORT, oracle.getFieldType(TestDataTypes.class.getSimpleName(), "fieldShortPrimitive"));
}
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) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) TestDataTypes(org.kie.workbench.common.widgets.client.datamodel.testclasses.TestDataTypes) 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 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)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 TestDataTypes (org.kie.workbench.common.widgets.client.datamodel.testclasses.TestDataTypes)1 Path (org.uberfire.backend.vfs.Path)1