Search in sources :

Example 26 with PackageDataModelOracleBaselinePayload

use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload in project drools-wb by kiegroup.

the class RuleModellerConditionSelectorPopupTest method testLoadDslConditionsPresentButDslDisabled.

@Test
public void testLoadDslConditionsPresentButDslDisabled() throws Exception {
    // DSL sentences disabled
    doReturn(false).when(ruleModeller).isDSLEnabled();
    // DSL Conditions present
    dataModel = PackageDataModelOracleBuilder.newPackageOracleBuilder(new RawMVELEvaluator()).addExtension(DSLConditionSentence.INSTANCE, Collections.singletonList(dslSentence)).build();
    dataModelPayload = new PackageDataModelOracleBaselinePayload();
    dataModelPayload.setAllPackageElements(dataModel.getAllExtensions());
    asyncPackageDataModelOracleFactory.makeAsyncPackageDataModelOracle(resourcePath, dataModelPayload);
    new RuleModellerConditionSelectorPopup(model, ruleModeller, 0, oracle);
    verify(choices, atLeastOnce()).addItem(keyCaptor.capture(), valueCaptor.capture());
    verify(choices).setMultipleSelect(true);
    Assertions.assertThat(keyCaptor.getAllValues()).doesNotContain(DSL_SENTENCE_CHOICE_KEY);
    Assertions.assertThat(valueCaptor.getAllValues()).doesNotContain(DSL_SENTENCE_CHOICE_VALUE);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) Test(org.junit.Test)

Example 27 with PackageDataModelOracleBaselinePayload

use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload in project drools-wb by kiegroup.

the class GuidedScoreCardEditorPresenter method getModelSuccessCallback.

private RemoteCallback<ScoreCardModelContent> getModelSuccessCallback() {
    return new RemoteCallback<ScoreCardModelContent>() {

        @Override
        public void callback(final ScoreCardModelContent content) {
            // Path is set to null when the Editor is closed (which can happen before async calls complete).
            if (versionRecordManager.getCurrentPath() == null) {
                return;
            }
            model = content.getModel();
            final PackageDataModelOracleBaselinePayload dataModel = content.getDataModel();
            oracle = oracleFactory.makeAsyncPackageDataModelOracle(versionRecordManager.getCurrentPath(), model, dataModel);
            resetEditorPages(content.getOverview());
            addSourcePage();
            addImportsTab(importsWidget);
            view.setContent(model, oracle);
            importsWidget.setContent(oracle, model.getImports(), isReadOnly);
            createOriginalHash(model);
            view.hideBusyIndicator();
        }
    };
}
Also used : ScoreCardModelContent(org.drools.workbench.screens.guided.scorecard.model.ScoreCardModelContent) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 28 with PackageDataModelOracleBaselinePayload

use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload in project kie-wb-common by kiegroup.

the class PackageDataModelDeclaredTypesTest method testPackageDeclaredTypes.

@Test
public void testPackageDeclaredTypes() throws Exception {
    final Bean dataModelServiceBean = (Bean) beanManager.getBeans(DataModelService.class).iterator().next();
    final CreationalContext cc = beanManager.createCreationalContext(dataModelServiceBean);
    final DataModelService dataModelService = (DataModelService) beanManager.getReference(dataModelServiceBean, DataModelService.class, cc);
    final URL packageUrl = this.getClass().getResource("/DataModelBackendDeclaredTypesTest1/src/main/java/t1p1");
    final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(packageUrl.toURI());
    final Path packagePath = paths.convert(nioPackagePath);
    final PackageDataModelOracle packageLoader = dataModelService.getDataModel(packagePath);
    // 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("t1p1");
    dataModel.setModelFields(packageLoader.getModuleModelFields());
    dataModel.setTypeSources(new HashMap<String, TypeSource>() {

        {
            put("t1p1.Bean1", TypeSource.JAVA_PROJECT);
            put("t1p1.DRLBean", TypeSource.DECLARED);
            put("t1p2.Bean2", TypeSource.JAVA_PROJECT);
            put("java.lang.String", TypeSource.JAVA_PROJECT);
            put("int", TypeSource.JAVA_PROJECT);
        }
    });
    PackageDataModelOracleTestUtils.populateDataModelOracle(mock(Path.class), new MockHasImports(), oracle, dataModel);
    assertNotNull(dataModel);
    assertEquals(2, oracle.getFactTypes().length);
    PackageDataModelOracleTestUtils.assertContains("Bean1", oracle.getFactTypes());
    PackageDataModelOracleTestUtils.assertContains("DRLBean", oracle.getFactTypes());
    assertEquals(2, oracle.getExternalFactTypes().length);
    PackageDataModelOracleTestUtils.assertContains("t1p2.Bean2", oracle.getExternalFactTypes());
    PackageDataModelOracleTestUtils.assertContains("java.lang.String", oracle.getExternalFactTypes());
    oracle.getTypeSource("Bean1", new Callback<TypeSource>() {

        @Override
        public void callback(final TypeSource result) {
            assertEquals(TypeSource.JAVA_PROJECT, result);
        }
    });
    oracle.getTypeSource("DRLBean", new Callback<TypeSource>() {

        @Override
        public void callback(final TypeSource result) {
            assertEquals(TypeSource.DECLARED, result);
        }
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalDataModelService(org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService) TypeSource(org.kie.soup.project.datamodel.oracle.TypeSource) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) CreationalContext(javax.enterprise.context.spi.CreationalContext) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) DataModelService(org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService) IncrementalDataModelService(org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService) Test(org.junit.Test)

Example 29 with PackageDataModelOracleBaselinePayload

use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload in project kie-wb-common by kiegroup.

the class PackageDataModelExtendJavaTypeTest method testPackageExtendJavaTypeWithImport.

@Test
public void testPackageExtendJavaTypeWithImport() throws Exception {
    final URL packageUrl = this.getClass().getResource("/DataModelBackendExtendJavaTypeTest2/src/main/java/t5p1");
    final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(packageUrl.toURI());
    final Path packagePath = paths.convert(nioPackagePath);
    final PackageDataModelOracle projectLoader = dataModelService.getDataModel(packagePath);
    // Emulate server-to-client conversions
    final Caller<IncrementalDataModelService> service = new MockIncrementalDataModelServiceCaller(projectLoader);
    final AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(service, validatorInstance);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    dataModel.setPackageName("t5p1");
    dataModel.setModelFields(projectLoader.getModuleModelFields());
    dataModel.setEventTypes(new HashMap<String, Boolean>() {

        {
            put("t5p1.Bean1", true);
        }
    });
    PackageDataModelOracleTestUtils.populateDataModelOracle(mock(Path.class), new MockHasImports(), oracle, dataModel);
    assertNotNull(oracle);
    assertEquals(1, oracle.getFactTypes().length);
    assertContains("Bean1", oracle.getFactTypes());
    oracle.isFactTypeAnEvent("Bean1", new Callback<Boolean>() {

        @Override
        public void callback(final Boolean result) {
            assertTrue(result);
        }
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalDataModelService(org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService) URL(java.net.URL) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Test(org.junit.Test)

Example 30 with PackageDataModelOracleBaselinePayload

use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload in project kie-wb-common by kiegroup.

the class PackageDataModelExtendJavaTypeTest method testModuleExtendJavaTypeWithQualifiedDRLBeanName.

@Test
public void testModuleExtendJavaTypeWithQualifiedDRLBeanName() throws Exception {
    final URL packageUrl = this.getClass().getResource("/DataModelBackendExtendJavaTypeTest1/src/main/java/t4p1");
    final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(packageUrl.toURI());
    final Path packagePath = paths.convert(nioPackagePath);
    final PackageDataModelOracle packageLoader = dataModelService.getDataModel(packagePath);
    final ModuleDataModelOracle projectLoader = dataModelService.getModuleDataModel(packagePath);
    // 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("t4p1");
    dataModel.setModelFields(projectLoader.getModuleModelFields());
    dataModel.setEventTypes(new HashMap<String, Boolean>() {

        {
            put("t4p1.Bean1", true);
        }
    });
    PackageDataModelOracleTestUtils.populateDataModelOracle(mock(Path.class), new MockHasImports(), oracle, dataModel);
    assertNotNull(oracle);
    assertEquals(1, oracle.getFactTypes().length);
    assertContains("Bean1", oracle.getFactTypes());
    oracle.isFactTypeAnEvent("Bean1", new Callback<Boolean>() {

        @Override
        public void callback(final Boolean result) {
            assertTrue(result);
        }
    });
}
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) URL(java.net.URL) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Test(org.junit.Test)

Aggregations

PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)103 Path (org.uberfire.backend.vfs.Path)88 Test (org.junit.Test)83 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)75 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)74 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)62 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)56 IncrementalDataModelService (org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService)55 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)32 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)29 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)26 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)25 ArrayList (java.util.ArrayList)24 List (java.util.List)23 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)19 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)14 Set (java.util.Set)13 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)12 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)12 ModuleDataModelOracleImpl (org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)12