### Question:
OSMRoadClassParser implements TagParser { @Override public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay readerWay, boolean ferry, IntsRef relationFlags) { if (ferry) return edgeFlags; String roadClassTag = readerWay.getTag("highway"); if (roadClassTag == null) return edgeFlags; RoadClass roadClass = RoadClass.find(roadClassTag); if (roadClass == OTHER && roadClassTag.endsWith("_link")) roadClass = RoadClass.find(roadClassTag.substring(0, roadClassTag.length() - 5)); if (roadClass != OTHER) roadClassEnc.setEnum(false, edgeFlags, roadClass); return edgeFlags; } OSMRoadClassParser(); @Override void createEncodedValues(EncodedValueLookup lookup, List<EncodedValue> link); @Override IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay readerWay, boolean ferry, IntsRef relationFlags);  }### Answer:
@Test public void testSimpleTags() { ReaderWay readerWay = new ReaderWay(1); IntsRef edgeFlags = em.createEdgeFlags(); readerWay.setTag("highway", "primary"); parser.handleWayTags(edgeFlags, readerWay, false, relFlags); assertEquals(RoadClass.PRIMARY, rcEnc.getEnum(false, edgeFlags)); edgeFlags = em.createEdgeFlags(); readerWay.setTag("highway", "unknownstuff"); parser.handleWayTags(edgeFlags, readerWay, false, relFlags); assertEquals(RoadClass.OTHER, rcEnc.getEnum(false, edgeFlags)); edgeFlags = em.createEdgeFlags(); readerWay.setTag("highway", "motorway_link"); parser.handleWayTags(edgeFlags, readerWay, false, relFlags); assertEquals(RoadClass.MOTORWAY, rcEnc.getEnum(false, edgeFlags)); }
@Test public void testIgnore() { ReaderWay readerWay = new ReaderWay(1); IntsRef edgeFlags = em.createEdgeFlags(); readerWay.setTag("route", "ferry"); parser.handleWayTags(edgeFlags, readerWay, true, relFlags); assertEquals(RoadClass.OTHER, rcEnc.getEnum(false, edgeFlags)); }
@Test public void testNoNPE() { ReaderWay readerWay = new ReaderWay(1); IntsRef edgeFlags = em.createEdgeFlags(); parser.handleWayTags(edgeFlags, readerWay, false, relFlags); assertEquals(RoadClass.OTHER, rcEnc.getEnum(false, edgeFlags)); }