Search in sources :

Example 1 with Purchase

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

the class PackageDataModelParametricTypesTest method testParametricMethod.

@Test
public void testParametricMethod() throws Exception {
    final ModuleDataModelOracle moduleLoader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addClass(Purchase.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);
    assertNotNull(oracle);
    assertEquals("Product", oracle.getParametricFieldType("Purchase", "customerPurchased(Integer)"));
}
Also used : Path(org.uberfire.backend.vfs.Path) Purchase(org.kie.workbench.common.widgets.client.datamodel.testclasses.Purchase) IncrementalDataModelService(org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) 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 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 Purchase (org.kie.workbench.common.widgets.client.datamodel.testclasses.Purchase)1 Path (org.uberfire.backend.vfs.Path)1