### Question:
GOLDParser extends Parser { public void validateHandlerExists(Production rule) throws ParserException { if (ruleHandlers.get(rule.toString()) == null) { raiseParserException(FormatHelper.formatMessage("messages", "error.handler_none", rule)); } } GOLDParser();  GOLDParser(GOLDParserBuildContext context);  GOLDParser(File cgtFile, String rulesPackage, boolean trimReductions);  GOLDParser(InputStream cgtFile, String rulesPackage, boolean trimReductions); void clear(); void clearProgramVariables(); void clearProgramVariable(String name); Variable getProgramVariable(String name); void setProgramVariable(String name, Variable value); Map<String, Scope> getScopes(); Scope getCurrentScope(); Scope setCurrentScope(Scope newScope); boolean getGenerateTree(); void setGenerateTree(boolean generateTree); void raiseParserException(String msg); void raiseParserException(String msg, Throwable cause); List<String> getErrorMessages(); String getErrorMessage(); void addErrorMessage(String message); boolean isReady(); boolean isIgnoreCaseOfVariables(); void setIgnoreCaseOfVariables(boolean ignoreCaseOfVariableNames); boolean setup(File grammarFile); boolean parseSourceStatements(String sourceStatements); boolean parseSourceStatements(Reader sourceReader); boolean processInternalError(); String getParseTree(); void loadRuleHandlers(String packageName); void loadRuleHandlers(List<Class> ruleClasses); List<String> validateHandlersExist(); void validateHandlerExists(Production rule); static final String VT_INDENT_DECREASE; static final String VT_INDENT_INCREASE; }### Answer:
@Test public void testValidateHandlerExists() throws Exception { GOLDParser parser = new GOLDParser(new File("src/test/resources/parser/Simple2.cgt"), "com.creativewidgetworks.goldparser.simple2", true); Symbol symbol = new Symbol("Value", SymbolType.NON_TERMINAL, 0); Production production = new Production(symbol, 0); production.getHandle().add(new Symbol("StringLiteral", SymbolType.CONTENT, 0)); parser.validateHandlerExists(production); production = new Production(symbol, 0); production.getHandle().add(new Symbol("DateLiteral", SymbolType.CONTENT, 0)); try { parser.validateHandlerExists(production); fail("expected ParserException"); } catch (ParserException pe) { assertEquals("wrong msg", "No rule handler for rule <Value> ::= DateLiteral", pe.getMessage()); } }