PersistentSHA256Checksums implements PersistentStateComponent<PersistentSHA256Checksums> { public void storeChecksum(@NotNull String distribution, @NotNull String checksum) { if (myStoredChecksums == null) { myStoredChecksums = new HashMap<>(); } myStoredChecksums.put(distribution, checksum); }  static PersistentSHA256Checksums getInstance(); @Override PersistentSHA256Checksums getState(); @Override void loadState(@NotNull PersistentSHA256Checksums state); boolean isChecksumStored(@Nullable String distribution, @Nullable String checksum); void storeChecksum(@NotNull String distribution, @NotNull String checksum); public HashMap<String, String> myStoredChecksums; }
@Test public void testChecksumStored() { String DISTRIBUTION_OTHER = "https: String SHA256_OTHER = "NOT_VALID_SHA256"; PersistentSHA256Checksums checksums = new PersistentSHA256Checksums(); assertThat(checksums.myStoredChecksums == null || checksums.myStoredChecksums.isEmpty()).isTrue(); verifyStored(checksums, false); checksums.storeChecksum(DISTRIBUTION_OTHER, SHA256); assertThat(checksums.myStoredChecksums).hasSize(1); verifyStored(checksums, false); checksums.storeChecksum(DISTRIBUTION, SHA256_OTHER); assertThat(checksums.myStoredChecksums).hasSize(2); verifyStored(checksums, false); checksums.storeChecksum(DISTRIBUTION, SHA256); assertThat(checksums.myStoredChecksums).hasSize(2); verifyStored(checksums, true); }