@Test public void testDecodeRules() { List<AnonymizationRule> rules = new ArrayList<>(); AnonymizationRule rule1 = new AnonymizationRule(); rule1.setReplacement("replace1"); AnonymizationRule rule2 = new AnonymizationRule(); rule2.setReplacement("replace2"); rule2.setValue(Base64.getEncoder().encodeToString("value2".getBytes())); rules.add(rule1); rules.add(rule2); List<AnonymizationRule> finalRules = underTest.decodeRules(rules); assertEquals(finalRules.size(), 1); assertEquals(finalRules.get(0).getValue(), "value2"); }
public List<AnonymizationRule> decodeRules(List<AnonymizationRule> rules) { return Optional.ofNullable(rules) .orElse(new ArrayList<>()) .stream() .filter(rule -> StringUtils.isNotBlank(rule.getValue())) .map(rule -> { AnonymizationRule newRule = new AnonymizationRule(); newRule.setReplacement(rule.getReplacement()); newRule.setValue(new String(Base64.getDecoder().decode( rule.getValue().getBytes()))); return newRule; }) .collect(Collectors.toList()); }
AnonymizationRuleResolver { public List<AnonymizationRule> decodeRules(List<AnonymizationRule> rules) { return Optional.ofNullable(rules) .orElse(new ArrayList<>()) .stream() .filter(rule -> StringUtils.isNotBlank(rule.getValue())) .map(rule -> { AnonymizationRule newRule = new AnonymizationRule(); newRule.setReplacement(rule.getReplacement()); newRule.setValue(new String(Base64.getDecoder().decode( rule.getValue().getBytes()))); return newRule; }) .collect(Collectors.toList()); } }
AnonymizationRuleResolver { public List<AnonymizationRule> decodeRules(List<AnonymizationRule> rules) { return Optional.ofNullable(rules) .orElse(new ArrayList<>()) .stream() .filter(rule -> StringUtils.isNotBlank(rule.getValue())) .map(rule -> { AnonymizationRule newRule = new AnonymizationRule(); newRule.setReplacement(rule.getReplacement()); newRule.setValue(new String(Base64.getDecoder().decode( rule.getValue().getBytes()))); return newRule; }) .collect(Collectors.toList()); }  }
AnonymizationRuleResolver { public List<AnonymizationRule> decodeRules(List<AnonymizationRule> rules) { return Optional.ofNullable(rules) .orElse(new ArrayList<>()) .stream() .filter(rule -> StringUtils.isNotBlank(rule.getValue())) .map(rule -> { AnonymizationRule newRule = new AnonymizationRule(); newRule.setReplacement(rule.getReplacement()); newRule.setValue(new String(Base64.getDecoder().decode( rule.getValue().getBytes()))); return newRule; }) .collect(Collectors.toList()); }  List<AnonymizationRule> decodeRules(List<AnonymizationRule> rules); }
AnonymizationRuleResolver { public List<AnonymizationRule> decodeRules(List<AnonymizationRule> rules) { return Optional.ofNullable(rules) .orElse(new ArrayList<>()) .stream() .filter(rule -> StringUtils.isNotBlank(rule.getValue())) .map(rule -> { AnonymizationRule newRule = new AnonymizationRule(); newRule.setReplacement(rule.getReplacement()); newRule.setValue(new String(Base64.getDecoder().decode( rule.getValue().getBytes()))); return newRule; }) .collect(Collectors.toList()); }  List<AnonymizationRule> decodeRules(List<AnonymizationRule> rules);  }