### Question:
KafkaAdminClient implements Closeable { public int getTopicReplicationFactor(String topic) { if (StringUtils.isBlank(topic)) throw new IllegalArgumentException("topic cannot be null, empty or blank"); LOG.debug("Getting replication factor for topic [{}]", topic); Collection<TopicDescription> topicDescription = getTopicDescriptions(Collections.singleton(topic)); if (topicDescription.isEmpty()) { throw new AdminOperationException("Unable to get description for topic: " + topic); } List<TopicPartitionInfo> topicPartitions = topicDescription.iterator().next().partitions(); if (topicPartitions.isEmpty()) { throw new AdminOperationException("Unable to get partitions for topic: " + topic); } return topicPartitions.get(0).replicas().size(); } KafkaAdminClient(Properties properties); Set<String> getTopics(); Set<TopicAndPartition> getPartitions(); Set<TopicAndPartition> getPartitions(String topic); Authorizer getAuthorizer(); Map<Resource, Set<Acl>> getAcls(); Map<Resource, Set<Acl>> getAcls(KafkaPrincipal principal); Set<Acl> getAcls(Resource resource); void addAcls(Set<Acl> acls, Resource resource); void removeAcls(Set<Acl> acls, Resource resource); void createTopic(String topic, int partitions, int replicationFactor); void createTopic(String topic, int partitions, int replicationFactor, Properties topicConfig); void deleteTopic(String topic); Properties getTopicConfig(String topic); void updateTopicConfig(String topic, Properties properties); int getTopicReplicationFactor(String topic); int getTopicPartitions(String topic); void addTopicPartitions(String topic, int partitions); AdminClient.ConsumerGroupSummary getConsumerGroupSummary(String consumerGroup); Collection<AdminClient.ConsumerSummary> getConsumerGroupSummaries(String consumerGroup); Map<TopicPartition, String> getConsumerGroupAssignments(String consumerGroup); @Override void close(); static final String ZOOKEEPER_SECURE; static final String DEFAULT_ZOOKEEPER_SECURE; static final String OPERATION_TIMEOUT_MS; static final String DEFAULT_OPERATION_TIMEOUT_MS; static final String OPERATION_SLEEP_MS; static final String DEFAULT_OPERATION_SLEEP_MS; }### Answer:
@Test (expected = IllegalArgumentException.class) public void getTopicReplicationFactor_nullTopic() { client.getTopicReplicationFactor(null); }
@Test (expected = IllegalArgumentException.class) public void getTopicReplicationFactor_emptyTopic() { client.getTopicReplicationFactor(""); }
@Test (expected = IllegalArgumentException.class) public void getTopicReplicationFactor_blankTopic() { client.getTopicReplicationFactor(" "); }
@Test public void getTopicReplicationFactor() { client.createTopic(topic, 1, 1); assertThat(client.getTopicReplicationFactor(topic), is(1)); }