@Test
public void testSerialization() throws Exception {
checkRequest(createFindCoordinatorRequest(0));
checkRequest(createFindCoordinatorRequest(1));
checkErrorResponse(createFindCoordinatorRequest(0), new UnknownServerException());
checkErrorResponse(createFindCoordinatorRequest(1), new UnknownServerException());
checkResponse(createFindCoordinatorResponse(), 0);
checkResponse(createFindCoordinatorResponse(), 1);
checkRequest(createControlledShutdownRequest());
checkResponse(createControlledShutdownResponse(), 1);
checkErrorResponse(createControlledShutdownRequest(), new UnknownServerException());
checkErrorResponse(createControlledShutdownRequest(0), new UnknownServerException());
checkRequest(createFetchRequest(4));
checkResponse(createFetchResponse(), 4);
List<TopicPartition> toForgetTopics = new ArrayList<>();
toForgetTopics.add(new TopicPartition("foo", 2));
toForgetTopics.add(new TopicPartition("bar", 0));
checkRequest(createFetchRequest(7, new FetchMetadata(123, 456), toForgetTopics));
checkResponse(createFetchResponse(123), 7);
checkResponse(createFetchResponse(Errors.FETCH_SESSION_ID_NOT_FOUND, 123), 7);
checkErrorResponse(createFetchRequest(4), new UnknownServerException());
checkRequest(createHeartBeatRequest());
checkErrorResponse(createHeartBeatRequest(), new UnknownServerException());
checkResponse(createHeartBeatResponse(), 0);
checkRequest(createJoinGroupRequest(1));
checkErrorResponse(createJoinGroupRequest(0), new UnknownServerException());
checkErrorResponse(createJoinGroupRequest(1), new UnknownServerException());
checkResponse(createJoinGroupResponse(), 0);
checkRequest(createLeaveGroupRequest());