public void checkPredictedAlt(LexerGrammar lg, Grammar g, int decision,
	                              String inputString, int expectedAlt)
	{
		ATN lexatn = createATN(lg, true);
		LexerATNSimulator lexInterp =
		new LexerATNSimulator(lexatn,new DFA[] { new DFA(lexatn.modeToStartState.get(Lexer.DEFAULT_MODE)) },new PredictionContextCache());
		IntegerList types = getTokenTypesViaATN(inputString, lexInterp);
//		System.out.println(types);

		semanticProcess(lg);
		g.importVocab(lg);
		semanticProcess(g);

		ParserATNFactory f = new ParserATNFactory(g);
		ATN atn = f.createATN();

		DOTGenerator dot = new DOTGenerator(g);

		Rule r = g.getRule("a");
//		if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
		r = g.getRule("b");
//		if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
		r = g.getRule("e");
//		if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
		r = g.getRule("ifstat");
//		if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
		r = g.getRule("block");
//		if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));

		// Check ATN prediction
//		ParserATNSimulator interp = new ParserATNSimulator(atn);
		TokenStream input = new MockIntTokenStream(types);
		ParserInterpreterForTesting interp = new ParserInterpreterForTesting(g, input);
		int alt = interp.adaptivePredict(input, decision, ParserRuleContext.EMPTY);

		assertEquals(expectedAlt, alt);

		// Check adaptive prediction
		input.seek(0);
		alt = interp.adaptivePredict(input, decision, null);
		assertEquals(expectedAlt, alt);
		// run 2x; first time creates DFA in atn
		input.seek(0);
		alt = interp.adaptivePredict(input, decision, null);
		assertEquals(expectedAlt, alt);
	}
first check that the ATN predicts right alt.
 Then check adaptive prediction.
tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java