Search in sources :

Example 16 with DSLMappingEntry

use of org.drools.drl.parser.lang.dsl.DSLMappingEntry in project drools by kiegroup.

the class DSLMappingEntryTest method testExpandSpaces.

@Test
public void testExpandSpaces() throws IOException {
    DSLMappingEntry entry = this.setupEntry();
    DefaultExpander ex = makeExpander(entry);
    String[] strs = new String[] { "0_sp", " 1_sp", "   3_sp", "0_sp_1 ", "0_sp_3   ", "0_sp 1_sp 2_sp", "   3_sp   3_sp 1_sp 1_sp_2  " };
    StringBuilder sb = new StringBuilder("rule x\n" + "when\n");
    for (String str : strs) {
        sb.append("String is \"" + str + "\"" + NL);
    }
    sb.append("then\n" + "end\n");
    String dslr = sb.toString();
    String drl = ex.expand(dslr);
    for (String str : strs) {
        assertTrue(drl.contains('"' + str + '"'));
    }
}
Also used : DSLMappingEntry(org.drools.drl.parser.lang.dsl.DSLMappingEntry) DefaultExpander(org.drools.drl.parser.lang.dsl.DefaultExpander) Test(org.junit.Test)

Aggregations

DSLMappingEntry (org.drools.drl.parser.lang.dsl.DSLMappingEntry)16 Test (org.junit.Test)14 DSLTokenizedMappingFile (org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile)9 InputStreamReader (java.io.InputStreamReader)8 Reader (java.io.Reader)8 StringReader (java.io.StringReader)8 IOException (java.io.IOException)7 DefaultExpander (org.drools.drl.parser.lang.dsl.DefaultExpander)6 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 DefaultDSLMapping (org.drools.drl.parser.lang.dsl.DefaultDSLMapping)1 Ignore (org.junit.Ignore)1