use of org.drools.compiler.lang.descr.ImportDescr in project drools by kiegroup.
the class RuleParserTest method testCompilationUnit.
@Test
public void testCompilationUnit() throws Exception {
final String source = "package foo; import com.foo.Bar; import com.foo.Baz;";
PackageDescr pkg = (PackageDescr) parse("compilationUnit", source);
assertFalse(parser.getErrors().toString(), parser.hasErrors());
assertEquals("foo", pkg.getName());
assertEquals(2, pkg.getImports().size());
ImportDescr impdescr = pkg.getImports().get(0);
assertEquals("com.foo.Bar", impdescr.getTarget());
assertEquals(source.indexOf("import " + impdescr.getTarget()), impdescr.getStartCharacter());
assertEquals(source.indexOf("import " + impdescr.getTarget()) + ("import " + impdescr.getTarget()).length(), impdescr.getEndCharacter());
impdescr = pkg.getImports().get(1);
assertEquals("com.foo.Baz", impdescr.getTarget());
assertEquals(source.indexOf("import " + impdescr.getTarget()), impdescr.getStartCharacter());
assertEquals(source.indexOf("import " + impdescr.getTarget()) + ("import " + impdescr.getTarget()).length(), impdescr.getEndCharacter());
}
Aggregations