Clean up generics

This commit is contained in:
René Pfeuffer
2019-03-28 14:10:43 +01:00
parent 79be188777
commit df9e16c485
5 changed files with 25 additions and 21 deletions

View File

@@ -12,19 +12,20 @@ public class CloseableWrapperTest {
@Test
public void shouldExecuteGivenMethodAtClose() {
Consumer<String> wrapped = new Consumer<String>() {
Consumer<AutoCloseable> wrapped = new Consumer<AutoCloseable>() {
// no this cannot be replaced with a lambda because otherwise we could not use Mockito#spy
@Override
public void accept(String s) {
public void accept(AutoCloseable s) {
}
};
Consumer<String> closer = spy(wrapped);
Consumer<AutoCloseable> closer = spy(wrapped);
try (CloseableWrapper<String> wrapper = new CloseableWrapper<>("test", closer)) {
AutoCloseable autoCloseable = () -> {};
try (CloseableWrapper<AutoCloseable> wrapper = new CloseableWrapper<>(autoCloseable, closer)) {
// nothing to do here
}
verify(closer).accept("test");
verify(closer).accept(autoCloseable);
}
}