public void record(Uuid topicId) {
        // Topic IDs should not differ, but we defensively check here to fail earlier in the case that the IDs somehow differ.
        dirtyTopicIdOpt.ifPresent(dirtyTopicId -> {
            if (!dirtyTopicId.equals(topicId)) {
                throw new InconsistentTopicIdException("Tried to record topic ID " + topicId + " to file " +
                        "but had already recorded " + dirtyTopicId);
            }
        });
        dirtyTopicIdOpt = Optional.of(topicId);
    }
@Test
    public void testSetRecordWithDifferentTopicId() {
        PartitionMetadataFile partitionMetadataFile = new PartitionMetadataFile(file, null);
        Uuid topicId = Uuid.randomUuid();
        partitionMetadataFile.record(topicId);
        Uuid differentTopicId = Uuid.randomUuid();
        assertThrows(InconsistentTopicIdException.class, () -> partitionMetadataFile.record(differentTopicId));
    }