diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/prefix/CmmnPrefixTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/prefix/CmmnPrefixTest.java index db9c9d75ce3..2577f62a466 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/prefix/CmmnPrefixTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/prefix/CmmnPrefixTest.java @@ -32,18 +32,13 @@ import org.flowable.task.api.Task; import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.variable.api.history.HistoricVariableInstance; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * @author Joram Barrez */ public class CmmnPrefixTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void testPrefixCase() { CmmnEngine cmmnEngine = null; diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/CaseInstanceInvolvementTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/CaseInstanceInvolvementTest.java index 66df8a1fe8c..5423e0cfe6e 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/CaseInstanceInvolvementTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/CaseInstanceInvolvementTest.java @@ -14,6 +14,7 @@ package org.flowable.cmmn.test.runtime; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.Collections; import java.util.HashSet; @@ -28,18 +29,13 @@ import org.flowable.common.engine.api.FlowableIllegalArgumentException; import org.flowable.common.engine.impl.AbstractEngineConfiguration; import org.flowable.identitylink.api.IdentityLinkType; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * @author martin.grofcik */ public class CaseInstanceInvolvementTest extends FlowableCmmnTestCase { - @Rule - public ExpectedException expectException = ExpectedException.none(); - @Test @CmmnDeployment(resources = "org/flowable/cmmn/test/runtime/oneTaskCase.cmmn") public void getCaseInstanceWithInvolvedUser() { @@ -94,26 +90,23 @@ public void getCaseInstanceWithNonExistingInvolvedUser() { @Test public void getCaseInstanceWithNullInvolvedUser() { - this.expectException.expect(FlowableIllegalArgumentException.class); - this.expectException.expectMessage("involvedUser is null"); - - cmmnRuntimeService.createCaseInstanceQuery().involvedUser(null); + assertThatThrownBy(() -> cmmnRuntimeService.createCaseInstanceQuery().involvedUser(null)) + .isInstanceOf(FlowableIllegalArgumentException.class) + .hasMessage("involvedUser is null"); } @Test public void getCaseInstanceWithNullInvolvedGroups() { - this.expectException.expect(FlowableIllegalArgumentException.class); - this.expectException.expectMessage("involvedGroups are null"); - - cmmnRuntimeService.createCaseInstanceQuery().involvedGroups(null); + assertThatThrownBy(() -> cmmnRuntimeService.createCaseInstanceQuery().involvedGroups(null)) + .isInstanceOf(FlowableIllegalArgumentException.class) + .hasMessage("involvedGroups are null"); } @Test public void getCaseInstanceWithEmptyInvolvedGroups() { - this.expectException.expect(FlowableIllegalArgumentException.class); - this.expectException.expectMessage("involvedGroups are empty"); - - cmmnRuntimeService.createCaseInstanceQuery().involvedGroups(Collections.emptySet()); + assertThatThrownBy(() -> cmmnRuntimeService.createCaseInstanceQuery().involvedGroups(Collections.emptySet())) + .isInstanceOf(FlowableIllegalArgumentException.class) + .hasMessage("involvedGroups are empty"); } @Test @@ -124,10 +117,9 @@ public void getCaseInstanceWithNonNullInvolvedUser() { start(); cmmnRuntimeService.addUserIdentityLink(caseInstance.getId(), "kermit", IdentityLinkType.PARTICIPANT); - this.expectException.expect(FlowableIllegalArgumentException.class); - this.expectException.expectMessage("involvedUser is null"); - - cmmnRuntimeService.createCaseInstanceQuery().involvedUser(null).count(); + assertThatThrownBy(() -> cmmnRuntimeService.createCaseInstanceQuery().involvedUser(null)) + .isInstanceOf(FlowableIllegalArgumentException.class) + .hasMessage("involvedUser is null"); } @Test diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/VariablesTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/VariablesTest.java index c133aae26a6..84644bf60d2 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/VariablesTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/VariablesTest.java @@ -14,6 +14,7 @@ import static java.util.stream.Collectors.toMap; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.entry; import java.io.Serializable; @@ -54,18 +55,13 @@ import org.flowable.variable.api.types.VariableType; import org.flowable.variable.service.VariableServiceConfiguration; import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * @author Joram Barrez */ public class VariablesTest extends FlowableCmmnTestCase { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test @CmmnDeployment public void testGetVariables() { @@ -437,19 +433,17 @@ public void testSetVariableOnRootCase() { @Test @CmmnDeployment(resources = "org/flowable/cmmn/test/task/CmmnTaskServiceTest.testOneHumanTaskCase.cmmn") public void testSetVariableOnNonExistingCase() { - this.expectedException.expect(FlowableObjectNotFoundException.class); - this.expectedException.expectMessage("No case instance found for id NON-EXISTING-CASE"); - - cmmnRuntimeService.setVariable("NON-EXISTING-CASE", "varToUpdate", "newValue"); + assertThatThrownBy(() -> cmmnRuntimeService.setVariable("NON-EXISTING-CASE", "varToUpdate", "newValue")) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessage("No case instance found for id NON-EXISTING-CASE"); } @Test @CmmnDeployment(resources = "org/flowable/cmmn/test/task/CmmnTaskServiceTest.testOneHumanTaskCase.cmmn") public void testSetVariableWithoutName() { - this.expectedException.expect(FlowableIllegalArgumentException.class); - this.expectedException.expectMessage("variable name is null"); - - cmmnRuntimeService.setVariable("NON-EXISTING-CASE", null, "newValue"); + assertThatThrownBy(() -> cmmnRuntimeService.setVariable("NON-EXISTING-CASE", null, "newValue")) + .isInstanceOf(FlowableIllegalArgumentException.class) + .hasMessage("variable name is null"); } @Test @@ -513,13 +507,13 @@ public void testSetVariablesOnRootCase() { @Test @CmmnDeployment(resources = "org/flowable/cmmn/test/task/CmmnTaskServiceTest.testOneHumanTaskCase.cmmn") public void testSetVariablesOnNonExistingCase() { - this.expectedException.expect(FlowableObjectNotFoundException.class); - this.expectedException.expectMessage("No case instance found for id NON-EXISTING-CASE"); Map variables = Stream.of(new ImmutablePair("varToUpdate", "newValue")).collect( toMap(Pair::getKey, Pair::getValue) ); - cmmnRuntimeService.setVariables("NON-EXISTING-CASE", variables); + assertThatThrownBy(() -> cmmnRuntimeService.setVariables("NON-EXISTING-CASE", variables)) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessage("No case instance found for id NON-EXISTING-CASE"); } @SuppressWarnings("unchecked") @@ -531,10 +525,9 @@ public void testSetVariablesWithEmptyMap() { .caseDefinitionKey("oneHumanTaskCase") .start(); - this.expectedException.expect(FlowableIllegalArgumentException.class); - this.expectedException.expectMessage("variables is empty"); - - cmmnRuntimeService.setVariables(caseInstance.getId(), Collections.EMPTY_MAP); + assertThatThrownBy(() -> cmmnRuntimeService.setVariables(caseInstance.getId(), Collections.EMPTY_MAP)) + .isInstanceOf(FlowableIllegalArgumentException.class) + .hasMessage("variables is empty"); } @Test diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/task/CmmnTaskServiceTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/task/CmmnTaskServiceTest.java index ff19b7611cc..aaf67f238a5 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/task/CmmnTaskServiceTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/task/CmmnTaskServiceTest.java @@ -51,9 +51,7 @@ import org.flowable.task.api.Task; import org.flowable.task.api.TaskQuery; import org.flowable.task.api.history.HistoricTaskInstance; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * @author Joram Barrez @@ -61,9 +59,6 @@ */ public class CmmnTaskServiceTest extends FlowableCmmnTestCase { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test @CmmnDeployment public void testOneHumanTaskCase() { @@ -167,12 +162,12 @@ public void testOneHumanTaskVariableScopeExpressionCase() { CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start(); Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("Error while evaluating expression: ${caseInstance.name}"); - cmmnTaskService.complete(task.getId(), Collections.singletonMap( + assertThatThrownBy(() -> cmmnTaskService.complete(task.getId(), Collections.singletonMap( "${caseInstance.name}", "newCaseName" ) - ); + )) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("Error while evaluating expression: ${caseInstance.name}"); } @Test @@ -181,12 +176,12 @@ public void testOneHumanTaskCompleteSetCaseName() { CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start(); Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("Error while evaluating expression: ${name}"); - cmmnTaskService.complete(task.getId(), Collections.singletonMap( + assertThatThrownBy(() -> cmmnTaskService.complete(task.getId(), Collections.singletonMap( "${name}", "newCaseName" ) - ); + )) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("Error while evaluating expression: ${name}"); } @Test diff --git a/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/MixedDeploymentTest.java b/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/MixedDeploymentTest.java index f38805847d3..3c88b5d1d4d 100644 --- a/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/MixedDeploymentTest.java +++ b/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/MixedDeploymentTest.java @@ -32,9 +32,7 @@ import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.test.Deployment; import org.flowable.variable.api.history.HistoricVariableInstance; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * @author Yvo Swillens @@ -42,9 +40,6 @@ */ public class MixedDeploymentTest extends AbstractFlowableDmnEngineConfiguratorTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test @Deployment(resources = { "org/flowable/dmn/engine/test/deployment/oneDecisionTaskProcess.bpmn20.xml", "org/flowable/dmn/engine/test/deployment/simple.dmn" }) @@ -155,10 +150,9 @@ public void testDecisionTaskExecutionWithGlobalTenantFallback() { @Deployment(resources = { "org/flowable/dmn/engine/test/deployment/oneDecisionTaskProcess.bpmn20.xml" } ) public void testDecisionTaskExecutionInAnotherDeploymentAndTenantDefaultBehavior() { - this.expectedException.expect(FlowableObjectNotFoundException.class); - this.expectedException.expectMessage("Process definition with key 'oneDecisionTaskProcess' and tenantId 'flowable' was not found"); - - deployDecisionAndAssertProcessExecuted(); + assertThatThrownBy(this::deployDecisionAndAssertProcessExecuted) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessageContaining("Process definition with key 'oneDecisionTaskProcess' and tenantId 'flowable' was not found"); } @Test @@ -166,11 +160,9 @@ public void testDecisionTaskExecutionInAnotherDeploymentAndTenantDefaultBehavior tenantId = "flowable" ) public void testDecisionTaskExecutionInAnotherDeploymentAndTenantFalse() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("No decision found for key: decision1"); - this.expectedException.expectMessage("and tenant id: flowable"); - - deployDecisionAndAssertProcessExecuted(); + assertThatThrownBy(this::deployDecisionAndAssertProcessExecuted) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessageContainingAll("No decision found for key: decision1", "and tenant id: flowable"); } @Test @@ -178,17 +170,15 @@ public void testDecisionTaskExecutionInAnotherDeploymentAndTenantFalse() { tenantId = "flowable" ) public void testDecisionTaskExecutionInAnotherDeploymentAndTenantFallbackFalseWithoutDeployment() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("No decision found for key: decision1"); - this.expectedException.expectMessage("and tenant id: flowable"); - deleteAllDmnDeployments(); org.flowable.engine.repository.Deployment deployment = repositoryService.createDeployment(). addClasspathResource("org/flowable/dmn/engine/test/deployment/simple.dmn"). tenantId("anotherTenant"). deploy(); try { - assertDmnProcessExecuted(); + assertThatThrownBy(this::assertDmnProcessExecuted) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessageContainingAll("No decision found for key: decision1", "and tenant id: flowable"); } finally { this.repositoryService.deleteDeployment(deployment.getId(), true); deleteAllDmnDeployments(); @@ -200,15 +190,14 @@ public void testDecisionTaskExecutionInAnotherDeploymentAndTenantFallbackFalseWi tenantId = "flowable" ) public void testDecisionTaskExecutionInAnotherDeploymentAndTenantFallbackTrueWithoutDeployment() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("No decision found for key: decision1. There was also no fall back decision table found without tenant."); - org.flowable.engine.repository.Deployment deployment = repositoryService.createDeployment(). addClasspathResource("org/flowable/dmn/engine/test/deployment/simple.dmn"). tenantId("anotherTenant"). deploy(); try { - assertDmnProcessExecuted(); + assertThatThrownBy(this::assertDmnProcessExecuted) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessageContaining("No decision found for key: decision1. There was also no fall back decision table found without tenant."); } finally { this.repositoryService.deleteDeployment(deployment.getId(), true); deleteAllDmnDeployments(); diff --git a/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/test/runtime/DecisionTaskTest.java b/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/test/runtime/DecisionTaskTest.java index a089ce65dfd..7abd98a0cd5 100644 --- a/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/test/runtime/DecisionTaskTest.java +++ b/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/test/runtime/DecisionTaskTest.java @@ -13,6 +13,7 @@ package org.flowable.dmn.test.runtime; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.List; import java.util.Map; @@ -35,7 +36,6 @@ import org.junit.After; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -53,9 +53,6 @@ public class DecisionTaskTest { @Rule public FlowableCmmnRule cmmnRule = new FlowableCmmnRule("org/flowable/cmmn/test/runtime/DecisionTaskTest.cfg.xml"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @After public void tearDown() { deleteAllDmnDeployments(); @@ -83,14 +80,11 @@ public void testDecisionServiceTask() { } ) public void testUnknowPropertyUsedInDmn() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("DMN decision with key decisionTable execution failed. Cause: Unknown property used in expression: #{testVar == \"test2\"}"); - - CaseInstance caseInstance = cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() + assertThatThrownBy(() -> cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() .caseDefinitionKey("myCase") - .start(); - - assertResultVariable(caseInstance); + .start()) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("DMN decision with key decisionTable execution failed. Cause: Unknown property used in expression: #{testVar == \"test2\"}"); } @Test @@ -163,14 +157,13 @@ public void testThrowErrorOnNoHitWithHit() { } ) public void testThrowErrorOnNoHit() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("DMN decision with key decisionTable did not hit any rules for the provided input."); - - cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() + assertThatThrownBy(() -> cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() .variable("throwErrorOnNoHits", true) .variable("testVar", "noHit") .caseDefinitionKey("myCase") - .start(); + .start()) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("DMN decision with key decisionTable did not hit any rules for the provided input."); } @Test @@ -210,14 +203,13 @@ public void testExpressionReferenceKey() { resources = {"org/flowable/cmmn/test/runtime/DecisionTaskTest.testExpressionReferenceKey.cmmn"} ) public void testNullReferenceKey() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("Could not execute decision: no externalRef defined"); - - cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() + assertThatThrownBy(() -> cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() .caseDefinitionKey("myCase") .variable("testVar", "test2") .variable("referenceKey", null) - .start(); + .start()) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("Could not execute decision: no externalRef defined"); } @Test @@ -225,14 +217,13 @@ public void testNullReferenceKey() { resources = {"org/flowable/cmmn/test/runtime/DecisionTaskTest.testExpressionReferenceKey.cmmn"} ) public void testNonStringReferenceKey() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("No decision found for key: 1 and parent deployment id"); - - cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() + assertThatThrownBy(() -> cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() .caseDefinitionKey("myCase") .variable("testVar", "test2") .variable("referenceKey", 1) - .start(); + .start()) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("No decision found for key: 1 and parent deployment id"); } @Test @@ -240,14 +231,13 @@ public void testNonStringReferenceKey() { resources = {"org/flowable/cmmn/test/runtime/DecisionTaskTest.testExpressionReferenceKey.cmmn"} ) public void testNonExistingReferenceKey() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("No decision found for key: NonExistingReferenceKey and parent deployment id"); - - cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() + assertThatThrownBy(() -> cmmnRule.getCmmnRuntimeService().createCaseInstanceBuilder() .caseDefinitionKey("myCase") .variable("testVar", "test2") .variable("referenceKey", "NonExistingReferenceKey") - .start(); + .start()) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("No decision found for key: NonExistingReferenceKey and parent deployment id"); } @Test @@ -303,10 +293,9 @@ public void testDecisionServiceTaskWithFallback() { tenantId = "flowable" ) public void testDecisionServiceTaskWithFallbackFalse() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("and tenant id: flowable. There was also no fall back decision found without parent deployment id."); - - deployDmnTableAssertCaseStarted(); + assertThatThrownBy(this::deployDmnTableAssertCaseStarted) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("and tenant id: flowable. There was also no fall back decision found without parent deployment id."); } @Test @@ -324,10 +313,9 @@ public void testDecisionServiceTaskWithGlobalTenantFallback() { tenantId = "flowable" ) public void testDecisionServiceTaskWithGlobalTenantFallbackNoDefinition() { - this.expectedException.expect(FlowableException.class); - this.expectedException.expectMessage("There was also no fall back decision found for default tenant defaultFlowable"); - - deployDmnTableWithGlobalTenantFallback("otherTenant"); + assertThatThrownBy(() -> deployDmnTableWithGlobalTenantFallback("otherTenant")) + .isInstanceOf(FlowableException.class) + .hasMessageContaining("There was also no fall back decision found for default tenant defaultFlowable"); } @Test diff --git a/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/runtime/DecisionTableExecutionFallBackTest.java b/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/runtime/DecisionTableExecutionFallBackTest.java index 50d38a03fd7..5f8af34dce9 100644 --- a/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/runtime/DecisionTableExecutionFallBackTest.java +++ b/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/runtime/DecisionTableExecutionFallBackTest.java @@ -13,6 +13,7 @@ package org.flowable.dmn.engine.test.runtime; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.HashMap; import java.util.Map; @@ -23,9 +24,7 @@ import org.flowable.dmn.engine.test.AbstractFlowableDmnTest; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * This class tests fallbacks in {@link org.flowable.dmn.engine.impl.cmd.AbstractExecuteDecisionCmd} @@ -36,9 +35,6 @@ public static final String TEST_TENANT_ID = "testTenantId"; public static final String TEST_PARENT_DEPLOYMENT_ID = "testParentDeploymentId"; - @Rule - public ExpectedException expectedException = ExpectedException.none(); - protected DmnDeployment deployment; @Before @@ -72,19 +68,16 @@ public void fallBackDecisionKeyDeploymentIdTenantIdWrongDeploymentId() { @Test public void decisionKeyDeploymentIdTenantIdWrongTenantIdThrowsException() { - expectedException.expect(FlowableObjectNotFoundException.class); - expectedException.expectMessage("No decision found for key: decision1, parent deployment id testParentDeploymentId and tenant id: WRONG_TENANT_ID."); - - executeDecision("WRONG_TENANT_ID", TEST_PARENT_DEPLOYMENT_ID); + assertThatThrownBy(() -> executeDecision("WRONG_TENANT_ID", TEST_PARENT_DEPLOYMENT_ID)) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessageContaining("No decision found for key: decision1, parent deployment id testParentDeploymentId and tenant id: WRONG_TENANT_ID."); } @Test public void decisionKeyTenantIdWrongTenantIdThrowsException() { - expectedException.expect(FlowableObjectNotFoundException.class); - expectedException.expectMessage("No decision found for key: decision1"); - expectedException.expectMessage("and tenantId: WRONG_TENANT_ID"); - - executeDecision("WRONG_TENANT_ID", null); + assertThatThrownBy(() -> executeDecision("WRONG_TENANT_ID", null)) + .isInstanceOf(FlowableObjectNotFoundException.class) + .hasMessage("No decision found for key: decision1 and tenantId: WRONG_TENANT_ID."); } @Test