### Question:
QueryGraph implements Graph { public boolean enforceHeadingByEdgeId( int nodeId, int edgeId, boolean incoming ) { if (!isVirtualNode(nodeId)) return false; VirtualEdgeIteratorState incomingEdge = (VirtualEdgeIteratorState) getEdgeIteratorState(edgeId, nodeId); VirtualEdgeIteratorState reverseEdge = (VirtualEdgeIteratorState) getEdgeIteratorState(edgeId, incomingEdge.getBaseNode()); incomingEdge.setVirtualEdgePreference(true); modifiedEdges.add(incomingEdge); reverseEdge.setVirtualEdgePreference(true); modifiedEdges.add(reverseEdge); return true; } QueryGraph( Graph graph ); private  QueryGraph( Graph graph, QueryGraph superQueryGraph ); QueryGraph lookup( QueryResult fromRes, QueryResult toRes ); void lookup( List<QueryResult> resList ); @Override Graph getBaseGraph(); boolean isVirtualEdge( int edgeId ); boolean isVirtualNode( int nodeId ); boolean enforceHeading( int nodeId, double favoredHeading, boolean incoming ); boolean enforceHeadingByEdgeId( int nodeId, int edgeId, boolean incoming ); void clearUnfavoredStatus(); @Override int getNodes(); @Override NodeAccess getNodeAccess(); @Override BBox getBounds(); @Override EdgeIteratorState getEdgeIteratorState( int origEdgeId, int adjNode ); @Override EdgeExplorer createEdgeExplorer( final EdgeFilter edgeFilter ); @Override EdgeExplorer createEdgeExplorer(); @Override AllEdgesIterator getAllEdges(); @Override EdgeIteratorState edge( int a, int b ); EdgeIteratorState edge( int a, int b, double distance, int flags ); @Override EdgeIteratorState edge( int a, int b, double distance, boolean bothDirections ); @Override Graph copyTo( Graph g ); @Override GraphExtension getExtension();  }### Answer:
@Test public void testEnforceHeadingByEdgeId() { initHorseshoeGraph(g); EdgeIteratorState edge = GHUtility.getEdge(g, 0, 1); QueryResult qr = fakeEdgeQueryResult(edge, 1.5, 0, 0); QueryGraph queryGraph = new QueryGraph(g); queryGraph.lookup(Arrays.asList(qr)); queryGraph.enforceHeadingByEdgeId(2, 1, false); boolean expect = true; VirtualEdgeIteratorState incomingEdge = (VirtualEdgeIteratorState) queryGraph.getEdgeIteratorState(1, 2); VirtualEdgeIteratorState incomingEdgeReverse = (VirtualEdgeIteratorState) queryGraph.getEdgeIteratorState(1, incomingEdge.getBaseNode()); assertEquals(expect, incomingEdge.getBoolean(EdgeIteratorState.K_UNFAVORED_EDGE, true, !expect)); assertEquals(expect, incomingEdgeReverse.getBoolean(EdgeIteratorState.K_UNFAVORED_EDGE, false, !expect)); queryGraph.clearUnfavoredStatus(); expect = false; assertEquals(expect, incomingEdge.getBoolean(EdgeIteratorState.K_UNFAVORED_EDGE, true, !expect)); assertEquals(expect, incomingEdgeReverse.getBoolean(EdgeIteratorState.K_UNFAVORED_EDGE, false, !expect)); }