Search in sources :

Example 1 with Message

use of org.kie.kogito.tracing.event.message.Message in project kogito-runtimes by kiegroup.

the class DecisionMessageTest method testSerialization.

@Test
public void testSerialization() throws JsonProcessingException {
    Message message = getDecisionMessage(new Random().nextInt(5));
    String retrieved = new ObjectMapper().writeValueAsString(message);
    assertNotNull(retrieved);
    System.out.println(retrieved);
}
Also used : Message(org.kie.kogito.tracing.event.message.Message) Random(java.util.Random) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 2 with Message

use of org.kie.kogito.tracing.event.message.Message in project kogito-runtimes by kiegroup.

the class DecisionMessageTest method testDeserialization.

@Test
public void testDeserialization() throws JsonProcessingException {
    String toRead = TracingTestUtils.readResourceAsString("/decisionmessage.json");
    Message retrieved = new ObjectMapper().readValue(toRead, Message.class);
    assertNotNull(retrieved);
    assertTrue(retrieved instanceof DecisionMessage);
}
Also used : Message(org.kie.kogito.tracing.event.message.Message) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 3 with Message

use of org.kie.kogito.tracing.event.message.Message in project kogito-runtimes by kiegroup.

the class TraceEventTest method getTraceInputValue.

private TraceInputValue getTraceInputValue(int id) {
    String valueType = "type-" + id;
    TypedValue value = new UnitValue(valueType);
    List<Message> messages = IntStream.range(id + 1, id + 3).mapToObj(DecisionMessageTest::getDecisionMessage).collect(Collectors.toList());
    return new TraceInputValue("id-" + id, "name-" + id, value, messages);
}
Also used : Message(org.kie.kogito.tracing.event.message.Message) UnitValue(org.kie.kogito.tracing.typedvalue.UnitValue) TypedValue(org.kie.kogito.tracing.typedvalue.TypedValue)

Example 4 with Message

use of org.kie.kogito.tracing.event.message.Message in project kogito-runtimes by kiegroup.

the class TraceEventTest method getTraceExecutionStep.

private TraceExecutionStep getTraceExecutionStep(int id) {
    List<Message> messages = IntStream.range(id + 1, id + 3).mapToObj(DecisionMessageTest::getDecisionMessage).collect(Collectors.toList());
    Map<String, String> additionalData = Collections.singletonMap("key", "value");
    List<TraceExecutionStep> children = IntStream.range(id + 1, id + 3).mapToObj(i -> getTraceExecutionStep()).collect(Collectors.toList());
    return new TraceExecutionStep(getTraceExecutionStepType(), new Random().nextLong(), "name-" + id, new IntNode(id), messages, additionalData, children);
}
Also used : IntStream(java.util.stream.IntStream) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) IntNode(com.fasterxml.jackson.databind.node.IntNode) DMN(org.kie.kogito.tracing.event.trace.TraceEventType.DMN) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Random(java.util.Random) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Collectors(java.util.stream.Collectors) TypedValue(org.kie.kogito.tracing.typedvalue.TypedValue) UnitValue(org.kie.kogito.tracing.typedvalue.UnitValue) Test(org.junit.jupiter.api.Test) List(java.util.List) DecisionMessageTest(org.kie.kogito.tracing.event.message.models.DecisionMessageTest) Map(java.util.Map) BooleanNode(com.fasterxml.jackson.databind.node.BooleanNode) TracingTestUtils(org.kie.kogito.tracing.event.TracingTestUtils) Collections(java.util.Collections) Message(org.kie.kogito.tracing.event.message.Message) IntNode(com.fasterxml.jackson.databind.node.IntNode) Message(org.kie.kogito.tracing.event.message.Message) Random(java.util.Random)

Example 5 with Message

use of org.kie.kogito.tracing.event.message.Message in project kogito-runtimes by kiegroup.

the class TraceEventTest method getTraceOutputValue.

private TraceOutputValue getTraceOutputValue(int id) {
    String valueType = "type-" + id;
    TypedValue value = new UnitValue(valueType);
    Map<String, TypedValue> inputs = Collections.singletonMap(valueType, value);
    List<Message> messages = IntStream.range(id + 1, id + 3).mapToObj(DecisionMessageTest::getDecisionMessage).collect(Collectors.toList());
    return new TraceOutputValue("id-" + id, "name-" + id, "status-" + id, value, inputs, messages);
}
Also used : Message(org.kie.kogito.tracing.event.message.Message) UnitValue(org.kie.kogito.tracing.typedvalue.UnitValue) TypedValue(org.kie.kogito.tracing.typedvalue.TypedValue)

Aggregations

Message (org.kie.kogito.tracing.event.message.Message)6 TypedValue (org.kie.kogito.tracing.typedvalue.TypedValue)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Test (org.junit.jupiter.api.Test)3 UnitValue (org.kie.kogito.tracing.typedvalue.UnitValue)3 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Random (java.util.Random)2 Collectors (java.util.stream.Collectors)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 BooleanNode (com.fasterxml.jackson.databind.node.BooleanNode)1 IntNode (com.fasterxml.jackson.databind.node.IntNode)1 CloudEvent (io.cloudevents.CloudEvent)1 URI (java.net.URI)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1