-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adding a test for previous fix
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/test/java/com/synopsys/integration/stepworkflow/StepWorkflowTest.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,53 @@ | ||
package com.synopsys.integration.stepworkflow; | ||
|
||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.synopsys.integration.exception.IntegrationException; | ||
|
||
public class StepWorkflowTest { | ||
public static final Integer DATA = 1; | ||
|
||
@Test | ||
public void testSuccessfulSingleStepDataStepWorkflow() { | ||
StepWorkflowResponse<Integer> response = StepWorkflow.just(SubStep.ofSupplier(this::successfulDataSupplier)) | ||
.run(); | ||
|
||
Assert.assertTrue(response.wasSuccessful()); | ||
Assert.assertEquals(DATA, response.getData()); | ||
Assert.assertNull(response.getException()); | ||
} | ||
|
||
@Test | ||
public void testSuccessfulSingleStepDatalessStepWorkflow() { | ||
StepWorkflowResponse response = StepWorkflow.just(SubStep.ofExecutor(this::successfulExecutor)) | ||
.run(); | ||
|
||
Assert.assertTrue(response.wasSuccessful()); | ||
Assert.assertNull(response.getData()); | ||
Assert.assertNull(response.getException()); | ||
} | ||
|
||
@Test | ||
public void testUnsuccessfulSingleStepStepWorkflow() { | ||
StepWorkflowResponse<Integer> response = StepWorkflow.just(SubStep.ofSupplier(this::unsuccessfulDataSupplier)) | ||
.run(); | ||
|
||
Assert.assertFalse(response.wasSuccessful()); | ||
Assert.assertNull(response.getData()); | ||
Assert.assertNotNull(response.getException()); | ||
} | ||
|
||
private void successfulExecutor() { | ||
// No body, should always succeed. | ||
} | ||
|
||
private Integer successfulDataSupplier() { | ||
return DATA; | ||
} | ||
|
||
private Integer unsuccessfulDataSupplier() throws IntegrationException { | ||
throw new IntegrationException(); | ||
} | ||
|
||
} |