Skip to content

Commit

Permalink
test: adding a test for previous fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rottebds committed Jan 6, 2020
1 parent c5e00ca commit 9cfaa7d
Showing 1 changed file with 53 additions and 0 deletions.
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();
}

}

0 comments on commit 9cfaa7d

Please sign in to comment.