Skip to content

Commit

Permalink
Removed the HappyPath.happyAttempt method that took an Attempt<Happy>…
Browse files Browse the repository at this point in the history
… parameter (closes #12)
  • Loading branch information
theangrydev committed Nov 18, 2016
1 parent 56fafa7 commit 3857666
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ There is no point in using this if your flows are "all or nothing". If there are
<dependency>
<groupId>io.github.theangrydev</groupId>
<artifactId>business-flows</artifactId>
<version>8.3.0</version>
<version>9.0.0</version>
</dependency>
```

## Releases
### 9.0.0
* Removed the `HappyPath.happyAttempt` method that took an `Attempt<Happy>` parameter (closes [#12](https://github.com/theangrydev/business-flows/issues/12)). This change is not backwards compatible. The recommended alternative is described in the migration advice, which can be found [here](https://github.com/theangrydev/business-flows/wiki/9.0.0-Migration-Advice)

### 8.3.0
* Add methods `consume` and `consumeOrThrow` to end a flow by performing some action that ends in a void (closes [#8](https://github.com/theangrydev/business-flows/issues/8))

Expand Down
16 changes: 0 additions & 16 deletions src/main/java/io/github/theangrydev/businessflows/HappyPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ static <Happy, Sad> HappyPath<Happy, Sad> happyPathAttempt(Attempt<HappyPath<Hap
}
}

/**
* Attempt an action that produces a {@link Happy}.
*
* @param attempt The {@link Attempt} to execute
* @param <Happy> The type of happy object this {@link HappyPath} may represent
* @param <Sad> The type of sad object this {@link HappyPath} may represent
* @return A {@link HappyPath} that is either happy on the inside or a technical failure
*/
static <Happy, Sad> HappyPath<Happy, Sad> happyAttempt(Attempt<Happy> attempt) {
try {
return happyPath(attempt.attempt());
} catch (Exception technicalFailure) {
return technicalFailure(technicalFailure);
}
}

/**
* Attempt an action that produces a {@link Happy}, mapping any technical failure to a {@link Sad}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ public void happyPathAttemptThatFailsResultsInTechnicalFailure() {
assertThat(actualTechnicalFailure).isSameAs(technicalFailure);
}

@Test
public void happyAttemptThatSucceedsWithNoFailureMappingResultsInHappy() {
Happy originalHappy = new Happy();

Happy actualHappy = HappyPath.happyAttempt(() -> originalHappy).get();

assertThat(actualHappy).isSameAs(originalHappy);
}

@Test
public void happyAttemptThatSucceedsWithNoSadFailureMappingResultsInHappy() {
Happy originalHappy = new Happy();
Expand All @@ -97,16 +88,6 @@ public void happyAttemptThatSucceedsWithNoSadFailureMappingResultsInHappy() {
assertThat(actualHappy).isSameAs(originalHappy);
}

@Test
public void happyAttemptThatFailsWithUncaughtExceptionIsATechnicalFailure() {
Exception exceptionDuringAttempt = new Exception();

Exception actualException = HappyPath.happyAttempt(() -> {throw exceptionDuringAttempt;})
.ifTechnicalFailure().get();

assertThat(actualException).isSameAs(exceptionDuringAttempt);
}

@Test
public void happyAttemptThatFailsWithUncaughtExceptionIsASadPath() {
Sad expectedSad = new Sad();
Expand Down

0 comments on commit 3857666

Please sign in to comment.