use of org.drools.verifier.data.VerifierComponent in project drools by kiegroup.
the class PackageDescrVisitorTest method testSubPatterns.
@Test
public void testSubPatterns() throws Exception {
PackageDescr packageDescr = getPackageDescr(getClass().getResourceAsStream("SubPattern.drl"));
assertNotNull(packageDescr);
packageDescrVisitor.visitPackageDescr(packageDescr);
Collection<VerifierComponent> all = verifierData.getAll();
assertNotNull(all);
SubPattern test1SubPattern = null;
SubPattern test2SubPattern = null;
SubRule test1SubRule = null;
SubRule test2SubRule = null;
for (VerifierComponent verifierComponent : all) {
// System.out.println( verifierComponent );
System.out.println("-" + verifierComponent);
if (verifierComponent.getDescr() != null) {
System.out.println(" \n\t\t => " + verifierComponent.getDescr().getLine() + ":" + +verifierComponent.getDescr().getEndLine() + " " + verifierComponent.getDescr().getText());
} else {
System.out.println(" \n\t\t => null for " + verifierComponent.getClass().getSimpleName());
}
if (verifierComponent.getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) {
SubPattern subPattern = (SubPattern) verifierComponent;
if ("Test 1".equals(subPattern.getRuleName())) {
assertNull(test1SubPattern);
test1SubPattern = subPattern;
} else if ("Test 2".equals(subPattern.getRuleName())) {
assertNull(test2SubPattern);
test2SubPattern = subPattern;
}
}
if (verifierComponent.getVerifierComponentType().equals(VerifierComponentType.SUB_RULE)) {
SubRule subRule = (SubRule) verifierComponent;
if ("Test 1".equals(subRule.getRuleName())) {
assertNull(test1SubRule);
test1SubRule = subRule;
} else if ("Test 2".equals(subRule.getRuleName())) {
assertNull(test2SubRule);
test2SubRule = subRule;
}
}
}
assertNotNull(test1SubPattern);
assertEquals(3, test1SubPattern.getItems().size());
assertNotNull(test2SubPattern);
assertEquals(3, test2SubPattern.getItems().size());
assertNotNull(test1SubRule);
assertEquals(1, test1SubRule.getItems().size());
assertNotNull(test2SubRule);
assertEquals(1, test2SubRule.getItems().size());
}
use of org.drools.verifier.data.VerifierComponent in project drools by kiegroup.
the class PackageDescrVisitorTest method testVisit.
@Test
public void testVisit() throws Exception {
PackageDescr packageDescr = getPackageDescr(Verifier.class.getResourceAsStream("Misc3.drl"));
assertNotNull(packageDescr);
packageDescrVisitor.visitPackageDescr(packageDescr);
Collection<VerifierComponent> all = verifierData.getAll();
Set<String> names = new HashSet<String>();
for (VerifierComponent verifierComponent : all) {
String path = verifierComponent.getPath();
System.out.println("-" + verifierComponent);
if (verifierComponent.getDescr() != null) {
System.out.println(" \n\t\t => " + verifierComponent.getDescr().getLine() + ":" + +verifierComponent.getDescr().getEndLine() + " " + verifierComponent.getDescr().getText());
} else {
System.out.println(" \n\t\t => null for " + verifierComponent.getClass().getSimpleName());
}
if (names.contains(path)) {
fail("Dublicate path " + path);
} else {
names.add(path);
}
}
assertNotNull(all);
assertEquals(45, all.size());
}
Aggregations