|
49 | 49 | import java.util.List;
|
50 | 50 | import java.util.Properties;
|
51 | 51 |
|
52 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPdfFilterWithPersonPolicy; |
53 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPolicy; |
54 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPolicyJustCreditCard; |
55 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPolicyJustIdentifier; |
56 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPolicyJustStreetAddress; |
57 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPolicyWithSentiment; |
58 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPolicyZipCodeWithIgnored; |
59 |
| -import static ai.philterd.test.phileas.services.EndToEndTestsHelper.getPolicyZipCodeWithIgnoredFromFile; |
| 52 | +import static ai.philterd.test.phileas.services.EndToEndTestsHelper.*; |
60 | 53 |
|
61 | 54 | @Disabled("Some of these tests require a running philter-ner service")
|
62 | 55 | public class EndToEndTests {
|
@@ -566,6 +559,38 @@ public void endToEnd17() throws Exception {
|
566 | 559 |
|
567 | 560 | }
|
568 | 561 |
|
| 562 | + @Test |
| 563 | + public void endToEndJustPhoneNumbers() throws Exception { |
| 564 | + |
| 565 | + final Path temp = Files.createTempDirectory("philter"); |
| 566 | + final File file = Paths.get(temp.toFile().getAbsolutePath(), "phonenumbers.json").toFile(); |
| 567 | + LOGGER.info("Writing policy to {}", file.getAbsolutePath()); |
| 568 | + final String policy = gson.toJson(getPolicyJustPhoneNumber("phonenumbers")); |
| 569 | + LOGGER.info(policy); |
| 570 | + FileUtils.writeStringToFile(file, policy, Charset.defaultCharset()); |
| 571 | + |
| 572 | + Properties properties = new Properties(); |
| 573 | + properties.setProperty("indexes.directory", INDEXES_DIRECTORY); |
| 574 | + properties.setProperty("filter.policies.directory", temp.toFile().getAbsolutePath()); |
| 575 | + |
| 576 | + final PhileasConfiguration phileasConfiguration = new PhileasConfiguration(properties); |
| 577 | + |
| 578 | + final String input = "his number is 123-456-7890. her number is 999-999-9999."; |
| 579 | + |
| 580 | + final PhileasFilterService service = new PhileasFilterService(phileasConfiguration); |
| 581 | + final FilterResponse response = service.filter(List.of("phonenumbers"), "context", "documentid", input, MimeType.TEXT_PLAIN); |
| 582 | + |
| 583 | + LOGGER.info(response.filteredText()); |
| 584 | + |
| 585 | + showSpans(response.explanation().appliedSpans()); |
| 586 | + |
| 587 | + Assertions.assertEquals("documentid", response.documentId()); |
| 588 | + Assertions.assertEquals(1, response.explanation().identifiedSpans().size()); |
| 589 | + Assertions.assertEquals(1, response.explanation().appliedSpans().size()); |
| 590 | + Assertions.assertEquals("his number is {{{REDACTED-phone-number}}}. her number is {{{REDACTED-phone-number}}}.", response.filteredText().trim()); |
| 591 | + |
| 592 | + } |
| 593 | + |
569 | 594 | @Test
|
570 | 595 | public void endToEndWithPolicyAsObject() throws Exception {
|
571 | 596 |
|
|
0 commit comments