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

[JBPM-10046] Missing PreUndeployOperations.doNothing call for development mode and no dispose flag #2753

Merged
merged 1 commit into from
Mar 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ public void disposeContainer(String id, KieContainerInstance kieContainerInstanc

if (isDispose) {
deploymentService.undeploy(new CustomIdKmoduleDeploymentUnit(id, unit.getGroupId(), unit.getArtifactId(), unit.getVersion()), PreUndeployOperations.abortUnitActiveProcessInstances(runtimeDataService, deploymentService));
} else if (isDevelopmentMode()){
deploymentService.undeploy(new CustomIdKmoduleDeploymentUnit(id, unit.getGroupId(), unit.getArtifactId(), unit.getVersion()), PreUndeployOperations.doNothing());
} else {
deploymentService.undeploy(new CustomIdKmoduleDeploymentUnit(id, unit.getGroupId(), unit.getArtifactId(), unit.getVersion()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.jbpm.services.api.model.ProcessInstanceDesc;
import org.jbpm.services.api.query.QueryService;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -75,6 +76,7 @@
import org.mockito.stubbing.Answer;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
Expand Down Expand Up @@ -257,6 +259,7 @@ private void testDispose(KieServerMode mode, boolean abort) throws IOException {
if (abort) {
verify(deploymentService).undeploy(any(), beforeUndeployCaptor.capture());
Function<DeploymentUnit, Boolean> function = beforeUndeployCaptor.getValue();
Assert.assertNotNull(function);
function.apply(deploymentUnit);

verify(runtimeDataService).getProcessInstancesByDeploymentId(eq(CONTAINER_ID), anyList(), any());
Expand All @@ -265,7 +268,14 @@ private void testDispose(KieServerMode mode, boolean abort) throws IOException {
verify(session, times(activeProcessInstances.size())).abortProcessInstance(eq(new Long(1)));
verify(runimeManager, times(activeProcessInstances.size())).disposeRuntimeEngine(any());
} else {
verify(deploymentService).undeploy(any());
if (mode.equals(KieServerMode.PRODUCTION)) {
verify(deploymentService).undeploy(any());
} else {
verify(deploymentService).undeploy(any(), beforeUndeployCaptor.capture());
Function<DeploymentUnit, Boolean> function = beforeUndeployCaptor.getValue();
assertNotNull(function);
function.apply(deploymentUnit);
}
}

}
Expand Down Expand Up @@ -451,8 +461,13 @@ private void testUpdateContainer(KieServerMode mode, String version, boolean cle
if (mode.equals(KieServerMode.PRODUCTION)) {
verify(deploymentService).undeploy(any());
} else {
verify(deploymentService).undeploy(any());
verify(deploymentService).undeploy(any(), beforeUndeployCaptor.capture());

Function<DeploymentUnit, Boolean> function = beforeUndeployCaptor.getValue();

assertNotNull(function);

assertTrue(function.apply(deploymentUnit));

verify(runtimeDataService, never()).getProcessInstancesByDeploymentId(eq(CONTAINER_ID), anyList(), any());
verify(runimeManager, never()).getRuntimeEngine(any());
Expand Down