### Question:
KeyManagerHeaplet extends GenericHeaplet { @Override public Object create() throws HeapException { JsonValue storeRef = config.get("keystore").required(); KeyStore keyStore = heap.resolve(storeRef, KeyStore.class); String password = evaluate(config.get("password").required()); String algorithm = config.get("alg").defaultTo(KeyManagerFactory.getDefaultAlgorithm()).asString(); KeyManagerFactory factory; try { factory = KeyManagerFactory.getInstance(algorithm); factory.init(keyStore, password.toCharArray()); } catch (Exception e) { throw new HeapException(loadingError(algorithm, storeRef), e); } KeyManager[] managers = factory.getKeyManagers(); if (managers.length == 1) { return managers[0]; } else if (managers.length > 1) { logger.warning("Only the first KeyManager will be selected"); return managers[0]; } throw new HeapException(loadingError(algorithm, storeRef)); }  @Override Object create();  }### Answer:
@Test public void shouldLoadKeyManagerFactoryWithDefaultAlgorithm() throws Exception { HeapImpl heap = new HeapImpl(Name.of("anonymous")); heap.put("KeyStore", loadKeyStore("jks", "/x509cert-keystore.jks", "changeit")); JsonValue config = json(object( field("keystore", "KeyStore"), field("password", "changeit") )); KeyManagerHeaplet heaplet = new KeyManagerHeaplet(); X509KeyManager manager = (X509KeyManager) heaplet.create(Name.of(OBJECT_NAME), config, heap); assertThat(manager.getPrivateKey("cert")).isNotNull(); assertThat(manager.getPrivateKey("cert").getFormat()).isEqualTo("PKCS#8"); assertThat(manager.getCertificateChain("cert")).hasSize(1); }