@Test public void fileContainsValidArgonJsonConfig() throws Exception { final String algorithm = "id"; final Integer iterations = 10; final Integer memory = 10; final Integer parallelism = 10; final String config = String.format( "{\"variant\": \"%s\", \"iterations\":%s, \"memory\":%s, \"parallelism\":%s}", algorithm, iterations, memory, parallelism); final Path argonPath = Files.createTempFile(UUID.randomUUID().toString(), ""); argonPath.toFile().deleteOnExit(); Files.write(argonPath, config.getBytes()); final ArgonOptions result = argonOptionsConverter.convert(argonPath.toString()); final ArgonOptions expected = new ArgonOptions(); expected.setAlgorithm(algorithm); expected.setIterations(iterations); expected.setMemory(memory); expected.setParallelism(parallelism); assertThat(result).isEqualToComparingFieldByField(expected); }
@Override public ArgonOptions convert(String value) throws Exception { final Path path = Paths.get(value); if (!Files.exists(path)) { throw new FileNotFoundException(String.format("%s not found.", path)); } try (InputStream in = Files.newInputStream(path)) { return JaxbUtil.unmarshal(in, ArgonOptions.class); } }
ArgonOptionsConverter implements CommandLine.ITypeConverter<ArgonOptions> { @Override public ArgonOptions convert(String value) throws Exception { final Path path = Paths.get(value); if (!Files.exists(path)) { throw new FileNotFoundException(String.format("%s not found.", path)); } try (InputStream in = Files.newInputStream(path)) { return JaxbUtil.unmarshal(in, ArgonOptions.class); } } }
ArgonOptionsConverter implements CommandLine.ITypeConverter<ArgonOptions> { @Override public ArgonOptions convert(String value) throws Exception { final Path path = Paths.get(value); if (!Files.exists(path)) { throw new FileNotFoundException(String.format("%s not found.", path)); } try (InputStream in = Files.newInputStream(path)) { return JaxbUtil.unmarshal(in, ArgonOptions.class); } }  }
ArgonOptionsConverter implements CommandLine.ITypeConverter<ArgonOptions> { @Override public ArgonOptions convert(String value) throws Exception { final Path path = Paths.get(value); if (!Files.exists(path)) { throw new FileNotFoundException(String.format("%s not found.", path)); } try (InputStream in = Files.newInputStream(path)) { return JaxbUtil.unmarshal(in, ArgonOptions.class); } }  @Override ArgonOptions convert(String value); }
ArgonOptionsConverter implements CommandLine.ITypeConverter<ArgonOptions> { @Override public ArgonOptions convert(String value) throws Exception { final Path path = Paths.get(value); if (!Files.exists(path)) { throw new FileNotFoundException(String.format("%s not found.", path)); } try (InputStream in = Files.newInputStream(path)) { return JaxbUtil.unmarshal(in, ArgonOptions.class); } }  @Override ArgonOptions convert(String value);  }