Skip to content

Commit

Permalink
[kie-issues-249] data index improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Oct 6, 2023
1 parent f31848d commit c71d2ed
Show file tree
Hide file tree
Showing 81 changed files with 2,389 additions and 1,500 deletions.
1 change: 1 addition & 0 deletions .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pipeline {
stages {
stage('Initialize') {
steps {
cleanWs()
script {
// load `pr_check.groovy` file from kogito-pipelines:main
dir('kogito-pipelines') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public void testProcessInstanceEvents() throws IOException {

public void testProcessGatewayAPI() throws IOException {
String pId2 = createTestProcessInstance();

await()
.atMost(TIMEOUT)
.untilAsserted(() -> getProcessInstanceById(pId2, "ACTIVE"));
Expand Down Expand Up @@ -343,6 +344,8 @@ public void testProcessGatewayAPI() throws IOException {
.statusCode(200)
.body("errors", nullValue()));

System.out.println("PROCESS INSTANCE 2!!! UPDATED " + taskSchema);

await()
.atMost(TIMEOUT)
.untilAsserted(() -> given().spec(dataIndexSpec()).contentType(ContentType.JSON)
Expand Down Expand Up @@ -471,6 +474,18 @@ public void testProcessGatewayAPIComments(String taskId, String processInstanceI
.body("$.size()", is(1))
.body("[0].content", is(commentContent)));

await()
.atMost(TIMEOUT)
.untilAsserted(() -> given().spec(dataIndexSpec()).contentType(ContentType.JSON)
.body("{ \"query\" : \"{ UserTaskInstances (where: { processInstanceId: {equal: \\\"" + processInstanceId + "\\\"}}) { " +
"id description priority potentialGroups comments {id content updatedBy updatedAt} } }\"}")
.when().post("/graphql")
.then()
.statusCode(200)
.body("data.UserTaskInstances[0].comments", notNullValue())
.body("data.UserTaskInstances[0].comments.size()", is(1))
.extract().jsonPath().getMap("data.UserTaskInstances[0].comments[0]"));

Map<String, String> commentMap = given().spec(dataIndexSpec()).contentType(ContentType.JSON)
.body("{ \"query\" : \"{ UserTaskInstances (where: { processInstanceId: {equal: \\\"" + processInstanceId + "\\\"}}) { " +
"id description priority potentialGroups comments {id content updatedBy updatedAt} } }\"}")
Expand All @@ -482,6 +497,7 @@ public void testProcessGatewayAPIComments(String taskId, String processInstanceI
.body("data.UserTaskInstances[0].potentialGroups[0]", equalTo("managers"))
.body("data.UserTaskInstances[0].comments.size()", is(1))
.extract().jsonPath().getMap("data.UserTaskInstances[0].comments[0]");

checkExpectedCreatedItemData(commentCreationResult, commentMap);
String commentNewContent = "commentNewContent";
String commentUpdateResult = given().spec(dataIndexSpec()).contentType(ContentType.JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,4 @@ mp.messaging.outgoing.kogito-usertaskinstances-events.connector=smallrye-kafka
mp.messaging.outgoing.kogito-usertaskinstances-events.topic=kogito-usertaskinstances-events
mp.messaging.outgoing.kogito-usertaskinstances-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer
mp.messaging.outgoing.kogito-usertaskinstances-events.group.id=kogito-data-index-it
mp.messaging.outgoing.kogito-usertaskinstances-events.auto.offset.reset=earliest

mp.messaging.outgoing.kogito-variables-events.connector=smallrye-kafka
mp.messaging.outgoing.kogito-variables-events.topic=kogito-variables-events
mp.messaging.outgoing.kogito-variables-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer
mp.messaging.outgoing.kogito-variables-events.group.id=kogito-data-index-it
mp.messaging.outgoing.kogito-variables-events.auto.offset.reset=earliest
mp.messaging.outgoing.kogito-usertaskinstances-events.auto.offset.reset=earliest
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ protected Map<String, String> getProperties() {
properties.put(KOGITO_SERVICE_URL, "http://host.testcontainers.internal:" + getTestResource().getMappedPort());
properties.put("mp.messaging.outgoing.kogito-processinstances-events.connector", "smallrye-kafka");
properties.put("mp.messaging.outgoing.kogito-usertaskinstances-events.connector", "smallrye-kafka");
properties.put("mp.messaging.outgoing.kogito-variables-events.connector", "smallrye-kafka");

return properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@ mp.messaging.outgoing.kogito-usertaskinstances-events.connector=smallrye-kafka
mp.messaging.outgoing.kogito-usertaskinstances-events.topic=kogito-usertaskinstances-events
mp.messaging.outgoing.kogito-usertaskinstances-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer

mp.messaging.outgoing.kogito-variables-events.connector=smallrye-kafka
mp.messaging.outgoing.kogito-variables-events.topic=kogito-variables-events
mp.messaging.outgoing.kogito-variables-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer

quarkus.http.auth.permission.source-files-addon.paths=/management/*
quarkus.http.auth.permission.source-files-addon.policy=permit

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.kie.kogito.index.event.mapper;

import javax.enterprise.context.ApplicationScoped;

import org.kie.kogito.event.process.ProcessInstanceDataEvent;
import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent;
import org.kie.kogito.index.model.ProcessInstance;
import org.kie.kogito.index.model.ProcessInstanceError;

@ApplicationScoped
public class ProcessInstanceErrorDataEventMerger implements ProcessInstanceEventMerger {

@Override
public boolean accept(ProcessInstanceDataEvent<?> event) {
return event instanceof ProcessInstanceErrorDataEvent;
}

@Override
public void merge(ProcessInstance pi, ProcessInstanceDataEvent<?> data) {
ProcessInstanceErrorDataEvent event = (ProcessInstanceErrorDataEvent) data;
ProcessInstanceError error = new ProcessInstanceError();
error.setMessage(event.getData().getErrorMessage());
error.setNodeDefinitionId(event.getData().getNodeDefinitionId());
pi.setError(error);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.kie.kogito.index.event.mapper;

import org.kie.kogito.event.process.ProcessInstanceDataEvent;
import org.kie.kogito.index.model.ProcessInstance;

public interface ProcessInstanceEventMerger {

boolean accept(ProcessInstanceDataEvent<?> event);

void merge(ProcessInstance pi, ProcessInstanceDataEvent<?> event);

}
Loading

0 comments on commit c71d2ed

Please sign in to comment.