### Question:
ScramCredentialUtils { public static void createCache(CredentialCache cache, Collection<String> enabledMechanisms) { for (String mechanism : ScramMechanism.mechanismNames()) { if (enabledMechanisms.contains(mechanism)) cache.createCache(mechanism, ScramCredential.class); } }  static String credentialToString(ScramCredential credential); static ScramCredential credentialFromString(String str); static void createCache(CredentialCache cache, Collection<String> enabledMechanisms);  }### Answer:
@Test public void scramCredentialCache() throws Exception { CredentialCache cache = new CredentialCache(); ScramCredentialUtils.createCache(cache, Arrays.asList("SCRAM-SHA-512", "PLAIN")); assertNotNull("Cache not created for enabled mechanism", cache.cache(ScramMechanism.SCRAM_SHA_512.mechanismName(), ScramCredential.class)); assertNull("Cache created for disabled mechanism", cache.cache(ScramMechanism.SCRAM_SHA_256.mechanismName(), ScramCredential.class)); CredentialCache.Cache<ScramCredential> sha512Cache = cache.cache(ScramMechanism.SCRAM_SHA_512.mechanismName(), ScramCredential.class); ScramFormatter formatter = new ScramFormatter(ScramMechanism.SCRAM_SHA_512); ScramCredential credentialA = formatter.generateCredential("password", 4096); sha512Cache.put("userA", credentialA); assertEquals(credentialA, sha512Cache.get("userA")); assertNull("Invalid user credential", sha512Cache.get("userB")); }