### Question:
TomlConfigFactory { KeyDataBuilder createKeyDataBuilder(InputStream configData) { final Toml toml = new Toml().read(configData); final List<String> publicKeyList = toml.getList("publickeys", emptyList()); final List<String> privateKeyList = toml.getList("privatekeys", emptyList()); final String pwd = toml.getString("passwords"); final String workdir = toml.getString("workdir"); return KeyDataBuilder.create() .withPublicKeys(publicKeyList) .withPrivateKeys(privateKeyList) .withPrivateKeyPasswordFile(pwd) .withWorkingDirectory(workdir); }  ConfigBuilder create(InputStream configData, ArgonOptions options, String... filenames);  }### Answer:
@Test public void ifPublicAndPrivateKeyListAreEmptyThenKeyConfigurationIsAllNulls() throws IOException { try (InputStream configData = getClass().getResourceAsStream("/sample-no-keys.conf")) { KeyConfiguration result = tomlConfigFactory.createKeyDataBuilder(configData).build(); assertThat(result).isNotNull(); KeyConfiguration expected = new KeyConfiguration(null, null, Collections.emptyList(), null, null); assertThat(result).isEqualTo(expected); } }
@Test public void ifPublicKeyListIsEmptyThenKeyConfigurationIsAllNulls() throws IOException { try (InputStream configData = getClass().getResourceAsStream("/sample-with-only-private-keys.conf")) { final Throwable throwable = catchThrowable(() -> tomlConfigFactory.createKeyDataBuilder(configData).build()); assertThat(throwable).isInstanceOf(ConfigException.class).hasCauseExactlyInstanceOf(RuntimeException.class); assertThat(throwable.getCause()).hasMessage("Different amount of public and private keys supplied"); } }
@Test public void ifPrivateKeyListIsEmptyThenKeyConfigurationIsAllNulls() throws IOException { try (InputStream configData = getClass().getResourceAsStream("/sample-with-only-public-keys.conf")) { final Throwable throwable = catchThrowable(() -> tomlConfigFactory.createKeyDataBuilder(configData).build()); assertThat(throwable).isInstanceOf(ConfigException.class).hasCauseExactlyInstanceOf(RuntimeException.class); assertThat(throwable.getCause()).hasMessage("Different amount of public and private keys supplied"); } }