CustomDescriptionStepParser implements StepParser<DescriptionStep> { private ParseContext parse(String expression) { BaseErrorListener baseErrorListener = new BaseErrorListener() { @Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new IllegalStateException(msg, e); } }; DescriptionStepLexer lexer = new DescriptionStepLexer(new ANTLRInputStream(expression)); lexer.addErrorListener(baseErrorListener); DescriptionStepParser parser = new DescriptionStepParser(new CommonTokenStream(lexer)); parser.addErrorListener(baseErrorListener); return parser.parse(); }  @Override int getParserScoreForStep(AbstractStep step); @Override void parseStep(ParsingContext parsingContext, DescriptionStep step);  }
@Test public void testMultipleSet() throws Exception { List<AbstractStep> steps = new ArrayList<>(); steps.add(step("Set a='b'\t c=\"d\"\u00A0e = 'f'\n")); List<AbstractArtefact> children = getChildren(parse(steps)); Set set = (Set) children.get(0); Assert.assertEquals("a",set.getKey().getValue()); Assert.assertEquals("'b'",set.getValue().getExpression()); set = (Set) children.get(1); Assert.assertEquals("c",set.getKey().getValue()); Assert.assertEquals("\"d\"",set.getValue().getExpression()); set = (Set) children.get(2); Assert.assertEquals("e",set.getKey().getValue()); Assert.assertEquals("'f'",set.getValue().getExpression()); }
@Test public void testSetWithExpression() throws Exception { List<AbstractStep> steps = new ArrayList<>(); steps.add(step("Set a=b.c d= e.getF() num=1")); List<AbstractArtefact> children = getChildren(parse(steps)); Set set0 = (Set) children.get(0); Assert.assertEquals("a",set0.getKey().getValue()); Assert.assertEquals("b.c",set0.getValue().getExpression()); Set set1 = (Set) children.get(1); Assert.assertEquals("d",set1.getKey().getValue()); Assert.assertEquals("e.getF()",set1.getValue().getExpression()); Set set2 = (Set) children.get(2); Assert.assertEquals("num",set2.getKey().getValue()); Assert.assertEquals("1",set2.getValue().getExpression()); }