@Test public void createMinimal() { Config config = new Config(); config.setEncryptor( new EncryptorConfig() { { setType(EncryptorType.NACL); } }); InputStream in = Optional.of(config) .map(JaxbUtil::marshalToStringNoValidation) .map(String::getBytes) .map(ByteArrayInputStream::new) .get(); JaxbUtil.marshalToStringNoValidation(config); Config result = factory.create(in); assertThat(result).isNotNull(); }
@Override public Config create(final InputStream configData) { byte[] originalData = Stream.of(configData) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.joining(System.lineSeparator())) .getBytes(); final Config initialConfig = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); EncryptorConfig encryptorConfig = Optional.ofNullable(initialConfig.getEncryptor()).orElse(DEFAULT_ENCRYPTOR_CONFIG); keyEncryptorFactory.create(encryptorConfig); final Config config = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); config.setEncryptor(encryptorConfig); return config; }
JaxbConfigFactory implements ConfigFactory { @Override public Config create(final InputStream configData) { byte[] originalData = Stream.of(configData) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.joining(System.lineSeparator())) .getBytes(); final Config initialConfig = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); EncryptorConfig encryptorConfig = Optional.ofNullable(initialConfig.getEncryptor()).orElse(DEFAULT_ENCRYPTOR_CONFIG); keyEncryptorFactory.create(encryptorConfig); final Config config = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); config.setEncryptor(encryptorConfig); return config; } }
JaxbConfigFactory implements ConfigFactory { @Override public Config create(final InputStream configData) { byte[] originalData = Stream.of(configData) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.joining(System.lineSeparator())) .getBytes(); final Config initialConfig = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); EncryptorConfig encryptorConfig = Optional.ofNullable(initialConfig.getEncryptor()).orElse(DEFAULT_ENCRYPTOR_CONFIG); keyEncryptorFactory.create(encryptorConfig); final Config config = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); config.setEncryptor(encryptorConfig); return config; } protected  JaxbConfigFactory(KeyEncryptorFactory keyEncryptorFactory);  JaxbConfigFactory(); }
JaxbConfigFactory implements ConfigFactory { @Override public Config create(final InputStream configData) { byte[] originalData = Stream.of(configData) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.joining(System.lineSeparator())) .getBytes(); final Config initialConfig = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); EncryptorConfig encryptorConfig = Optional.ofNullable(initialConfig.getEncryptor()).orElse(DEFAULT_ENCRYPTOR_CONFIG); keyEncryptorFactory.create(encryptorConfig); final Config config = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); config.setEncryptor(encryptorConfig); return config; } protected  JaxbConfigFactory(KeyEncryptorFactory keyEncryptorFactory);  JaxbConfigFactory(); @Override Config create(final InputStream configData); }
JaxbConfigFactory implements ConfigFactory { @Override public Config create(final InputStream configData) { byte[] originalData = Stream.of(configData) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.joining(System.lineSeparator())) .getBytes(); final Config initialConfig = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); EncryptorConfig encryptorConfig = Optional.ofNullable(initialConfig.getEncryptor()).orElse(DEFAULT_ENCRYPTOR_CONFIG); keyEncryptorFactory.create(encryptorConfig); final Config config = JaxbUtil.unmarshal(new ByteArrayInputStream(originalData), Config.class); config.setEncryptor(encryptorConfig); return config; } protected  JaxbConfigFactory(KeyEncryptorFactory keyEncryptorFactory);  JaxbConfigFactory(); @Override Config create(final InputStream configData);  }