use of org.kie.kogito.explainability.api.ModelIdentifier in project kogito-apps by kiegroup.
the class ExplainabilityApiV1Test method testGetCounterfactualResultsWhenExecutionDoesExist.
@Test
public void testGetCounterfactualResultsWhenExecutionDoesExist() {
NamedTypedValue goal = buildGoalUnit("unit", "string", new TextNode("hello"));
CounterfactualSearchDomain searchDomain = buildSearchDomainUnit("unit", "string", new CounterfactualDomainCategorical(List.of(new TextNode("hello"), new TextNode("goodbye"))));
when(trustyService.getCounterfactualRequest(anyString(), anyString())).thenReturn(new CounterfactualExplainabilityRequest(EXECUTION_ID, SERVICE_URL, new ModelIdentifier("resourceType", "resourceIdentifier"), COUNTERFACTUAL_ID, Collections.emptyList(), List.of(goal), List.of(searchDomain), MAX_RUNNING_TIME_SECONDS));
Response response = explainabilityEndpoint.getCounterfactualDetails(EXECUTION_ID, COUNTERFACTUAL_ID);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Object entity = response.getEntity();
assertNotNull(entity);
assertTrue(entity instanceof CounterfactualResultsResponse);
CounterfactualResultsResponse resultsResponse = (CounterfactualResultsResponse) entity;
assertEquals(EXECUTION_ID, resultsResponse.getExecutionId());
assertEquals(COUNTERFACTUAL_ID, resultsResponse.getCounterfactualId());
assertEquals(MAX_RUNNING_TIME_SECONDS, resultsResponse.getMaxRunningTimeSeconds());
assertEquals(1, resultsResponse.getGoals().size());
assertEquals(goal, resultsResponse.getGoals().iterator().next());
assertEquals(1, resultsResponse.getSearchDomains().size());
assertEquals(searchDomain, resultsResponse.getSearchDomains().iterator().next());
assertTrue(resultsResponse.getSolutions().isEmpty());
}
use of org.kie.kogito.explainability.api.ModelIdentifier in project kogito-apps by kiegroup.
the class ExplainabilityApiV1Test method testGetAllCounterfactualsWhenExecutionDoesExist.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testGetAllCounterfactualsWhenExecutionDoesExist() {
when(trustyService.getCounterfactualRequests(anyString())).thenReturn(List.of(new CounterfactualExplainabilityRequest(EXECUTION_ID, SERVICE_URL, new ModelIdentifier("resourceType", "resourceIdentifier"), COUNTERFACTUAL_ID, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), MAX_RUNNING_TIME_SECONDS)));
Response response = explainabilityEndpoint.getAllCounterfactualsSummary(EXECUTION_ID);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Object entity = response.getEntity();
assertNotNull(entity);
assertTrue(entity instanceof List);
List<CounterfactualRequestResponse> counterfactualRequestResponse = (List) entity;
assertEquals(1, counterfactualRequestResponse.size());
CounterfactualRequestResponse counterfactual = counterfactualRequestResponse.get(0);
assertEquals(EXECUTION_ID, counterfactual.getExecutionId());
assertEquals(COUNTERFACTUAL_ID, counterfactual.getCounterfactualId());
assertEquals(MAX_RUNNING_TIME_SECONDS, counterfactual.getMaxRunningTimeSeconds());
}
use of org.kie.kogito.explainability.api.ModelIdentifier in project kogito-apps by kiegroup.
the class ExplainabilityRequestProducerTest method test.
@Test
void test() {
AssertSubscriber<String> subscriber = AssertSubscriber.create(1);
ExplainabilityRequestProducer producer = new ExplainabilityRequestProducer();
producer.getEventPublisher().subscribe(subscriber);
producer.sendEvent(new LIMEExplainabilityRequest("executionId", "http://localhost:8080/model", new ModelIdentifier("dmn", "modelNamespace:model"), Collections.emptyList(), Collections.emptyList()));
assertEquals(1, subscriber.getItems().size());
}
Aggregations