use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class GuidedScoreCardIntegrationJavaClassesOnClassPathTest method testIncrementalCompilation.
@Test
public void testIncrementalCompilation() throws Exception {
String xml1_1 = Helper.createEmptyGuidedScoreCardXML();
String xml1_2 = Helper.createGuidedScoreCardXML();
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("pom.xml", Helper.getPom());
kfs.write("src/main/resources/META-INF/kmodule.xml", Helper.getKModule());
kfs.write("src/main/resources/sc1.scgd", xml1_1);
// Add empty Score Card
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
final List<Message> messages = kieBuilder.getResults().getMessages();
Helper.dumpMessages(messages);
assertEquals(0, messages.size());
// Update with complete Score Card
kfs.write("src/main/resources/sc1.scgd", xml1_2);
IncrementalResults results = ((InternalKieBuilder) kieBuilder).incrementalBuild();
final List<Message> addedMessages = results.getAddedMessages();
final List<Message> removedMessages = results.getRemovedMessages();
Helper.dumpMessages(addedMessages);
assertEquals(0, addedMessages.size());
Helper.dumpMessages(removedMessages);
assertEquals(0, removedMessages.size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class GuidedScoreCardIntegrationJavaClassesAddedToKieFileSystemTest method testIncrementalCompilation.
@Test
public void testIncrementalCompilation() throws Exception {
String xml1_1 = Helper.createEmptyGuidedScoreCardXML();
String xml1_2 = Helper.createGuidedScoreCardXML();
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("pom.xml", Helper.getPom());
kfs.write("src/main/resources/META-INF/kmodule.xml", Helper.getKModule());
kfs.write("src/main/java/org/drools/workbench/models/guided/scorecard/backend/test2/Applicant.java", Helper.getApplicant());
kfs.write("src/main/java/org/drools/workbench/models/guided/scorecard/backend/test2/ApplicantAttribute.java", Helper.getApplicantAttribute());
kfs.write("src/main/resources/org/drools/workbench/models/guided/scorecard/backend/test2/sc1.scgd", xml1_1);
// Add empty Score Card
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
final List<Message> messages = kieBuilder.getResults().getMessages();
Helper.dumpMessages(messages);
assertEquals(0, messages.size());
// Update with complete Score Card
kfs.write("src/main/resources/sc1.scgd", xml1_2);
IncrementalResults results = ((InternalKieBuilder) kieBuilder).incrementalBuild();
final List<Message> addedMessages = results.getAddedMessages();
final List<Message> removedMessages = results.getRemovedMessages();
Helper.dumpMessages(addedMessages);
assertEquals(0, addedMessages.size());
Helper.dumpMessages(removedMessages);
assertEquals(0, removedMessages.size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class KieBuilderSetImplTest method testBuild.
@Test
public void testBuild() throws Exception {
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("src/main/resources/rule%201.drl", ruleContent());
final KieBuilderSetImpl kieBuilderSet = new KieBuilderSetImpl(kieBuilder(ks, kfs));
kieBuilderSet.setFiles(new String[] { "src/main/resources/rule%201.drl" });
final IncrementalResults build = kieBuilderSet.build();
assertEquals(0, build.getAddedMessages().size());
assertEquals(0, build.getRemovedMessages().size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class MultipleModelTest method testIncrementalBuilding.
@Test
public void testIncrementalBuilding() throws Exception {
ReleaseId releaseId1 = KieServices.Factory.get().newReleaseId("org.test", "test", "1.0.0-SNAPSHOT");
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieBuilder kb = ks.newKieBuilder(kfs);
kfs.generateAndWritePomXML(releaseId1);
kfs.write(ResourceFactory.newClassPathResource(source1).setResourceType(ResourceType.PMML));
kb.buildAll();
KieContainer kc = ks.newKieContainer(releaseId1);
KieSession kSession = kc.newKieSession();
setKbase(kSession.getKieBase());
kSession.fireAllRules();
kfs.write(ResourceFactory.newClassPathResource(source2).setResourceType(ResourceType.PMML));
IncrementalResults results = ((InternalKieBuilder) kb).incrementalBuild();
kc.updateToVersion(releaseId1);
kSession.fireAllRules();
assertEquals(2, kSession.getObjects(new ClassObjectFilter(ModelMarker.class)).size());
assertEquals(11, kSession.getObjects(new ClassObjectFilter(kSession.getKieBase().getFactType(packageName, "Synapse").getFactClass())).size());
kSession.dispose();
checkGeneratedRules();
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class GuidedDTableParsingIntegrationTest method testGuidedDTableWithNoDSLIncrementalCompilation.
@Test
public void testGuidedDTableWithNoDSLIncrementalCompilation() {
// DROOLS-1544
String typeDrl = "package org.drools.test\n" + "declare LoanApplication\n" + " amount : int\n" + "end";
String brokenDrlGenerated = "<decision-table52>\n" + " <tableName>Pricing loans</tableName>\n" + " <rowNumberCol>\n" + " <hideColumn>false</hideColumn>\n" + " <width>-1</width>\n" + " </rowNumberCol>\n" + " <descriptionCol>\n" + " <hideColumn>false</hideColumn>\n" + " <width>-1</width>\n" + " </descriptionCol>\n" + " <metadataCols/>\n" + " <attributeCols/>\n" + " <conditionPatterns>\n" + " <Pattern52>\n" + " <factType>org.drools.test.LoanApplication</factType>\n" + " <boundName>application</boundName>\n" + " <isNegated>false</isNegated>\n" + " <conditions>\n" + " <condition-column52>\n" + " <typedDefaultValue>\n" + " <valueString></valueString>\n" + " <dataType>STRING</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </typedDefaultValue>\n" + " <hideColumn>false</hideColumn>\n" + " <width>-1</width>\n" + " <header>aa</header>\n" + " <constraintValueType>1</constraintValueType>\n" + " <factField>amount</factField>\n" + " <fieldType>Integer</fieldType>\n" + " <operator>==</operator>\n" + " <valueList>a,b</valueList>\n" + " <parameters/>\n" + " </condition-column52>\n" + " </conditions>\n" + " <window>\n" + " <parameters/>\n" + " </window>\n" + " <entryPointName></entryPointName>\n" + " </Pattern52>\n" + " </conditionPatterns>\n" + " <actionCols/>\n" + " <auditLog>\n" + " <filter class=\"org.drools.guvnor.client.modeldriven.dt52.auditlog.DecisionTableAuditLogFilter\">\n" + " <acceptedTypes>\n" + " <entry>\n" + " <string>INSERT_ROW</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>INSERT_COLUMN</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>DELETE_ROW</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>DELETE_COLUMN</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>UPDATE_COLUMN</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " </acceptedTypes>\n" + " </filter>\n" + " <entries/>\n" + " </auditLog>\n" + " <imports>\n" + " <imports/>\n" + " </imports>\n" + " <packageName>mortgages.mortgages</packageName>\n" + " <tableFormat>EXTENDED_ENTRY</tableFormat>\n" + " <hitPolicy>NONE</hitPolicy>\n" + " <data>\n" + " <list>\n" + " <value>\n" + " <valueNumeric class=\"int\">1</valueNumeric>\n" + " <valueString></valueString>\n" + " <dataType>NUMERIC_INTEGER</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </value>\n" + " <value>\n" + " <valueString></valueString>\n" + " <dataType>STRING</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </value>\n" + " <value>\n" + " <valueString>a</valueString>\n" + " <dataType>STRING</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </value>\n" + " </list>\n" + " </data>\n" + "</decision-table52>";
String correctDrlGenerated = "<decision-table52>\n" + " <tableName>Pricing loans</tableName>\n" + " <rowNumberCol>\n" + " <hideColumn>false</hideColumn>\n" + " <width>-1</width>\n" + " </rowNumberCol>\n" + " <descriptionCol>\n" + " <hideColumn>false</hideColumn>\n" + " <width>-1</width>\n" + " </descriptionCol>\n" + " <metadataCols/>\n" + " <attributeCols/>\n" + " <conditionPatterns>\n" + " <Pattern52>\n" + " <factType>org.drools.test.LoanApplication</factType>\n" + " <boundName>application</boundName>\n" + " <isNegated>false</isNegated>\n" + " <conditions>\n" + " <condition-column52>\n" + " <typedDefaultValue>\n" + " <valueString></valueString>\n" + " <dataType>STRING</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </typedDefaultValue>\n" + " <hideColumn>false</hideColumn>\n" + " <width>-1</width>\n" + " <header>aa</header>\n" + " <constraintValueType>1</constraintValueType>\n" + " <factField>amount</factField>\n" + " <fieldType>Integer</fieldType>\n" + " <operator>==</operator>\n" + " <valueList>a,b</valueList>\n" + " <parameters/>\n" + " </condition-column52>\n" + " </conditions>\n" + " <window>\n" + " <parameters/>\n" + " </window>\n" + " <entryPointName></entryPointName>\n" + " </Pattern52>\n" + " </conditionPatterns>\n" + " <actionCols/>\n" + " <auditLog>\n" + " <filter class=\"org.drools.guvnor.client.modeldriven.dt52.auditlog.DecisionTableAuditLogFilter\">\n" + " <acceptedTypes>\n" + " <entry>\n" + " <string>INSERT_ROW</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>INSERT_COLUMN</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>DELETE_ROW</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>DELETE_COLUMN</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " <entry>\n" + " <string>UPDATE_COLUMN</string>\n" + " <boolean>false</boolean>\n" + " </entry>\n" + " </acceptedTypes>\n" + " </filter>\n" + " <entries/>\n" + " </auditLog>\n" + " <imports>\n" + " <imports/>\n" + " </imports>\n" + " <packageName>mortgages.mortgages</packageName>\n" + " <tableFormat>EXTENDED_ENTRY</tableFormat>\n" + " <hitPolicy>NONE</hitPolicy>\n" + " <data>\n" + " <list>\n" + " <value>\n" + " <valueNumeric class=\"int\">1</valueNumeric>\n" + " <valueString></valueString>\n" + " <dataType>NUMERIC_INTEGER</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </value>\n" + " <value>\n" + " <valueString></valueString>\n" + " <dataType>STRING</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </value>\n" + " <value>\n" + " <valueNumeric class=\"int\">1000</valueNumeric>\n" + " <dataType>NUMERIC_INTEGER</dataType>\n" + " <isOtherwise>false</isOtherwise>\n" + " </value>\n" + " </list>\n" + " </data>\n" + "</decision-table52>";
// Build the module with a broken DRL file
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/org/drools/test/personDrl.drl", typeDrl).write("src/main/resources/dt1.gdst", brokenDrlGenerated);
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
Results buildResults = kieBuilder.getResults();
int errorsNr = buildResults.getMessages(Message.Level.ERROR).size();
Assert.assertTrue("Expected build failure", errorsNr > 0);
// Fix the DRL file
kfs.write("src/main/resources/dt1.gdst", correctDrlGenerated);
IncrementalResults results = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/dt1.gdst").build();
assertEquals(0, results.getAddedMessages().size());
assertEquals(errorsNr, results.getRemovedMessages().size());
}
Aggregations