Skip to content

Commit

Permalink
Adds unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BOUTIER Charly committed Nov 24, 2023
1 parent 4e50633 commit 539e2e1
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,29 @@ public void testEvaluateExpertFilterIgnoreCase() {

assertTrue(result);
}

@Test
public void testEvaluateExpertFilterExists() {
List<AbstractExpertRule> numRules = new ArrayList<>();
numRules.add(NumberExpertRule.builder().field(FieldType.TARGET_V).operator(OperatorType.EXISTS).build());
CombinatorExpertRule numFilter = CombinatorExpertRule.builder().combinator(CombinatorType.AND).rules(numRules).build();

List<AbstractExpertRule> stringRules = new ArrayList<>();
stringRules.add(StringExpertRule.builder().field(FieldType.NAME).operator(OperatorType.EXISTS).build());
CombinatorExpertRule stringFilter = CombinatorExpertRule.builder().combinator(CombinatorType.AND).rules(stringRules).build();

// Test when value exists
assertTrue(numFilter.evaluateRule(gen));
assertTrue(stringFilter.evaluateRule(gen));

// Test when value does not exist
Mockito.when(gen.getTargetV()).thenReturn(Double.NaN);
assertFalse(numFilter.evaluateRule(gen));

Mockito.when(gen.getNameOrId()).thenReturn(null);
assertFalse(stringFilter.evaluateRule(gen));

Mockito.when(gen.getNameOrId()).thenReturn("");
assertFalse(stringFilter.evaluateRule(gen));
}
}

0 comments on commit 539e2e1

Please sign in to comment.