use of org.kie.kogito.decision.DecisionModel in project kogito-runtimes by kiegroup.
the class DecisionExplainabilityResourceExecutorTest method testGetDecisionModel.
@ParameterizedTest
@MethodSource("getDecisionModelTestProvider")
public void testGetDecisionModel(String[] args) {
String namespace = args[0];
String name = args[1];
DecisionExplainabilityResourceExecutor executor = new DecisionExplainabilityResourceExecutor();
DecisionModels decisionModels = mock(DecisionModels.class);
DecisionModel model = new DmnDecisionModel(generateDMNRuntime(namespace, name), namespace, name);
when(decisionModels.getDecisionModel(eq(namespace), eq(name))).thenReturn(model);
ModelIdentifier modelIdentifier = new ModelIdentifier("dmn", String.format("%s%s%s", namespace, RESOURCE_ID_SEPARATOR, name));
DecisionModel decisionModelResponse = executor.getDecisionModel(decisionModels, modelIdentifier);
Assertions.assertNotNull(decisionModelResponse);
Assertions.assertEquals(namespace, decisionModelResponse.getDMNModel().getNamespace());
Assertions.assertEquals(name, decisionModelResponse.getDMNModel().getName());
}
use of org.kie.kogito.decision.DecisionModel in project kogito-runtimes by kiegroup.
the class DecisionTracingListenerTest method testWithRealRuntime.
private static List<EvaluateEvent> testWithRealRuntime(Map<String, Object> contextVariables, int expectedEvents, BiConsumer<DecisionModel, DMNContext> modelConsumer) {
final DMNRuntime runtime = createDMNRuntime();
Consumer<EvaluateEvent> eventConsumer = mock(Consumer.class);
DecisionTracingListener listener = new DecisionTracingListener(eventConsumer);
runtime.addListener(listener);
final DecisionModel model = new DmnDecisionModel(runtime, MODEL_NAMESPACE, MODEL_NAME, () -> TEST_EXECUTION_ID_2);
final DMNContext context = model.newContext(contextVariables);
modelConsumer.accept(model, context);
ArgumentCaptor<EvaluateEvent> eventCaptor = ArgumentCaptor.forClass(EvaluateEvent.class);
verify(eventConsumer, times(expectedEvents)).accept(eventCaptor.capture());
return eventCaptor.getAllValues();
}
use of org.kie.kogito.decision.DecisionModel in project kogito-runtimes by kiegroup.
the class BaseQuarkusDecisionTracingTest method testAsyncListenerAndCollectorWithRealEventsIsWorking.
@Test
void testAsyncListenerAndCollectorWithRealEventsIsWorking() throws IOException {
final DMNRuntime runtime = buildDMNRuntime();
final DecisionModel model = buildDecisionModel(runtime);
final List<EvaluateEvent> events = testListener(true, runtime, model);
assertEquals(getEvaluationEventCount(), events.size());
testCollector(events, model);
}
use of org.kie.kogito.decision.DecisionModel in project kogito-runtimes by kiegroup.
the class BaseQuarkusDecisionTracingTest method testSyncListenerAndCollectorWithRealEventsIsWorking.
@Test
void testSyncListenerAndCollectorWithRealEventsIsWorking() throws IOException {
final DMNRuntime runtime = buildDMNRuntime();
final DecisionModel model = buildDecisionModel(runtime);
final List<EvaluateEvent> events = testListener(false, runtime, model);
assertEquals(getEvaluationEventCount(), events.size());
testCollector(events, model);
}
use of org.kie.kogito.decision.DecisionModel in project kogito-runtimes by kiegroup.
the class DMNKogitoTest method testBasic.
@Test
public void testBasic() {
DMNRuntime dmnRuntime = DMNKogito.createGenericDMNRuntime(new InputStreamReader(DMNKogitoTest.class.getResourceAsStream("TrafficViolation.dmn")));
assertEquals(1, dmnRuntime.getModels().size());
final String TRAFFIC_VIOLATION_NS = "https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF";
final String TRAFFIC_VIOLATION_NAME = "Traffic Violation";
DecisionModel kogitoAPI = new DmnDecisionModel(dmnRuntime, TRAFFIC_VIOLATION_NS, TRAFFIC_VIOLATION_NAME);
assertEquals(TRAFFIC_VIOLATION_NS, kogitoAPI.getDMNModel().getNamespace());
assertEquals(TRAFFIC_VIOLATION_NAME, kogitoAPI.getDMNModel().getName());
assertEquals(2, kogitoAPI.getDMNModel().getInputs().size(), "Traffic Violation model has 2 inputs");
}
Aggregations