### Question:
OSMTrackTypeParser implements TagParser { @Override public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay readerWay, boolean ferry, IntsRef relationFlags) { if (ferry) return edgeFlags; String trackTypeTag = readerWay.getTag("tracktype"); if (trackTypeTag == null) return edgeFlags; TrackType trackType = TrackType.find(trackTypeTag); if (trackType != OTHER) trackTypeEnc.setEnum(false, edgeFlags, trackType); return edgeFlags; } OSMTrackTypeParser(); @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 intsRef = em.createEdgeFlags(); readerWay.setTag("tracktype", "grade1"); parser.handleWayTags(intsRef, readerWay, false, relFlags); assertEquals(TrackType.GRADE1, ttEnc.getEnum(false, intsRef)); intsRef = em.createEdgeFlags(); readerWay.setTag("tracktype", "grade2"); parser.handleWayTags(intsRef, readerWay, false, relFlags); assertEquals(TrackType.GRADE2, ttEnc.getEnum(false, intsRef)); intsRef = em.createEdgeFlags(); readerWay.setTag("tracktype", "grade3"); parser.handleWayTags(intsRef, readerWay, false, relFlags); assertEquals(TrackType.GRADE3, ttEnc.getEnum(false, intsRef)); intsRef = em.createEdgeFlags(); readerWay.setTag("tracktype", "grade4"); parser.handleWayTags(intsRef, readerWay, false, relFlags); assertEquals(TrackType.GRADE4, ttEnc.getEnum(false, intsRef)); intsRef = em.createEdgeFlags(); readerWay.setTag("tracktype", "grade5"); parser.handleWayTags(intsRef, readerWay, false, relFlags); assertEquals(TrackType.GRADE5, ttEnc.getEnum(false, intsRef)); }
@Test public void testUnkownValue() { ReaderWay readerWay = new ReaderWay(1); IntsRef intsRef = em.createEdgeFlags(); readerWay.setTag("tracktype", "unknownstuff"); parser.handleWayTags(intsRef, readerWay, false, relFlags); assertEquals(TrackType.OTHER, ttEnc.getEnum(false, intsRef)); }
@Test public void testNoNPE() { ReaderWay readerWay = new ReaderWay(1); IntsRef intsRef = em.createEdgeFlags(); parser.handleWayTags(intsRef, readerWay, false, relFlags); assertEquals(TrackType.OTHER, ttEnc.getEnum(false, intsRef)); }