use of org.kie.kogito.explainability.api.CounterfactualExplainabilityRequest in project kogito-apps by kiegroup.
the class AbstractTrustyServiceIT method testCounterfactuals_StoreSingleAndRetrieveSingleWithSearchDomainCategorical.
@Test
public void testCounterfactuals_StoreSingleAndRetrieveSingleWithSearchDomainCategorical() {
String executionId = "myCFExecution1";
storeExecution(executionId, 0L);
// The Goals structures must be comparable to the original decisions outcomes.
// The Search Domain structures must be identical those of the original decision inputs.
Collection<JsonNode> categories = List.of(new TextNode("1"), new TextNode("2"));
CounterfactualSearchDomain searchDomain = buildSearchDomainUnit("test", "number", new CounterfactualDomainCategorical(categories));
CounterfactualExplainabilityRequest request = trustyService.requestCounterfactuals(executionId, Collections.emptyList(), Collections.singletonList(searchDomain));
assertNotNull(request);
assertEquals(request.getExecutionId(), executionId);
assertNotNull(request.getCounterfactualId());
assertEquals(1, request.getSearchDomains().size());
List<CounterfactualSearchDomain> requestSearchDomains = new ArrayList<>(request.getSearchDomains());
assertCounterfactualSearchDomainCategorical(searchDomain, requestSearchDomains.get(0));
CounterfactualExplainabilityRequest result = trustyService.getCounterfactualRequest(executionId, request.getCounterfactualId());
assertNotNull(result);
assertEquals(request.getExecutionId(), result.getExecutionId());
assertEquals(request.getCounterfactualId(), result.getCounterfactualId());
assertEquals(1, result.getSearchDomains().size());
List<CounterfactualSearchDomain> resultSearchDomains = new ArrayList<>(result.getSearchDomains());
assertCounterfactualSearchDomainCategorical(searchDomain, resultSearchDomains.get(0));
}
Aggregations