Skip to content

Commit

Permalink
#104 Adding additional unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Jul 13, 2024
1 parent 4ae95ad commit 9b85820
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Replacement getReplacement(String label, String context, String documentI
}

replacement = maskCharacter.repeat(characters);

} else if(StringUtils.equalsIgnoreCase(strategy, RANDOM_REPLACE)) {

// Default to document scope.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void replacement10() throws Exception {
}

@Test
public void replacementWithMaskCharacter() throws Exception {
public void replacementWithMaskCharacterForSameLength() throws Exception {

final AnonymizationService anonymizationService = Mockito.mock(AnonymizationService.class);
final AnonymizationCacheService anonymizationCacheService = Mockito.mock(AnonymizationCacheService.class);
Expand All @@ -240,6 +240,7 @@ public void replacementWithMaskCharacter() throws Exception {

final AbstractFilterStrategy strategy = getFilterStrategy();
strategy.setStrategy(AbstractFilterStrategy.MASK);
strategy.setMaskLength("same");

final String token = "token";
final Replacement replacement = strategy.getReplacement("name", "context", "docId", token, WINDOW, null, null, anonymizationService, null);
Expand All @@ -249,6 +250,27 @@ public void replacementWithMaskCharacter() throws Exception {

}

@Test
public void replacementWithMaskCharacterForSetLength() throws Exception {

final AnonymizationService anonymizationService = Mockito.mock(AnonymizationService.class);
final AnonymizationCacheService anonymizationCacheService = Mockito.mock(AnonymizationCacheService.class);

when(anonymizationService.getAnonymizationCacheService()).thenReturn(anonymizationCacheService);

final AbstractFilterStrategy strategy = getFilterStrategy();
strategy.setStrategy(AbstractFilterStrategy.MASK);
strategy.setMaskCharacter("#");
strategy.setMaskLength("10");

final String token = "token";
final Replacement replacement = strategy.getReplacement("name", "context", "docId", token, WINDOW, null, null, anonymizationService, null);

Assertions.assertEquals(replacement.getReplacement(), "##########");
Assertions.assertEquals(replacement.getReplacement().length(), 10);

}

@Test
public void evaluateCondition1() throws IOException {

Expand Down

0 comments on commit 9b85820

Please sign in to comment.