@Test
    public void testReadWriteSnapshot() throws IOException {
        Map<Long, ProducerStateEntry> expectedEntryMap = new HashMap<>();
        expectedEntryMap.put(1L, new ProducerStateEntry(1L, (short) 2, 3,
                RecordBatch.NO_TIMESTAMP,
                OptionalLong.of(100L),
                Optional.of(new BatchMetadata(1, 2L, 3, RecordBatch.NO_TIMESTAMP))));
        expectedEntryMap.put(11L, new ProducerStateEntry(11L, (short) 12, 13,
                123456L,
                OptionalLong.empty(),
                Optional.empty()));

        File file = new File(logDir, "testReadWriteSnapshot");
        ProducerStateManager.writeSnapshot(file, expectedEntryMap, true);
        assertEntries(expectedEntryMap, ProducerStateManager.readSnapshot0(file, null));
    }
Test that marking a snapshot for deletion when the file has already been deleted
returns None instead of the SnapshotFile. The snapshot file should be removed from
the in-memory state of the ProducerStateManager. This scenario can occur during log
recovery when the intermediate ProducerStateManager instance deletes a file without
updating the state of the "real" ProducerStateManager instance which is passed to the Log.
storage/src/test/java/org/apache/kafka/storage/internals/log/ProducerStateManagerTest.java