### Question:
KeyStoreHelper implements Closeable { public static KeyStoreHelper create(@NonNull final KeyStoreOptions options) throws SocketEndpointAddressException, KeyStoreHelperException, KeyStoreException { if (options.keyStorePath.equals(options.trustStorePath)) { throw new KeyStoreHelperException("KeyStore and TrustStore should use different files"); } if (options.keyStoreType == null) { options.keyStoreType = KeyStoreType.getDefaultType(); } if (StringUtils.isBlank(options.keyAlias)) { options.keyAlias = DEFAULT_ALIAS; } val keyStore = createKeyStore(options, options.keyStorePath, options.keyStorePass); val trustStore = createKeyStore(options, options.trustStorePath, options.trustStorePass); if (options.workloadApiClient == null) { options.workloadApiClient = createNewClient(options.spiffeSocketPath); } return new KeyStoreHelper(keyStore, trustStore, options.keyPass, options.keyAlias, options.workloadApiClient); } private  KeyStoreHelper(KeyStore keyStore, KeyStore trustStore, String keyPass, String keyAlias, WorkloadApiClient workloadApiClient); static KeyStoreHelper create(@NonNull final KeyStoreOptions options); void run(boolean keepRunning); @SneakyThrows @Override void close();  }### Answer:
@Test void testCreateHelper_keyStore_trustStore_same_file_throwsException() throws SocketEndpointAddressException { val keyStorefileName = RandomStringUtils.randomAlphabetic(10); keyStoreFilePath = Paths.get(keyStorefileName); val trustStorePass = "truststore123"; val keyStorePass = "keystore123"; val keyPass = "keypass123"; val alias = "other_alias"; final KeyStoreHelper.KeyStoreOptions options = KeyStoreHelper.KeyStoreOptions .builder() .keyStorePath(keyStoreFilePath) .keyStorePass(keyStorePass) .trustStorePath(keyStoreFilePath) .trustStorePass(trustStorePass) .keyPass(keyPass) .keyAlias(alias) .workloadApiClient(workloadApiClient) .build(); try { KeyStoreHelper.create(options); fail("expected exception: KeyStore and TrustStore should use different files"); } catch (KeyStoreHelperException e) { assertEquals("KeyStore and TrustStore should use different files", e.getMessage()); } catch (KeyStoreException e) { fail(e); } }
@Test void testCreateKeyStoreHelper_createNewClient() throws Exception { TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test"); val options = getKeyStoreValidOptions(null); try { KeyStoreHelper.create(options); } catch (KeyStoreHelperException e) { fail(); } }
@Test void testCreateKeyStoreHelper_nullParameter() { try { KeyStoreHelper.create(null); } catch (NullPointerException e) { assertEquals("options is marked non-null but is null", e.getMessage()); } catch (SocketEndpointAddressException | KeyStoreHelperException | KeyStoreException e) { fail(); } }