Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #2197] Adding count for jobs and process definitions #2200

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
extend type Query {
CountProcessInstances(where: ProcessInstanceArgument): Int
CountUserTaskInstances(where: UserTaskInstanceArgument): Int
CountJobs(where: JobArgument): Int
CountProcessDefinitions(where: ProcessDefinitionArgument): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@
*/
package org.kie.kogito.index.jpa.query;

import java.util.List;
import java.util.UUID;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;
import org.kie.kogito.index.jpa.storage.JobEntityStorage;
import org.kie.kogito.index.model.Job;
import org.kie.kogito.index.test.TestUtils;
import org.kie.kogito.index.test.query.AbstractJobQueryIT;
import org.kie.kogito.persistence.api.Storage;

import jakarta.inject.Inject;

import static org.assertj.core.api.Assertions.assertThat;
import static org.kie.kogito.persistence.api.query.QueryFilterFactory.equalTo;

public abstract class AbstractJobEntityQueryIT extends AbstractJobQueryIT {

@Inject
Expand All @@ -35,4 +44,13 @@ public Storage<String, Job> getStorage() {
return storage;
}

@Test
void testCount() {
String jobId = UUID.randomUUID().toString();
storage.put(jobId, TestUtils
.createJob(jobId, UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(),
RandomStringUtils.randomAlphabetic(10), "EXPECTED", 0L));
assertThat(storage.query().count()).isNotZero();
assertThat(storage.query().filter(List.of(equalTo("status", "UNEXPECTED"))).count()).isZero();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@
*/
package org.kie.kogito.index.jpa.query;

import java.util.List;
import java.util.Set;

import org.junit.jupiter.api.Test;
import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage;
import org.kie.kogito.index.model.ProcessDefinition;
import org.kie.kogito.index.model.ProcessDefinitionKey;
import org.kie.kogito.index.test.TestUtils;
import org.kie.kogito.index.test.query.AbstractProcessDefinitionQueryIT;
import org.kie.kogito.persistence.api.Storage;

import jakarta.inject.Inject;

import static org.assertj.core.api.Assertions.assertThat;
import static org.kie.kogito.persistence.api.query.QueryFilterFactory.equalTo;

public abstract class AbstractProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionQueryIT {

@Inject
Expand All @@ -36,4 +44,12 @@ public Storage<ProcessDefinitionKey, ProcessDefinition> getStorage() {
return storage;
}

@Test
void testCount() {
ProcessDefinition pdv1 = TestUtils.createProcessDefinition("items", "1.0", Set.of("admin", "kogito"));
storage.put(new ProcessDefinitionKey(pdv1.getId(), pdv1.getVersion()), pdv1);
assertThat(storage.query().count()).isNotZero();
assertThat(storage.query().filter(List.of(equalTo("version", "60.0"))).count()).isZero();
}

}