@Test public void ellipticalCurveWithDefinedProperties() { EncryptorOptions encryptorOptions = new EncryptorOptions(); encryptorOptions.type = EncryptorType.EC; encryptorOptions.symmetricCipher = "somecipher"; encryptorOptions.ellipticCurve = "somecurve"; encryptorOptions.nonceLength = "3"; encryptorOptions.sharedKeyLength = "2"; EncryptorConfig result = encryptorOptions.parseEncryptorConfig(); assertThat(result.getType()).isEqualTo(EncryptorType.EC); assertThat(result.getProperties()) .containsOnlyKeys("symmetricCipher", "ellipticCurve", "nonceLength", "sharedKeyLength"); assertThat(result.getProperties().get("symmetricCipher")).isEqualTo("somecipher"); assertThat(result.getProperties().get("ellipticCurve")).isEqualTo("somecurve"); assertThat(result.getProperties().get("nonceLength")).isEqualTo("3"); assertThat(result.getProperties().get("sharedKeyLength")).isEqualTo("2"); }
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; }    }