use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class IndexGuidedScoreCardTest method testIndexGuidedScoreCard.
@Test
public void testIndexGuidedScoreCard() throws IOException, InterruptedException {
// Add test files
final Path path1 = basePath.resolve("scorecard1.scgd");
final ScoreCardModel model1 = GuidedScoreCardFactory.makeScoreCardWithCharacteristics("org.drools.workbench.screens.guided.scorecard.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage"));
}
}, "scorecard1");
final String xml1 = GuidedScoreCardXMLPersistence.getInstance().marshal(model1);
ioService().write(path1, xml1);
final Path path2 = basePath.resolve("scorecard2.scgd");
final ScoreCardModel model2 = GuidedScoreCardFactory.makeScoreCardWithoutCharacteristics("org.drools.workbench.screens.guided.scorecard.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage"));
}
}, "scorecard2");
final String xml2 = GuidedScoreCardXMLPersistence.getInstance().marshal(model2);
ioService().write(path2, xml2);
final Path path3 = basePath.resolve("scorecard3.scgd");
final ScoreCardModel model3 = GuidedScoreCardFactory.makeEmptyScoreCard("org.drools.workbench.screens.guided.scorecard.backend.server.indexing", "scorecard3");
final String xml3 = GuidedScoreCardXMLPersistence.getInstance().marshal(model3);
ioService().write(path3, xml3);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
// Score Cards using org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 2, path1, path2);
}
// Score Cards referring to org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
searchFor(index, query, 2, path1);
}
// Score Cards using org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage#amount
{
final Query query = new SingleTermQueryBuilder(new ValuePartReferenceIndexTerm("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage", "amount", PartType.FIELD)).build();
searchFor(index, query, 1, path1);
}
// Score Cards using java.lang.Integer
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("java.lang.Integer", ResourceType.JAVA)).build();
searchFor(index, query, 2, path1, path2);
}
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidgetTest method setUp.
@Before
public void setUp() throws Exception {
// listBox is used for verification fo added available fact types into UI
GwtMockito.useProviderForType(ListBox.class, aClass -> listBox);
// Mock partially the AsyncPackageDataModelOracle
validatorInstance = new MockInstanceImpl<>();
oracle = spy(new AsyncPackageDataModelOracleImpl(new CallerMock<>(incrementalDataModelService), validatorInstance));
// Mock partially the AsyncPackageDataModelOracleFactory and ensure oracle will contain data form payload below
doReturn(syncBeanDef).when(syncBeanManager).lookupBean(AsyncPackageDataModelOracle.class);
doReturn(oracle).when(syncBeanDef).getInstance();
doReturn(oracle).when(ruleModeller).getDataModelOracle();
// Prepare base payload that simulates two Facts in the package, Person and Car
dataModelPayload = new PackageDataModelOracleBaselinePayload();
dataModelPayload.setModelFields(new HashMap<String, ModelField[]>() {
{
final String fqnPerson = REDHAT_PACKAGE + "." + FACT_TYPE_PERSON;
final String fqnCar = REDHAT_PACKAGE + "." + FACT_TYPE_CAR;
final String fqnNumber = Number.class.getName();
put(fqnPerson, new ModelField[] { modelField(DataType.TYPE_THIS, fqnPerson) });
put(fqnCar, new ModelField[] { modelField(DataType.TYPE_THIS, fqnCar) });
put(fqnNumber, new ModelField[] { modelField(DataType.TYPE_THIS, fqnNumber) });
}
});
// Prevent NPE in FromAccumulateCompositeFactPatternWidget constructor
when(pattern.useFunctionOrCode()).thenReturn(FromAccumulateCompositeFactPattern.USE_FUNCTION);
fromAccumulateWidget = new FromAccumulateCompositeFactPatternWidget(ruleModeller, eventBus, pattern);
ruleModelWithImportedNumber = new RuleModel() {
{
setImports(new Imports() {
{
addImport(new Import(Number.class));
}
});
}
};
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class DecisionTableAnalyzerConflictResolverLimitedDTableTest method testConflict.
@Test
public void testConflict() throws Exception {
table52 = new LimitedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withIntegerColumn("a", "Person", "age", "==", 0).withAction("a", "approved", DataType.TYPE_BOOLEAN, new DTCellValue52() {
{
setBooleanValue(true);
}
}).withAction("a", "approved", DataType.TYPE_BOOLEAN, new DTCellValue52() {
{
setBooleanValue(false);
}
}).withData(new Object[][] { { 1, "", "description", true, true, false }, { 2, "", "description", true, false, true } }).buildTable();
fireUpAnalyzer();
assertContains(analyzerProvider.getAnalysisReport(), CheckType.CONFLICTING_ROWS, Severity.WARNING, 2);
assertContains(analyzerProvider.getAnalysisReport(), CheckType.CONFLICTING_ROWS, Severity.WARNING, 1);
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class DecisionTableAnalyzerSubsumptionResolverTest method testNoIssues2.
@Test
public void testNoIssues2() throws Exception {
GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("application", "LoanApplication", "amount", ">").withConditionIntegerColumn("application", "LoanApplication", "amount", "<=").withConditionIntegerColumn("application", "LoanApplication", "lengthYears", "==").withConditionIntegerColumn("application", "LoanApplication", "deposit", "<").withStringColumn("income", "IncomeSource", "type", "==").withActionSetField("application", "approved", DataType.TYPE_BOOLEAN).withActionSetField("application", "insuranceCost", DataType.TYPE_NUMERIC_INTEGER).withActionSetField("application", "approvedRate", DataType.TYPE_NUMERIC_INTEGER).withData(new Object[][] { { 1, "", "description", 131000, 200000, 30, 20000, "Asset", true, 0, 2 }, { 2, "", "description", 1000, 200000, 30, 20000, "Asset", true, 0, 2 }, { 3, "", "description", 100001, 130000, 20, 3000, "Job", true, 10, 6 } }).buildTable();
Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
analyzer.resetChecks();
analyzer.analyze();
assertDoesNotContain(CheckType.REDUNDANT_ROWS, analyzerProvider.getAnalysisReport());
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class DecisionTableAnalyzerSubsumptionResolverTest method testRedundantRows001.
@Test
@Ignore("This randomly does not pick up the issue. Better that way, I'm hoping future changes will find the cause. Every other test works 100%")
public void testRedundantRows001() throws Exception {
GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withNumericColumn("application", "LoanApplication", "amount", ">").withNumericColumn("application", "LoanApplication", "amount", "<=").withNumericColumn("application", "LoanApplication", "lengthYears", "==").withNumericColumn("application", "LoanApplication", "deposit", "<").withStringColumn("income", "IncomeSource", "type", "==").withActionSetField("application", "approved", DataType.TYPE_BOOLEAN).withActionSetField("application", "insuranceCost", DataType.TYPE_NUMERIC).withActionSetField("application", "approvedRate", DataType.TYPE_NUMERIC).withData(new Object[][] { { 1, "", "description", 131000, 200000, 30, 20000, "Asset", true, 0, 2 }, { 2, "", "description", 131000, 200000, 30, 20000, "Asset", true, 0, 2 }, { 3, "", "description", 100001, 130000, 20, 3000, "Job", true, 10, 6 } }).buildTable();
Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
analyzer.resetChecks();
analyzer.analyze();
assertContains(analyzerProvider.getAnalysisReport(), CheckType.REDUNDANT_ROWS, Severity.WARNING, 1, 2);
}
Aggregations