@ParameterizedTest
    @ValueSource(booleans = {true, false})
    public void testSelfJoin(final boolean cacheEnabled) {
        final StreamsBuilder builder = new StreamsBuilder();
        final KStream<Long, String> leftStream = builder.stream(INPUT_TOPIC_LEFT);
        final Properties streamsConfig = setupConfigsAndUtils(cacheEnabled);
        streamsConfig.put(StreamsConfig.APPLICATION_ID_CONFIG, APP_ID + "-selfJoin");
        streamsConfig.put(StreamsConfig.TOPOLOGY_OPTIMIZATION_CONFIG, StreamsConfig.OPTIMIZE);

        final List<List<TestRecord<Long, String>>> expectedResult = Arrays.asList(
            null,
            Collections.singletonList(new TestRecord<>(ANY_UNIQUE_KEY, "A-A", null, 2L)),
            Arrays.asList(
                new TestRecord<>(ANY_UNIQUE_KEY, "B-A", null, 3L),
                new TestRecord<>(ANY_UNIQUE_KEY, "A-B", null, 3L),
                new TestRecord<>(ANY_UNIQUE_KEY, "B-B", null, 3L)),
            null,
            Arrays.asList(
                new TestRecord<>(ANY_UNIQUE_KEY, "C-A", null, 5L),
                new TestRecord<>(ANY_UNIQUE_KEY, "C-B", null, 5L),
                new TestRecord<>(ANY_UNIQUE_KEY, "A-C", null, 5L),
                new TestRecord<>(ANY_UNIQUE_KEY, "B-C", null, 5L),
                new TestRecord<>(ANY_UNIQUE_KEY, "C-C", null, 5L)),
            null,
            Arrays.asList(
                new TestRecord<>(ANY_UNIQUE_KEY, "D-A", null, 7L),
                new TestRecord<>(ANY_UNIQUE_KEY, "D-B", null, 7L),
                new TestRecord<>(ANY_UNIQUE_KEY, "D-C", null, 7L),
                new TestRecord<>(ANY_UNIQUE_KEY, "A-D", null, 7L),
                new TestRecord<>(ANY_UNIQUE_KEY, "B-D", null, 7L),
                new TestRecord<>(ANY_UNIQUE_KEY, "C-D", null, 7L),
                new TestRecord<>(ANY_UNIQUE_KEY, "D-D", null, 7L))
        );

        leftStream.join(
            leftStream,
            valueJoiner,
            JoinWindows.ofTimeDifferenceAndGrace(ofSeconds(10), ofHours(24))
        ).to(OUTPUT_TOPIC);

        runSelfJoinTestWithDriver(expectedResult, streamsConfig, builder.build(streamsConfig));
    }
Tests all available joins of Kafka Streams DSL.
streams/src/test/java/org/apache/kafka/streams/integration/StreamStreamJoinIntegrationTest.java