Source:
<code>public void testGetStateForMultipleTasks() throws Exception { <START> String yummyTopic = "YummyPizza"; <END> String saltyTopic = "SaltyPizza"; String saladTopic = "HealthySalad"; createTopic(_zkUtils, saladTopic); createTopic(_zkUtils, yummyTopic); createTopic(_zkUtils, saltyTopic); Datastream datastream = KafkaMirrorMakerConnectorTestUtils.createDatastream("pizzaStream", _broker, "\\w+Pizza"); List<DatastreamTask> tasks = ImmutableList.of(new DatastreamTaskImpl(Collections.singletonList(datastream)), new DatastreamTaskImpl(Collections.singletonList(datastream)), new DatastreamTaskImpl(Collections.singletonList(datastream))); MockDatastreamEventProducer datastreamProducer = new MockDatastreamEventProducer(); tasks.forEach(t -> ((DatastreamTaskImpl) t).setEventProducer(datastreamProducer)); KafkaMirrorMakerConnector connector = new KafkaMirrorMakerConnector("MirrorMakerConnector", getDefaultConfig(Optional.empty()), "testCluster"); connector.start(null); connector.onAssignmentChange(tasks); boolean pollResult = PollUtils.poll(() -> { String jsonStr = connector.process("/datastream_state?datastream=pizzaStream"); KafkaDatastreamStatesResponse response = KafkaDatastreamStatesResponse.fromJson(jsonStr); return response.getAssignedTopicPartitions().equals(ImmutableSet.of(new TopicPartition("SaltyPizza", 0), new TopicPartition("YummyPizza", 0))); }, POLL_PERIOD_MS, POLL_TIMEOUT_MS); Assert.assertTrue(pollResult); connector.stop(); }</code><technical_language>nit: store strings in array reduce repetition: java String[] topics = {"YummyPizza", "SaltyPizza", "HealthySalad"}; Arrays.stream(topics).forEach(t -> createTopic(_zkUtils, t)); in a list java List<String> topics = Arrays.asList("YummyPizza", "SaltyPizza", "HealthySalad"); topics.forEach(t -> createTopic(_zkUtils, t));</technical_language>

Target:
public void testGetStateForMultipleTasks() throws Exception { List<String> topics = Arrays.asList("YummyPizza", "SaltyPizza", "HealthySalad"); topics.forEach(t -> createTopic(_zkUtils, t)); Datastream datastream = KafkaMirrorMakerConnectorTestUtils.createDatastream("pizzaStream", _broker, "\\w+Pizza"); List<DatastreamTask> tasks = ImmutableList.of(new DatastreamTaskImpl(Collections.singletonList(datastream)), new DatastreamTaskImpl(Collections.singletonList(datastream)), new DatastreamTaskImpl(Collections.singletonList(datastream))); MockDatastreamEventProducer datastreamProducer = new MockDatastreamEventProducer(); tasks.forEach(t -> ((DatastreamTaskImpl) t).setEventProducer(datastreamProducer)); KafkaMirrorMakerConnector connector = new KafkaMirrorMakerConnector("MirrorMakerConnector", getDefaultConfig(Optional.empty()), "testCluster"); connector.start(null); connector.onAssignmentChange(tasks); boolean hasExpectedTopicPartitions = PollUtils.poll(() -> { String jsonStr = connector.process("/datastream_state?datastream=pizzaStream"); KafkaDatastreamStatesResponse response = KafkaDatastreamStatesResponse.fromJson(jsonStr); return response.getAssignedTopicPartitions().equals(ImmutableSet.of(new TopicPartition("SaltyPizza", 0), new TopicPartition("YummyPizza", 0))); }, POLL_PERIOD_MS, POLL_TIMEOUT_MS); Assert.assertTrue(hasExpectedTopicPartitions); connector.stop(); }