use of org.drools.verifier.VerifierError in project drools by kiegroup.
the class VerifierKnowledgeBaseBuilder method newVerifierKnowledgeBase.
public KieBase newVerifierKnowledgeBase(VerifierConfiguration configuration) {
InternalKnowledgeBase verifierKnowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeBuilderConfiguration kbuilderConfiguration = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
kbuilderConfiguration.setProperty("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbuilderConfiguration);
if (configuration.getVerifyingResources() != null) {
for (Resource resource : configuration.getVerifyingResources().keySet()) {
kbuilder.add(resource, configuration.getVerifyingResources().get(resource));
}
}
if (kbuilder.hasErrors()) {
Iterator<KnowledgeBuilderError> errors = kbuilder.getErrors().iterator();
while (errors.hasNext()) {
this.errors.add(new VerifierError("Error compiling verifier rules: " + errors.next().getMessage()));
}
}
verifierKnowledgeBase.addPackages(kbuilder.getKnowledgePackages());
return verifierKnowledgeBase;
}
use of org.drools.verifier.VerifierError in project drools by kiegroup.
the class VerifierImpl method addResourcesToVerify.
public void addResourcesToVerify(Resource resource, ResourceType type) {
verifierPackageBuilder.addKnowledgeResource(resource, type, null);
if (verifierPackageBuilder.hasErrors()) {
addVerifierErrors(verifierPackageBuilder.getErrors());
}
PackageDescr pkg = verifierPackageBuilder.getPackageDescr();
if (pkg != null) {
addPackageDescr(pkg);
} else {
errors.add(new VerifierError("Verifier could not form a PackageDescr from the resources that it was trying to verify."));
}
}
use of org.drools.verifier.VerifierError in project drools by kiegroup.
the class SubsumptantSubPatternsTest method testSubpatternSubsumption1.
@Test
public void testSubpatternSubsumption1() throws Exception {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantSubPatterns1.drl", getClass()), ResourceType.DRL);
// for ( VerifierError error : verifier.getMissingClasses() ) {
// System.out.println( error.getMessage() );
// }
assertFalse(verifier.hasErrors());
boolean noProblems = verifier.fireAnalysis();
if (!noProblems) {
for (VerifierError error : verifier.getErrors()) {
System.out.println(error.getMessage());
}
}
Collection<? extends Object> subsumptionList = ((VerifierImpl) verifier).getKnowledgeSession().getObjects(new ClassObjectFilter(Subsumption.class));
int count = 0;
for (Object object : subsumptionList) {
// System.out.println( " * " + ((Subsumption) object) );
if (((VerifierComponent) ((Subsumption) object).getLeft()).getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) {
// System.out.println( " ** " + ((SubPattern) ((Subsumption) object).getLeft()).getItems() + " - " + ((SubPattern) ((Subsumption) object).getRight()).getItems() );
count++;
}
}
assertEquals(1, count);
verifier.dispose();
}
use of org.drools.verifier.VerifierError in project drools by kiegroup.
the class VerifierImpl method addResourcesToVerify.
public void addResourcesToVerify(Resource resource, ResourceType type, ResourceConfiguration config) {
verifierPackageBuilder.addKnowledgeResource(resource, type, config);
if (verifierPackageBuilder.hasErrors()) {
addVerifierErrors(verifierPackageBuilder.getErrors());
}
PackageDescr pkg = verifierPackageBuilder.getPackageDescr();
if (pkg != null) {
addPackageDescr(pkg);
} else {
errors.add(new VerifierError("Verifier could not form a PackageDescr from the resources that it was trying to verify."));
}
}
Aggregations