### Question:
HprofReader { @Nonnull public ClassDefinition readLoadClassRecord() throws IOException { int serialNumber = readInt(in); ID classObjectId = readID(in); int stackTraceSerial = readInt(in); ID classNameStringId = readID(in); ClassDefinition cls = new ClassDefinition(); cls.setSerialNumber(serialNumber); cls.setObjectId(classObjectId); cls.setStackTraceSerial(stackTraceSerial); cls.setNameStringId(classNameStringId); return cls; } HprofReader(@Nonnull InputStream in, @Nonnull HprofProcessor processor); boolean hasNext(); void next(); @Nonnull InputStream getInputStream(); @Nonnull ClassDefinition readLoadClassRecord(); @Nonnull HprofString readStringRecord(int recordLength, int timestamp); StackFrame readStackFrame();  }### Answer:
@Test public void readLoadClassRecord() throws IOException { ClassDefinition cls = new ClassDefinition(); cls.setSerialNumber(SERIAL); cls.setObjectId(new ID(OBJECT_ID)); cls.setStackTraceSerial(STACK_SERIAL); cls.setNameStringId(new ID(NAME_ID)); writer.writeLoadClassRecord(cls); final AtomicBoolean called = new AtomicBoolean(false); HprofProcessor processor = new DiscardProcessor() { @Override public void onRecord(int tag, int timestamp, int length, @Nonnull HprofReader reader) throws IOException { called.set(true); ClassDefinition readCls = reader.readLoadClassRecord(); assertEquals(SERIAL, readCls.getSerialNumber()); assertEquals(new ID(OBJECT_ID), readCls.getObjectId()); assertEquals(STACK_SERIAL, readCls.getStackTraceSerial()); assertEquals(new ID(NAME_ID), readCls.getNameStringId()); } }; HprofReader reader = new HprofReader(new ByteArrayInputStream(buffer.toByteArray()), processor); while (reader.hasNext()) { reader.next(); } assertTrue(called.get()); }