Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Sep 10, 2021
1 parent 0bd6feb commit efb980c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public void afterTestExecution(ExtensionContext context) {
Store store = context.getStore(NAMESPACE);
AtomicInteger argumentIndex = new AtomicInteger();

Arrays.stream(arguments) //
Arrays.stream(this.arguments) //
.filter(AutoCloseable.class::isInstance) //
.map(AutoCloseable.class::cast) //
.map(CloseableArgument::new) //
.forEach(closeable -> store.put("closeableArgument" + argumentIndex.getAndIncrement(), closeable));
.forEach(closeable -> store.put("closeableArgument#" + argumentIndex.incrementAndGet(), closeable));
}

private static class CloseableArgument implements Store.CloseableResource {
Expand All @@ -103,17 +103,16 @@ private static class CloseableArgument implements Store.CloseableResource {

@Override
public void close() throws Throwable {
autoCloseable.close();
this.autoCloseable.close();
}

}

@SuppressWarnings("unchecked")
private Object[] extractPayloads(Object[] arguments) {
return Arrays.stream(arguments) //
.map(argument -> {
if (argument instanceof Named) {
return ((Named<Object>) argument).getPayload();
return ((Named<?>) argument).getPayload();
}
return argument;
}) //
Expand Down

0 comments on commit efb980c

Please sign in to comment.