Source:
<code>public void shouldThrowAnExceptionWhenNumberOfPartitionsOfRepartitionOperationsDoNotMatchWhenJoining() { final String topicB = "topic-b"; final String outputTopic = "topic-output"; final String topicBRepartitionedName = "topic-b-scale-up"; final String inputTopicRepartitionedName = "input-topic-scale-up"; final int topicBNumberOfPartitions = 2; final int inputTopicNumberOfPartitions = 4; final StreamsBuilder builder = new StreamsBuilder(); final Repartitioned<Integer, String> inputTopicRepartitioned = Repartitioned .<Integer, String>as(inputTopicRepartitionedName) .withNumberOfPartitions(inputTopicNumberOfPartitions); final Repartitioned<Integer, String> topicBRepartitioned = Repartitioned .<Integer, String>as(topicBRepartitionedName) .withNumberOfPartitions(topicBNumberOfPartitions); final KStream<Integer, String> topicBStream = builder .stream(topicB, Consumed.with(Serdes.Integer(), Serdes.String())) .repartition(topicBRepartitioned); builder.stream(inputTopic, Consumed.with(Serdes.Integer(), Serdes.String())) .repartition(inputTopicRepartitioned) .join(topicBStream, (value1, value2) -> value2, JoinWindows.of(Duration.ofSeconds(10))) .to(outputTopic); final Map<String, Integer> repartitionTopicsWithNumOfPartitions = Utils.mkMap( Utils.mkEntry(toRepartitionTopicName(topicBRepartitionedName), topicBNumberOfPartitions), Utils.mkEntry(toRepartitionTopicName(inputTopicRepartitionedName), inputTopicNumberOfPartitions) ); try { builder.build(props); Assert.fail(); <START> } catch (final TopologyException t) { <END> final String expectedErrorMessage = String.format("Following topics do not have the same " + "number of partitions: [%s]", new TreeMap<>(repartitionTopicsWithNumOfPartitions)); assertNotNull(t); assertTrue(t.getMessage().contains(expectedErrorMessage)); } }</code><technical_language>use: final TopologyException expected = assertThrows( TopologyException.class, () -> builder.build(props) ); // put assertions</technical_language>

Target:
public void shouldThrowAnExceptionWhenNumberOfPartitionsOfRepartitionOperationsDoNotMatchWhenJoining() { final String topicB = "topic-b"; final String outputTopic = "topic-output"; final String topicBRepartitionedName = "topic-b-scale-up"; final String inputTopicRepartitionedName = "input-topic-scale-up"; final int topicBNumberOfPartitions = 2; final int inputTopicNumberOfPartitions = 4; final StreamsBuilder builder = new StreamsBuilder(); final Repartitioned<Integer, String> inputTopicRepartitioned = Repartitioned .<Integer, String>as(inputTopicRepartitionedName) .withNumberOfPartitions(inputTopicNumberOfPartitions); final Repartitioned<Integer, String> topicBRepartitioned = Repartitioned .<Integer, String>as(topicBRepartitionedName) .withNumberOfPartitions(topicBNumberOfPartitions); final KStream<Integer, String> topicBStream = builder .stream(topicB, Consumed.with(Serdes.Integer(), Serdes.String())) .repartition(topicBRepartitioned); builder.stream(inputTopic, Consumed.with(Serdes.Integer(), Serdes.String())) .repartition(inputTopicRepartitioned) .join(topicBStream, (value1, value2) -> value2, JoinWindows.of(Duration.ofSeconds(10))) .to(outputTopic); final Map<String, Integer> repartitionTopicsWithNumOfPartitions = Utils.mkMap( Utils.mkEntry(toRepartitionTopicName(topicBRepartitionedName), topicBNumberOfPartitions), Utils.mkEntry(toRepartitionTopicName(inputTopicRepartitionedName), inputTopicNumberOfPartitions) ); final TopologyException expected = assertThrows( TopologyException.class, () -> builder.build(props) ); final String expectedErrorMessage = String.format("Following topics do not have the same " + "number of partitions: [%s]", new TreeMap<>(repartitionTopicsWithNumOfPartitions)); assertNotNull(expected); assertTrue(expected.getMessage().contains(expectedErrorMessage)); }