use of org.apache.kafka.common.requests.CreateTopicsRequest.Builder in project kafka by apache.
the class RequestResponseTest method cannotUseFindCoordinatorV0ToFindTransactionCoordinator.
@Test
public void cannotUseFindCoordinatorV0ToFindTransactionCoordinator() {
FindCoordinatorRequest.Builder builder = new FindCoordinatorRequest.Builder(new FindCoordinatorRequestData().setKeyType(CoordinatorType.TRANSACTION.id).setKey("foobar"));
assertThrows(UnsupportedVersionException.class, () -> builder.build((short) 0));
}
use of org.apache.kafka.common.requests.CreateTopicsRequest.Builder in project kafka by apache.
the class RequestResponseTest method testCreateTopicRequestV3FailsIfNoPartitionsOrReplicas.
@Test
public void testCreateTopicRequestV3FailsIfNoPartitionsOrReplicas() {
final UnsupportedVersionException exception = assertThrows(UnsupportedVersionException.class, () -> {
CreateTopicsRequestData data = new CreateTopicsRequestData().setTimeoutMs(123).setValidateOnly(false);
data.topics().add(new CreatableTopic().setName("foo").setNumPartitions(CreateTopicsRequest.NO_NUM_PARTITIONS).setReplicationFactor((short) 1));
data.topics().add(new CreatableTopic().setName("bar").setNumPartitions(1).setReplicationFactor(CreateTopicsRequest.NO_REPLICATION_FACTOR));
new Builder(data).build((short) 3);
});
assertTrue(exception.getMessage().contains("supported in CreateTopicRequest version 4+"));
assertTrue(exception.getMessage().contains("[foo, bar]"));
}
Aggregations