-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(failure): bpm failure tables (#3241)
Introduce 2 new tables in bonita DB schema: bpm_failure and arch_bpm_failure. Add associated PersistedObject and Service to create new failure. Closes BPM-308
- Loading branch information
Showing
26 changed files
with
533 additions
and
16 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...ration-tests-local/src/test/java/org/bonitasoft/engine/bpm/failure/FlowNodeFailureIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Copyright (C) 2024 Bonitasoft S.A. | ||
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble | ||
* This library is free software; you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation | ||
* version 2.1 of the License. | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License along with this | ||
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth | ||
* Floor, Boston, MA 02110-1301, USA. | ||
**/ | ||
package org.bonitasoft.engine.bpm.failure; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.bonitasoft.engine.TestWithUser; | ||
import org.bonitasoft.engine.bpm.flownode.FlowNodeInstance; | ||
import org.bonitasoft.engine.bpm.process.ActivationState; | ||
import org.bonitasoft.engine.bpm.process.DesignProcessDefinition; | ||
import org.bonitasoft.engine.bpm.process.ProcessDefinition; | ||
import org.bonitasoft.engine.bpm.process.ProcessDeploymentInfo; | ||
import org.bonitasoft.engine.bpm.process.ProcessInstance; | ||
import org.bonitasoft.engine.bpm.process.impl.ProcessDefinitionBuilder; | ||
import org.bonitasoft.engine.expression.ExpressionBuilder; | ||
import org.bonitasoft.engine.operation.LeftOperandBuilder; | ||
import org.bonitasoft.engine.operation.OperatorType; | ||
import org.bonitasoft.engine.service.ServiceAccessor; | ||
import org.bonitasoft.engine.service.impl.ServiceAccessorFactory; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class FlowNodeFailureIT extends TestWithUser { | ||
|
||
private ServiceAccessor serviceAccessor; | ||
|
||
@Override | ||
@Before | ||
public void before() throws Exception { | ||
super.before(); | ||
serviceAccessor = ServiceAccessorFactory.getInstance().createServiceAccessor(); | ||
} | ||
|
||
@Test | ||
public void create_a_failure_on_flownode_operation_exception() throws Exception { | ||
// Given a process failing on a flownode operation | ||
final DesignProcessDefinition designProcessDefinition = new ProcessDefinitionBuilder() | ||
.createNewInstance("My_Process_with_failed_flownode", PROCESS_VERSION) | ||
.addActor(ACTOR_NAME) | ||
.addAutomaticTask("step1") | ||
.addOperation(new LeftOperandBuilder().createDataLeftOperand("myData"), | ||
OperatorType.ASSIGNMENT, | ||
"", | ||
new ExpressionBuilder() | ||
.createGroovyScriptExpression("my-failing-script", | ||
"throw new RuntimeException('Failed !')", String.class.getName())) | ||
.getProcess(); | ||
final ProcessDefinition processDefinition = deployAndEnableProcessWithActor(designProcessDefinition, ACTOR_NAME, | ||
user); | ||
final ProcessDeploymentInfo processDeploymentInfo = getProcessAPI() | ||
.getProcessDeploymentInfo(processDefinition.getId()); | ||
assertEquals(ActivationState.ENABLED, processDeploymentInfo.getActivationState()); | ||
|
||
// When the flownode is executed | ||
final ProcessInstance processInstance = getProcessAPI().startProcess(processDeploymentInfo.getProcessId()); | ||
final FlowNodeInstance failFlowNodeInstance = waitForFlowNodeInFailedState(processInstance); | ||
|
||
// Then a failure is created | ||
assertEquals("step1", failFlowNodeInstance.getName()); | ||
var failureService = ServiceAccessorFactory.getInstance().createServiceAccessor().getBpmFailureService(); | ||
var failures = serviceAccessor.getTransactionService() | ||
.executeInTransaction(() -> failureService.getFlowNodeFailures(failFlowNodeInstance.getId(), 5)); | ||
assertThat(failures).hasSize(1); | ||
assertThat(failures.get(0).getErrorMessage()) | ||
.isEqualTo("java.lang.RuntimeException: Failed !"); | ||
disableAndDeleteProcess(processDefinition); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ance/src/main/java/org/bonitasoft/engine/core/process/instance/api/BpmFailureService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (C) 2024 Bonitasoft S.A. | ||
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble | ||
* This library is free software; you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation | ||
* version 2.1 of the License. | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License along with this | ||
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth | ||
* Floor, Boston, MA 02110-1301, USA. | ||
**/ | ||
package org.bonitasoft.engine.core.process.instance.api; | ||
|
||
import java.util.List; | ||
|
||
import org.bonitasoft.engine.core.process.instance.model.SBpmFailure; | ||
import org.bonitasoft.engine.core.process.instance.model.SFlowNodeInstance; | ||
import org.bonitasoft.engine.persistence.SBonitaReadException; | ||
import org.bonitasoft.engine.services.SPersistenceException; | ||
|
||
public interface BpmFailureService { | ||
|
||
void createFlowNodeFailure(SFlowNodeInstance flowNodeInstance, | ||
Failure failure) throws SPersistenceException; | ||
|
||
List<SBpmFailure> getFlowNodeFailures(long flowNodeInstanceId, int maxResults) throws SBonitaReadException; | ||
|
||
record Failure(String scope, String context, Throwable throwable){} | ||
} |
Oops, something went wrong.