Skip to content

Commit

Permalink
[JBPM-9867] Add parameterized test with NONE audit mode (#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmunozfe authored Sep 6, 2021
1 parent e2b54f7 commit ff1a56c
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2021 Red Hat, Inc. and/or its affiliates.
*
* Licensed 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.jbpm.kie.services.test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.drools.compiler.kie.builder.impl.InternalKieModule;
import org.kie.api.KieServices;
import org.kie.api.builder.ReleaseId;
import org.kie.internal.runtime.conf.DeploymentDescriptor;
import org.kie.internal.runtime.manager.deploy.DeploymentDescriptorImpl;
import static org.kie.internal.runtime.conf.AuditMode.NONE;

public class UserTaskServiceImplAuditNoneTest extends UserTaskServiceImplTest {

@Override
protected InternalKieModule createKJAR(KieServices ks, ReleaseId releaseId, List<String> processes) {
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().auditMode(NONE);

Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());

return createKieJar(ks, releaseId, processes, resources);
}

@Override
protected boolean isJPAAuditMode() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import static org.kie.internal.runtime.conf.AuditMode.JPA;
import static org.kie.scanner.KieMavenRepository.getKieMavenRepository;

public class UserTaskServiceImplTest extends AbstractKieServicesBaseTest {
Expand All @@ -94,7 +96,7 @@ public void prepare() {
processes.add("repo/processes/general/NoFormNameHumanTask.bpmn");
processes.add("repo/processes/general/BPMN2-UserTaskImageVar.bpmn2");

InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
InternalKieModule kJar1 = createKJAR(ks, releaseId, processes);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
Expand All @@ -116,6 +118,10 @@ public void prepare() {
assertNotNull(processService);

}

protected InternalKieModule createKJAR(KieServices ks, ReleaseId releaseId, List<String> processes) {
return createKieJar(ks, releaseId, processes);
}

@After
public void cleanup() {
Expand Down Expand Up @@ -328,7 +334,7 @@ public void testStartAndForward() {
task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Ready.toString(), task.getStatus());
assertEquals("", task.getActualOwner());
assertTrue(task.getActualOwner() == null || task.getActualOwner().isEmpty());
}

@Test
Expand Down Expand Up @@ -683,6 +689,8 @@ public void testGetTask() {

@Test
public void testGetTaskOfAbortedProcess() {
skipIfAuditModeIsNotJPA();

processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument.noform");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
Expand All @@ -706,7 +714,7 @@ public void testGetTaskOfAbortedProcess() {
assertTrue(StringUtils.isEmpty(((InternalTask)taskInstance).getFormName()));

}

@Test
public void testUpdateTask() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
Expand Down Expand Up @@ -748,6 +756,8 @@ public void testUpdateTask() {

@Test
public void testUpdateTaskWithData() {
skipIfAuditModeIsNotJPA();

TaskAuditService taskAuditService = getTaskAuditService();

processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
Expand Down Expand Up @@ -866,6 +876,8 @@ public void testUpdateTaskPermissionDenied() {

@Test
public void testProcessWithLazyLoadedVariable() {
skipIfAuditModeIsNotJPA();

identityProvider.setName("john");
Image newImage = new Image("test");
Map<String, Object> params = new HashMap<>();
Expand Down Expand Up @@ -918,6 +930,8 @@ public void testProcessWithLazyLoadedVariable() {

@Test
public void testTaskOperationWithUserOrWithIdentityProvider() {
skipIfAuditModeIsNotJPA();

processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);

Expand Down Expand Up @@ -1006,6 +1020,15 @@ public void testCompleteAutoProgressWrongDeploymentId() {
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Ready.toString(), task.getStatus());
assertCorrelationAndProcess(task, processInstanceId);
if (isJPAAuditMode())
assertCorrelationAndProcess(task, processInstanceId);
}

protected void skipIfAuditModeIsNotJPA() {
assumeTrue("skip if audit mode is not JPA", isJPAAuditMode());
}

protected boolean isJPAAuditMode() {
return true;
}
}

0 comments on commit ff1a56c

Please sign in to comment.