public boolean checkExpanded(final String patternOriginal) { return this.expander.checkPattern( patternOriginal ); } }
@Test public void testRuleWithoutEnd() throws Exception { String source = "rule \"Invalid customer id\" \n" + " when \n" + " o: Order( ) \n" + " then \n" + " System.err.println(\"Invalid customer id found!\"); \n"; parse( "compilationUnit", source ); assertTrue( parser.hasErrors() ); }
@Test(timeout=10*1000) public void testCheckRuleHeaderLocationDetermination3() { String input = "rule \"Hello World\" ruleflow-group \"hello\" s"; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test public void testInvalidSyntax_Catches() throws Exception { DRLParser parser = parseResource("invalid_syntax.drl"); parser.compilationUnit(); assertTrue(parser.hasErrors()); }
@Test public void testDump() throws Exception { String input = "price > 10 && < 20 || == $val || == 30"; String expected = "( price > 10 && price < 20 || price == $val || price == 30 )"; ConstraintConnectiveDescr descr = parse( input ); String result = dumper.dump( descr ); assertEquals( expected, result ); }
@Test public void testChunkWithParensAndQuotedString() throws Exception { String input = "( fnord( \"cheese\" ) )"; createParser( new ANTLRStringStream( input ) ); String returnData = parser.chunk( DRL6Lexer.LEFT_PAREN, DRL6Lexer.RIGHT_PAREN, -1 ); assertEquals( "fnord( \"cheese\" )", returnData ); }
@Test(timeout=10*1000) public void testCheckRuleHeaderLocationDetermination_dialect1() { String input = "rule MyRule \n" + " dialect \"java\""; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test public void testNotBindindShouldBarf() throws Exception { final DRLParser parser = parseResource( "not_with_binding_error.drl" ); parser.compilationUnit(); assertTrue(parser.hasErrors()); }
@Test public void testDumpMatches2() throws Exception { String input = "type.toString matches 'something\\swith\\tsingle escapes'"; String expected = "type.toString ~= \"something\\swith\\tsingle escapes\""; ConstraintConnectiveDescr descr = parse( input ); String result = dumper.dump( descr ); assertEquals( expected, result ); }
@Test(timeout=10*1000) public void testCheckRuleHeaderLocationDetermination() { String input = "rule MyRule "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test public void testPackageGarbage() throws Exception { DRLParser parser = parseResource( "package_garbage.drl" ); parser.compilationUnit(); assertTrue(parser.hasErrors()); }
@Test public void testDumpMatches() throws Exception { String input = "type.toString matches \"something\\swith\\tsingle escapes\""; String expected = "type.toString ~= \"something\\swith\\tsingle escapes\""; ConstraintConnectiveDescr descr = parse( input ); String result = dumper.dump( descr ); assertEquals( expected, result ); }
@Test(timeout=10*1000) public void testCheckQueryLocationDetermination_RULE_HEADER1() { String input = "query MyQuery "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test public void testLexicalError() throws Exception { DRLParser parser = parseResource( "lex_error.drl" ); parser.compilationUnit(); assertTrue( parser.hasErrors() ); }
@Test(timeout=10*1000) public void testCheckQueryLocationDetermination_RULE_HEADER2() { String input = "query \"MyQuery\" "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test public void testTempleteError() throws Exception { DRLParser parser = parseResource( "template_test_error.drl" ); parser.compilationUnit(); assertTrue(parser.hasErrors()); }
@Test(timeout=10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START21() { String input = "rule MyRule \n" + " when \n" + " not Class ("; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, getLastIntegerValue(parser.getEditorInterface().get(0) .getContent())); }
@Test public void testCommaMisuse() throws Exception { final DRLParser parser = parseResource( "comma_misuse.drl" ); try { parser.compilationUnit(); assertTrue( "Parser should have raised errors", parser.hasErrors() ); } catch ( NullPointerException npe ) { fail( "Should not raise NPE" ); } }
@Test(timeout=10*1000) public void testCheckRHSLocationDetermination_startOfNewlINE() { String input = "rule MyRule \n" + " when\n" + " Class ( )\n" + " then\n" + " assert(null);\n" + " "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RHS, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }