Skip to content

Commit

Permalink
fixed issue with lambdaJ and CGLib when using Hamcrest assertions on …
Browse files Browse the repository at this point in the history
…collections
  • Loading branch information
wakaleo committed Apr 20, 2016
1 parent 2301044 commit 1e58704
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

import java.util.List;

import static ch.lambdaj.Lambda.extract;
import static ch.lambdaj.Lambda.on;

public class ErrorTally {

private final EventBusInterface eventBusInterface;
Expand All @@ -30,16 +27,28 @@ public void reportAnyErrors() {
return;
}
if (Serenity.shouldThrowErrorsImmediately()) {
throwSummaryExceptionFrom(extract(errors, on(FailedConsequence.class).getCause()));
throwSummaryExceptionFrom(errorCausesIn(errors));
}

}

private void throwSummaryExceptionFrom(List<Throwable> errorCauses) {
List<String> errorMessages = extract(errorCauses, on(Throwable.class).getMessage());
String overallErrorMessage = Joiner.on(System.lineSeparator()).join(errorMessages);
String overallErrorMessage = Joiner.on(System.lineSeparator()).join(errorMessagesIn(errorCauses));
throw new AssertionError(overallErrorMessage);
}

private List<Throwable> errorCausesIn(List<FailedConsequence> failedConsequences) {
List<Throwable> causes = Lists.newArrayList();
for(FailedConsequence consequence : failedConsequences) {
causes.add(consequence.getCause());
}
return causes;
}

private List<String> errorMessagesIn(List<Throwable> errorCauses) {
List<String> errorMessages = Lists.newArrayList();
for(Throwable cause : errorCauses) {
errorMessages.add(cause.getMessage());
}
return errorMessages;
}
}

0 comments on commit 1e58704

Please sign in to comment.