RuleBlock ruleBody = createMock(RuleBlock.class);
LabeledElement labeledElement = createMock(LabeledElement.class);
Terminal terminal = createMock(Terminal.class);
LexerRule ID = createMock(LexerRule.class);
ActionElement actionElement = createMock(ActionElement.class);
ActionOption actionOption = createMock(ActionOption.class);
Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");
expect(grammar.getRules()).andReturn(rules);
expect(rule1.getArgs()).andReturn(args);
expect(rule1.getReturn()).andReturn(returns);
expect(rule1.getLocals()).andReturn(locals);
expect(rule1.getBody()).andReturn(ruleBody).times(2);
expect(returns.getBody()).andReturn(returnBody);
expect(locals.getBody()).andReturn(localsBody);
ruleBodyList.add(labeledElement);
ruleBodyList.add(terminal);
ruleBodyList.add(actionElement);
ruleBodyList.add(actionOption);
expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
expect(terminal.getReference()).andReturn(ID);
expect(labeledElement.getName()).andReturn("var");
expect(ID.getName()).andReturn("ID");
expect(actionElement.getBody()).andReturn("{$a = 0; $b = 3; text = $ID.text;}");
expect(actionOption.getValue()).andReturn("{$r = 0; $l = null; v = $var;}");
rules.add(rule1);
Object[] mocks = {grammar, validator, rule1, returns, locals, ruleBody, labeledElement,
terminal, ID, actionElement, actionOption };