@Test public void testParseFileWithEscaptedBrackets() { String file = "[when]ATTRIBUTE \"{attr}\" IS IN \\[{list}\\]=Attribute( {attr} in ({list}) )"; try { final Reader reader = new StringReader(file); this.file = new DSLTokenizedMappingFile(); final boolean parsingResult = this.file.parseAndLoad(reader); reader.close(); assertTrue(this.file.getErrors().toString(), parsingResult); assertTrue(this.file.getErrors().isEmpty()); assertEquals(1, this.file.getMapping().getEntries().size()); DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get(0); assertEquals(DSLMappingEntry.CONDITION, entry.getSection()); assertEquals(DSLMappingEntry.EMPTY_METADATA, entry.getMetaData()); assertEquals( lookbehind + "ATTRIBUTE\\s+\"(.*?)\"\\s+IS\\s+IN\\s+\\[(.*?)\\](?=\\W|$)", entry.getKeyPattern().toString()); // Attribute( {attr} in ({list}) ) assertEquals("Attribute( {attr} in ({list}) )", entry.getValuePattern()); } catch (final IOException e) { e.printStackTrace(); fail("Should not raise exception "); } }
@Test public void testParseFileWithEscaptedEquals() { String file = "[when]something:\\={value}=Attribute( something == \"{value}\" )"; try { final Reader reader = new StringReader(file); this.file = new DSLTokenizedMappingFile(); final boolean parsingResult = this.file.parseAndLoad(reader); reader.close(); assertTrue(this.file.getErrors().toString(), parsingResult); assertTrue(this.file.getErrors().isEmpty()); assertEquals(1, this.file.getMapping().getEntries().size()); DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get(0); assertEquals(DSLMappingEntry.CONDITION, entry.getSection()); assertEquals(DSLMappingEntry.EMPTY_METADATA, entry.getMetaData()); assertEquals(lookbehind + "something:\\=(.*?)$", entry.getKeyPattern().toString()); assertEquals("Attribute( something == \"{value}\" )", entry.getValuePattern()); } catch (final IOException e) { e.printStackTrace(); fail("Should not raise exception "); } }