@Test
public void testEnforceHeading()
{

    initHorseshoeGraph(g);
    EdgeIteratorState edge = GHUtility.getEdge(g, 0, 1);
    // query result on first vertical part of way (upward)
    QueryResult qr = fakeEdgeQueryResult(edge, 1.5, 0, 0);
    QueryGraph queryGraph = new QueryGraph(g);
    queryGraph.lookup(Arrays.asList(qr));
    // enforce going out north
    queryGraph.enforceHeading(qr.getClosestNode(), 0., false);
    // test penalized south
    boolean expect = true;
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_BASE_REV, false, !expect));
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_BASE, true, !expect));
    queryGraph.clearUnfavoredStatus();
    // test cleared edges south
    expect = false;
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_BASE_REV, false, !expect));
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_BASE, true, !expect));
    // enforce coming in north
    queryGraph.enforceHeading(qr.getClosestNode(), 180., true);
    // test penalized south
    expect = true;
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_BASE_REV, true, !expect));
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_BASE, false, !expect));
    // query result on second vertical part of way (downward)
    qr = fakeEdgeQueryResult(edge, 1.5, 2, 2);
    queryGraph = new QueryGraph(g);
    queryGraph.lookup(Arrays.asList(qr));
    // enforce going north
    queryGraph.enforceHeading(qr.getClosestNode(), 0., false);
    // test penalized south
    expect = true;
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_ADJ, false, !expect));
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_ADJ_REV, true, !expect));
    queryGraph.clearUnfavoredStatus();
    // enforce coming in north
    queryGraph.enforceHeading(qr.getClosestNode(), 180., true);
    // test penalized south
    expect = true;
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_ADJ, true, !expect));
    assertEquals(expect, getEdgePreference(queryGraph, QueryGraph.VE_ADJ_REV, false, !expect));
}