Source:
public void setUp() { super.setUp(); String uniqueTestId = UUID.randomUUID().toString(); testStreamAppName = String.format("test-app-name-%s", uniqueTestId); testStreamAppId = String.format("test-app-id-%s", uniqueTestId); inputKafkaTopic = String.format("test-input-topic-%s", uniqueTestId); outputKafkaTopic = String.format("test-output-topic-%s", uniqueTestId); inputSinglePartitionKafkaTopic = String.format("test-input-single-partition-topic-%s", uniqueTestId); outputSinglePartitionKafkaTopic = String.format("test-output-single-partition-topic-%s", uniqueTestId); Map<String, String> configMap = buildStreamApplicationConfigMap(ImmutableList.of(inputKafkaTopic), testStreamAppName, testStreamAppId); configMap.put(JobConfig.PROCESSOR_ID(), PROCESSOR_IDS[0]); applicationConfig1 = new ApplicationConfig(new MapConfig(configMap)); configMap.put(JobConfig.PROCESSOR_ID(), PROCESSOR_IDS[1]); applicationConfig2 = new ApplicationConfig(new MapConfig(configMap)); configMap.put(JobConfig.PROCESSOR_ID(), PROCESSOR_IDS[2]); applicationConfig3 = new ApplicationConfig(new MapConfig(configMap)); ZkClient zkClient = new ZkClient(zkConnect(), ZK_CONNECTION_TIMEOUT_MS, ZK_CONNECTION_TIMEOUT_MS, new ZkStringSerializer()); ZkKeyBuilder zkKeyBuilder = new ZkKeyBuilder(ZkJobCoordinatorFactory.getJobCoordinationZkPath(applicationConfig1)); zkUtils = new ZkUtils(zkKeyBuilder, zkClient, ZK_CONNECTION_TIMEOUT_MS, ZK_SESSION_TIMEOUT_MS, new NoOpMetricsRegistry()); zkUtils.connect(); List<NewTopic> newTopics = ImmutableList.of(inputKafkaTopic, outputKafkaTopic, inputSinglePartitionKafkaTopic, outputSinglePartitionKafkaTopic) .stream() .map(topic -> new NewTopic(topic, 5, (short) 1)) .collect(Collectors.toList()); createTopics(newTopics); }

Target:
public void setUp() { super.setUp(); String uniqueTestId = UUID.randomUUID().toString(); testStreamAppName = String.format("test-app-name-%s", uniqueTestId); testStreamAppId = String.format("test-app-id-%s", uniqueTestId); inputKafkaTopic = String.format("test-input-topic-%s", uniqueTestId); outputKafkaTopic = String.format("test-output-topic-%s", uniqueTestId); inputSinglePartitionKafkaTopic = String.format("test-input-single-partition-topic-%s", uniqueTestId); outputSinglePartitionKafkaTopic = String.format("test-output-single-partition-topic-%s", uniqueTestId); Map<String, String> configMap = buildStreamApplicationConfigMap(ImmutableList.of(inputKafkaTopic), testStreamAppName, testStreamAppId); configMap.put(JobConfig.PROCESSOR_ID(), PROCESSOR_IDS[0]); applicationConfig1 = new ApplicationConfig(new MapConfig(configMap)); configMap.put(JobConfig.PROCESSOR_ID(), PROCESSOR_IDS[1]); applicationConfig2 = new ApplicationConfig(new MapConfig(configMap)); configMap.put(JobConfig.PROCESSOR_ID(), PROCESSOR_IDS[2]); applicationConfig3 = new ApplicationConfig(new MapConfig(configMap)); ZkClient zkClient = new ZkClient(zkConnect(), ZK_CONNECTION_TIMEOUT_MS, ZK_CONNECTION_TIMEOUT_MS, new ZkStringSerializer()); ZkKeyBuilder zkKeyBuilder = new ZkKeyBuilder(ZkJobCoordinatorFactory.getJobCoordinationZkPath(applicationConfig1)); zkUtils = new ZkUtils(zkKeyBuilder, zkClient, ZK_CONNECTION_TIMEOUT_MS, ZK_SESSION_TIMEOUT_MS, new NoOpMetricsRegistry()); zkUtils.connect(); List<NewTopic> newTopics = ImmutableList.of(inputKafkaTopic, outputKafkaTopic, inputSinglePartitionKafkaTopic, outputSinglePartitionKafkaTopic) .stream() .map(topic -> new NewTopic(topic, 5, (short) 1)) .collect(Collectors.toList()); assertTrue("Encountered errors during test setup. Failed to create topics.", createTopics(newTopics)); }