@Test
    public void testGetTopicPartitionStreamRelation() {
        Uuid topicId = Uuid.randomUuid();
        S3StreamsMetadataImage image = S3StreamsMetadataImage.EMPTY;
        S3StreamsMetadataDelta delta = new S3StreamsMetadataDelta(image);

        S3StreamRecord.TagCollection tags = new S3StreamRecord.TagCollection();
        tags.add(new S3StreamRecord.Tag().setKey(StreamTags.Topic.KEY).setValue(StreamTags.Topic.encode(topicId)));
        tags.add(new S3StreamRecord.Tag().setKey(StreamTags.Partition.KEY).setValue(StreamTags.Partition.encode(10)));
        delta.replay(new S3StreamRecord().setStreamId(STREAM0).setTags(tags));

        tags = new S3StreamRecord.TagCollection();
        tags.add(new S3StreamRecord.Tag().setKey(StreamTags.Topic.KEY).setValue(StreamTags.Topic.encode(topicId)));
        tags.add(new S3StreamRecord.Tag().setKey(StreamTags.Partition.KEY).setValue(StreamTags.Partition.encode(11)));
        delta.replay(new S3StreamRecord().setStreamId(STREAM1).setTags(tags));
        delta.replay(new RemoveS3StreamRecord().setStreamId(STREAM1));

        image = delta.apply();

        {
            Set<Long> streams = image.getTopicPartitionStreams(topicId, 10);
            assertEquals(Set.of(STREAM0), streams);

            streams = image.getTopicPartitionStreams(topicId, 11);
            assertTrue(streams.isEmpty());
        }

        {
            TopicIdPartition tp = image.getStreamTopicPartition(STREAM0);
            assertEquals(topicId, tp.topicId());
            assertEquals(10, tp.partition());

            tp = image.getStreamTopicPartition(STREAM1);
            assertNull(tp);
        }

        delta = new S3StreamsMetadataDelta(image);

        tags = new S3StreamRecord.TagCollection();
        tags.add(new S3StreamRecord.Tag().setKey(StreamTags.Topic.KEY).setValue(StreamTags.Topic.encode(topicId)));
        tags.add(new S3StreamRecord.Tag().setKey(StreamTags.Partition.KEY).setValue(StreamTags.Partition.encode(10)));
        delta.replay(new S3StreamRecord().setStreamId(STREAM2).setTags(tags));

        image = delta.apply();
        {
            Set<Long> streams = image.getTopicPartitionStreams(topicId, 10);
            assertEquals(Set.of(STREAM0, STREAM2), streams);
            TopicIdPartition tp = image.getStreamTopicPartition(STREAM2);
            assertEquals(topicId, tp.topicId());
            assertEquals(10, tp.partition());
        }

        delta = new S3StreamsMetadataDelta(image);
        delta.replay(new RemoveS3StreamRecord().setStreamId(STREAM0));

        image = delta.apply();
        {
            Set<Long> streams = image.getTopicPartitionStreams(topicId, 10);
            assertEquals(Set.of(STREAM2), streams);
            TopicIdPartition tp = image.getStreamTopicPartition(STREAM0);
            assertNull(tp);
        }
    }
Test get objects with the first hit object is a stream set object.
metadata/src/test/java/org/apache/kafka/image/S3StreamsMetadataImageTest.java