use of org.kie.kogito.explainability.api.CounterfactualExplainabilityResult in project kogito-apps by kiegroup.
the class CounterfactualExplainabilityResultsManagerDuplicatesTest method testPurgeWhenResultSetSizeIsGreaterThanMinimum_WithoutDuplicateOutputs.
@Test
public void testPurgeWhenResultSetSizeIsGreaterThanMinimum_WithoutDuplicateOutputs() {
CounterfactualExplainabilityResult result0 = makeResult(0, Collections.emptyList(), List.of(makeCounterfactualOutput("0")));
CounterfactualExplainabilityResult result1 = makeResult(1, Collections.emptyList(), List.of(makeCounterfactualOutput("1")));
CounterfactualExplainabilityResult result2 = makeResult(2, Collections.emptyList(), List.of(makeCounterfactualOutput("2")));
CounterfactualExplainabilityResult result3 = makeResult(3, Collections.emptyList(), List.of(makeCounterfactualOutput("3")));
when(query.execute()).thenReturn(List.of(result0, result1, result2, result3));
manager.purge(COUNTERFACTUAL_ID, storage);
verify(storage, never()).remove(anyString());
}
use of org.kie.kogito.explainability.api.CounterfactualExplainabilityResult in project kogito-apps by kiegroup.
the class CounterfactualExplainabilityResultsManagerDuplicatesTest method testPurgeWhenResultSetSizeIsGreaterThanMinimum_WithDuplicateOutputs.
@Test
public void testPurgeWhenResultSetSizeIsGreaterThanMinimum_WithDuplicateOutputs() {
CounterfactualExplainabilityResult result0 = makeResult(0, Collections.emptyList(), Collections.emptyList());
CounterfactualExplainabilityResult result1 = makeResult(1, Collections.emptyList(), Collections.emptyList());
CounterfactualExplainabilityResult result2 = makeResult(2, Collections.emptyList(), List.of(makeCounterfactualOutput("a")));
CounterfactualExplainabilityResult result3 = makeResult(3, Collections.emptyList(), List.of(makeCounterfactualOutput("a")));
when(query.execute()).thenReturn(List.of(result0, result1, result2, result3));
manager.purge(COUNTERFACTUAL_ID, storage);
verify(storage).remove(anyString());
verify(storage).remove(result3.getSolutionId());
}
use of org.kie.kogito.explainability.api.CounterfactualExplainabilityResult in project kogito-apps by kiegroup.
the class CounterfactualExplainabilityResultsManagerSlidingWindowTest method testPurgeWhenResultSetSizeIsGreaterThanWindowSize.
@Test
public void testPurgeWhenResultSetSizeIsGreaterThanWindowSize() {
CounterfactualExplainabilityResult result0 = makeResult(0);
CounterfactualExplainabilityResult result1 = makeResult(1);
CounterfactualExplainabilityResult result2 = makeResult(2);
CounterfactualExplainabilityResult result3 = makeResult(3);
when(query.execute()).thenReturn(List.of(result0, result1, result2, result3));
manager.purge(COUNTERFACTUAL_ID, storage);
verify(storage, times(2)).remove(anyString());
verify(storage).remove(result0.getSolutionId());
verify(storage).remove(result1.getSolutionId());
}
use of org.kie.kogito.explainability.api.CounterfactualExplainabilityResult in project kogito-apps by kiegroup.
the class CounterfactualExplainerServiceHandlerTest method testGetExplainabilityResultById_WhenMultipleStored.
@Test
public void testGetExplainabilityResultById_WhenMultipleStored() {
CounterfactualExplainabilityResult intermediate = mock(CounterfactualExplainabilityResult.class);
when(intermediate.getExecutionId()).thenReturn(EXECUTION_ID);
when(intermediate.getSolutionId()).thenReturn(SOLUTION_ID);
when(intermediate.getStage()).thenReturn(CounterfactualExplainabilityResult.Stage.INTERMEDIATE);
when(query.execute()).thenReturn(List.of(intermediate, result));
assertEquals(result, handler.getExplainabilityResultById(EXECUTION_ID));
}
use of org.kie.kogito.explainability.api.CounterfactualExplainabilityResult in project kogito-apps by kiegroup.
the class CounterfactualExplainerServiceHandlerTest method testGetExplainabilityResultById_WhenOnlyIntermediateStored.
@Test
public void testGetExplainabilityResultById_WhenOnlyIntermediateStored() {
CounterfactualExplainabilityResult intermediate = mock(CounterfactualExplainabilityResult.class);
when(intermediate.getExecutionId()).thenReturn(EXECUTION_ID);
when(intermediate.getSolutionId()).thenReturn(SOLUTION_ID);
when(intermediate.getStage()).thenReturn(CounterfactualExplainabilityResult.Stage.INTERMEDIATE);
when(query.execute()).thenReturn(List.of(intermediate));
assertThrows(IllegalArgumentException.class, () -> handler.getExplainabilityResultById(EXECUTION_ID));
}
Aggregations