@Test
public void testGetRestrictionAsEntries()
{

    CarFlagEncoder encoder = new CarFlagEncoder(5, 5, 1);
    final Map<Long, Integer> osmNodeToInternal = new HashMap<Long, Integer>();
    final Map<Integer, Long> internalToOSMEdge = new HashMap<Integer, Long>();
    osmNodeToInternal.put(3L, 3);
    // edge ids are only stored if they occured before in an OSMRelation
    internalToOSMEdge.put(3, 3L);
    internalToOSMEdge.put(4, 4L);
    GraphHopperStorage ghStorage = new GraphBuilder(new EncodingManager(encoder)).create();
    EdgeBasedRoutingAlgorithmTest.initGraph(ghStorage);
    OSMReader osmReader = new OSMReader(ghStorage)
    {
        @Override
        public int getInternalNodeIdOfOsmNode( long nodeOsmId )
        {
            return osmNodeToInternal.get(nodeOsmId);
        }
        @Override
        public long getOsmIdOfInternalEdge( int edgeId )
        {
            Long l = internalToOSMEdge.get(edgeId);
            if (l == null)
                return -1;
            return l;
        }
    };
    EdgeExplorer edgeExplorer = ghStorage.createEdgeExplorer();
    // TYPE == ONLY
    OSMTurnRelation instance = new OSMTurnRelation(4, 3, 3, Type.ONLY);
    Collection<OSMTurnRelation.TurnCostTableEntry> result
            = instance.getRestrictionAsEntries(encoder, edgeExplorer, edgeExplorer, osmReader);
    assertEquals(2, result.size());
    Iterator<OSMTurnRelation.TurnCostTableEntry> iter = result.iterator();
    OSMTurnRelation.TurnCostTableEntry entry = iter.next();
    assertEquals(4, entry.edgeFrom);
    assertEquals(6, entry.edgeTo);
    assertEquals(3, entry.nodeVia);
    entry = iter.next();
    assertEquals(4, entry.edgeFrom);
    assertEquals(2, entry.edgeTo);
    assertEquals(3, entry.nodeVia);
    // TYPE == NOT
    instance = new OSMTurnRelation(4, 3, 3, Type.NOT);
    result = instance.getRestrictionAsEntries(encoder, edgeExplorer, edgeExplorer, osmReader);
    assertEquals(1, result.size());
    iter = result.iterator();
    entry = iter.next();
    assertEquals(4, entry.edgeFrom);
    assertEquals(3, entry.edgeTo);
    assertEquals(3, entry.nodeVia);
}