@Test public void testRulePatternWithInvalidPattern() { String input = "My email card number is: 1111-2222-3333-4444"; List<AnonymizationRule> rules = new ArrayList<>(); AnonymizationRule rule = new AnonymizationRule(); rule.setReplacement("[REDACTED]"); String pattern = "\\d{8}[^[["; String encodedPattern = new String(Base64.getEncoder().encode(pattern.getBytes())); rule.setValue(encodedPattern); rules.add(rule); assertThrows(BadRequestException.class, () -> { underTest.testRulePatterns(rules, input); }); }
public String testRulePatterns(List<AnonymizationRule> rules, String input) { String output = input; for (AnonymizationRule rule : rules) { String decodedRule = new String(Base64.getDecoder().decode(rule.getValue().getBytes())); Pattern p = createAndCheckPattern(decodedRule); Replacer replacer = p.replacer(rule.getReplacement()); output = replacer.replace(output); } return output; }
AccountTelemetryService { public String testRulePatterns(List<AnonymizationRule> rules, String input) { String output = input; for (AnonymizationRule rule : rules) { String decodedRule = new String(Base64.getDecoder().decode(rule.getValue().getBytes())); Pattern p = createAndCheckPattern(decodedRule); Replacer replacer = p.replacer(rule.getReplacement()); output = replacer.replace(output); } return output; } }
AccountTelemetryService { public String testRulePatterns(List<AnonymizationRule> rules, String input) { String output = input; for (AnonymizationRule rule : rules) { String decodedRule = new String(Base64.getDecoder().decode(rule.getValue().getBytes())); Pattern p = createAndCheckPattern(decodedRule); Replacer replacer = p.replacer(rule.getReplacement()); output = replacer.replace(output); } return output; } AccountTelemetryService(AccountTelemetryRepository accountTelemetryRepository); }
AccountTelemetryService { public String testRulePatterns(List<AnonymizationRule> rules, String input) { String output = input; for (AnonymizationRule rule : rules) { String decodedRule = new String(Base64.getDecoder().decode(rule.getValue().getBytes())); Pattern p = createAndCheckPattern(decodedRule); Replacer replacer = p.replacer(rule.getReplacement()); output = replacer.replace(output); } return output; } AccountTelemetryService(AccountTelemetryRepository accountTelemetryRepository); AccountTelemetry create(AccountTelemetry telemetry, String accountId); AccountTelemetry getOrDefault(String accountId); Features updateFeatures(String accountId, Features newFeatures); AccountTelemetry createDefaultAccuontTelemetry(); String testRulePatterns(List<AnonymizationRule> rules, String input); }
AccountTelemetryService { public String testRulePatterns(List<AnonymizationRule> rules, String input) { String output = input; for (AnonymizationRule rule : rules) { String decodedRule = new String(Base64.getDecoder().decode(rule.getValue().getBytes())); Pattern p = createAndCheckPattern(decodedRule); Replacer replacer = p.replacer(rule.getReplacement()); output = replacer.replace(output); } return output; } AccountTelemetryService(AccountTelemetryRepository accountTelemetryRepository); AccountTelemetry create(AccountTelemetry telemetry, String accountId); AccountTelemetry getOrDefault(String accountId); Features updateFeatures(String accountId, Features newFeatures); AccountTelemetry createDefaultAccuontTelemetry(); String testRulePatterns(List<AnonymizationRule> rules, String input);  }