@Test public void encryptorTypeDefaultsToNACL() { EncryptorOptions encryptorOptions = new EncryptorOptions(); EncryptorConfig result = encryptorOptions.parseEncryptorConfig(); assertThat(result.getType()).isEqualTo(EncryptorType.NACL); assertThat(result.getProperties()).isEmpty(); }
EncryptorConfig parseEncryptorConfig() { final EncryptorConfig encryptorConfig = new EncryptorConfig(); if (Objects.isNull(type)) { type = EncryptorType.NACL; } Map<String, String> properties = new HashMap<>(); if (type == EncryptorType.EC) { Optional.ofNullable(symmetricCipher).ifPresent(v -> properties.put("symmetricCipher", v)); Optional.ofNullable(ellipticCurve).ifPresent(v -> properties.put("ellipticCurve", v)); Optional.ofNullable(nonceLength).ifPresent(v -> properties.put("nonceLength", v)); Optional.ofNullable(sharedKeyLength).ifPresent(v -> properties.put("sharedKeyLength", v)); } encryptorConfig.setType(type); encryptorConfig.setProperties(properties); return encryptorConfig; }
EncryptorOptions { EncryptorConfig parseEncryptorConfig() { final EncryptorConfig encryptorConfig = new EncryptorConfig(); if (Objects.isNull(type)) { type = EncryptorType.NACL; } Map<String, String> properties = new HashMap<>(); if (type == EncryptorType.EC) { Optional.ofNullable(symmetricCipher).ifPresent(v -> properties.put("symmetricCipher", v)); Optional.ofNullable(ellipticCurve).ifPresent(v -> properties.put("ellipticCurve", v)); Optional.ofNullable(nonceLength).ifPresent(v -> properties.put("nonceLength", v)); Optional.ofNullable(sharedKeyLength).ifPresent(v -> properties.put("sharedKeyLength", v)); } encryptorConfig.setType(type); encryptorConfig.setProperties(properties); return encryptorConfig; } }
EncryptorOptions { EncryptorConfig parseEncryptorConfig() { final EncryptorConfig encryptorConfig = new EncryptorConfig(); if (Objects.isNull(type)) { type = EncryptorType.NACL; } Map<String, String> properties = new HashMap<>(); if (type == EncryptorType.EC) { Optional.ofNullable(symmetricCipher).ifPresent(v -> properties.put("symmetricCipher", v)); Optional.ofNullable(ellipticCurve).ifPresent(v -> properties.put("ellipticCurve", v)); Optional.ofNullable(nonceLength).ifPresent(v -> properties.put("nonceLength", v)); Optional.ofNullable(sharedKeyLength).ifPresent(v -> properties.put("sharedKeyLength", v)); } encryptorConfig.setType(type); encryptorConfig.setProperties(properties); return encryptorConfig; }  }
EncryptorOptions { EncryptorConfig parseEncryptorConfig() { final EncryptorConfig encryptorConfig = new EncryptorConfig(); if (Objects.isNull(type)) { type = EncryptorType.NACL; } Map<String, String> properties = new HashMap<>(); if (type == EncryptorType.EC) { Optional.ofNullable(symmetricCipher).ifPresent(v -> properties.put("symmetricCipher", v)); Optional.ofNullable(ellipticCurve).ifPresent(v -> properties.put("ellipticCurve", v)); Optional.ofNullable(nonceLength).ifPresent(v -> properties.put("nonceLength", v)); Optional.ofNullable(sharedKeyLength).ifPresent(v -> properties.put("sharedKeyLength", v)); } encryptorConfig.setType(type); encryptorConfig.setProperties(properties); return encryptorConfig; }   }
EncryptorOptions { EncryptorConfig parseEncryptorConfig() { final EncryptorConfig encryptorConfig = new EncryptorConfig(); if (Objects.isNull(type)) { type = EncryptorType.NACL; } Map<String, String> properties = new HashMap<>(); if (type == EncryptorType.EC) { Optional.ofNullable(symmetricCipher).ifPresent(v -> properties.put("symmetricCipher", v)); Optional.ofNullable(ellipticCurve).ifPresent(v -> properties.put("ellipticCurve", v)); Optional.ofNullable(nonceLength).ifPresent(v -> properties.put("nonceLength", v)); Optional.ofNullable(sharedKeyLength).ifPresent(v -> properties.put("sharedKeyLength", v)); } encryptorConfig.setType(type); encryptorConfig.setProperties(properties); return encryptorConfig; }    }