### Question:
TlsCertificateAuthorityClientCommandLine extends BaseCertificateAuthorityCommandLine { public TlsClientConfig createClientConfig() throws IOException { String configJsonIn = getConfigJsonIn(); if (!StringUtils.isEmpty(configJsonIn)) { try (InputStream inputStream = inputStreamFactory.create(new File(configJsonIn))) { TlsClientConfig tlsClientConfig = new ObjectMapper().readValue(inputStream, TlsClientConfig.class); tlsClientConfig.initDefaults(); return tlsClientConfig; } } else { TlsClientConfig tlsClientConfig = new TlsClientConfig(); tlsClientConfig.setCaHostname(getCertificateAuthorityHostname()); tlsClientConfig.setDn(getDn()); tlsClientConfig.setDomainAlternativeNames(getDomainAlternativeNames()); tlsClientConfig.setToken(getToken()); tlsClientConfig.setPort(getPort()); tlsClientConfig.setKeyStore(KEYSTORE + getKeyStoreType().toLowerCase()); tlsClientConfig.setKeyStoreType(getKeyStoreType()); tlsClientConfig.setTrustStore(TRUSTSTORE + tlsClientConfig.getTrustStoreType().toLowerCase()); tlsClientConfig.setKeySize(getKeySize()); tlsClientConfig.setKeyPairAlgorithm(getKeyAlgorithm()); tlsClientConfig.setSigningAlgorithm(getSigningAlgorithm()); return tlsClientConfig; } } TlsCertificateAuthorityClientCommandLine();  TlsCertificateAuthorityClientCommandLine(InputStreamFactory inputStreamFactory); static void main(String[] args); String getCertificateDirectory(); String getDomainAlternativeNames(); TlsClientConfig createClientConfig(); static final String DESCRIPTION; static final String CERTIFICATE_DIRECTORY; static final String SUBJECT_ALTERNATIVE_NAMES; static final String DEFAULT_CERTIFICATE_DIRECTORY; }### Answer:
@Test public void testCaHostname() throws CommandLineParseException, IOException { String testCaHostname = "testCaHostname"; tlsCertificateAuthorityClientCommandLine.parse("-t", testToken, "-c", testCaHostname); assertEquals(testCaHostname, tlsCertificateAuthorityClientCommandLine.createClientConfig().getCaHostname()); }
@Test public void testDn() throws CommandLineParseException, IOException { String testDn = "testDn"; tlsCertificateAuthorityClientCommandLine.parse("-t", testToken, "-D", testDn); assertEquals(testDn, tlsCertificateAuthorityClientCommandLine.createClientConfig().getDn()); }
@Test public void testPort() throws CommandLineParseException, IOException { int testPort = 2345; tlsCertificateAuthorityClientCommandLine.parse("-t", testToken, "-p", Integer.toString(testPort)); assertEquals(testPort, tlsCertificateAuthorityClientCommandLine.createClientConfig().getPort()); }
@Test public void testKeyStoreType() throws CommandLineParseException, IOException { String testType = "testType"; tlsCertificateAuthorityClientCommandLine.parse("-t", testToken, "-T", testType); TlsClientConfig clientConfig = tlsCertificateAuthorityClientCommandLine.createClientConfig(); assertEquals(testType, clientConfig.getKeyStoreType()); String trustStoreType = KeystoreType.JKS.toString().toLowerCase(); assertEquals(trustStoreType, clientConfig.getTrustStoreType()); assertEquals(TlsCertificateAuthorityClientCommandLine.KEYSTORE + testType.toLowerCase(), clientConfig.getKeyStore()); assertEquals(TlsCertificateAuthorityClientCommandLine.TRUSTSTORE + trustStoreType, clientConfig.getTrustStore()); }