RequestItemV2Parser extends Parser<RequestItemV2> { @Override public RequestItemV2 parse() { RequestItemV2 item = new RequestItemV2(); item.setRequestType(parseIntField(ExtensionByteLength.CERTIFICATE_STATUS_REQUEST_STATUS_TYPE)); item.setRequestLength(parseIntField(ExtensionByteLength.CERTIFICATE_STATUS_REQUEST_V2_REQUEST_LENGTH)); item.setResponderIdListLength(parseIntField(ExtensionByteLength.CERTIFICATE_STATUS_REQUEST_V2_RESPONDER_ID)); item.setResponderIdListBytes(parseByteArrayField(item.getResponderIdListLength().getValue())); item.setRequestExtensionsLength(parseIntField(ExtensionByteLength.CERTIFICATE_STATUS_REQUEST_V2_REQUEST_EXTENSION)); item.setRequestExtensions(parseByteArrayField(item.getRequestExtensionsLength().getValue())); int position = 0; List<ResponderId> resonderIds = new LinkedList<>(); while (position < item.getResponderIdListBytes().getValue().length) { ResponderIdParser parser = new ResponderIdParser(position, item.getResponderIdListBytes().getValue()); resonderIds.add(parser.parse()); if (position == parser.getPointer()) { throw new ParserException("Ran into infinite Loop while parsing ResponderId"); } position = parser.getPointer(); } item.setResponderIdList(resonderIds); return item; } RequestItemV2Parser(int startposition, byte[] array); @Override RequestItemV2 parse();  }
@Test public void testParser() { RequestItemV2Parser parser = new RequestItemV2Parser(startParsing, parsingBytes); RequestItemV2 item = parser.parse(); assertEquals(requestType, (long) item.getRequestType().getValue()); assertEquals(requestLength, (long) item.getRequestLength().getValue()); assertEquals(responderIdLength, (long) item.getResponderIdListLength().getValue()); assertArrayEquals(responderIdBytes, item.getResponderIdListBytes().getValue()); assertResponderIdList(responderIdList, item.getResponderIdList()); assertEquals(requestExtensionLength, (long) item.getRequestExtensionsLength().getValue()); assertArrayEquals(requestExtension, item.getRequestExtensions().getValue()); }