### Question:
Grammar { public List<Rule> getBinaryRules(String left, String right){ StringTuple tuple = StringTuple.fromParts(left, right); return binaryRules.containsKey(tuple) ? binaryRules.get(tuple) : Collections.emptyList(); } Grammar(List<Rule> rules, String rootCategory); boolean isRoot(Rule rule); List<Rule> getLexicalRules(List<String> rhs); List<Rule> getUnaryRules(String rhs); List<Rule> getBinaryRules(String left, String right); Set<Rule> getNonTerminalRules();  }### Answer:
@Test void getBinaryRules() { List<Rule> rules = Collections.singletonList(new Rule("$A", "$B $C")); Grammar grammar = new Grammar(rules, "$ROOT"); assertEquals(rules.get(0), grammar.getBinaryRules("$B", "$C").get(0)); assertEquals(0, grammar.getLexicalRules(Arrays.asList("$B", "$C")).size()); assertEquals(0, grammar.getUnaryRules("$B").size()); }