Code formatting
This commit is contained in:
parent
7135047ba1
commit
2ed78462c8
|
@ -9,16 +9,18 @@ public class LambdaSupplierUnitTest {
|
|||
|
||||
@Test
|
||||
public void whenCalledMultipleTimes_thenShouldBeCalledMultipleTimes() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Supplier<String> mockedExpensiveFunction = Mockito.mock(Supplier.class);
|
||||
Mockito.when(mockedExpensiveFunction.get()).thenReturn("expensive call");
|
||||
@SuppressWarnings("unchecked") Supplier<String> mockedExpensiveFunction = Mockito.mock(Supplier.class);
|
||||
Mockito.when(mockedExpensiveFunction.get())
|
||||
.thenReturn("expensive call");
|
||||
LambdaSupplier<String> testee = new LambdaSupplier<>(mockedExpensiveFunction);
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.never()).get();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.never())
|
||||
.get();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.times(4)).get();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.times(4))
|
||||
.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,14 +10,17 @@ public class LazyLambdaSupplierUnitTest {
|
|||
@Test
|
||||
public void whenCalledMultipleTimes_thenShouldBeCalledOnlyOnce() {
|
||||
@SuppressWarnings("unchecked") Supplier<String> mockedExpensiveFunction = Mockito.mock(Supplier.class);
|
||||
Mockito.when(mockedExpensiveFunction.get()).thenReturn("expensive call");
|
||||
Mockito.when(mockedExpensiveFunction.get())
|
||||
.thenReturn("expensive call");
|
||||
LazyLambdaSupplier<String> testee = new LazyLambdaSupplier<>(mockedExpensiveFunction);
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.never()).get();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.never())
|
||||
.get();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.times(1)).get();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.times(1))
|
||||
.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,14 +10,17 @@ public class LazyLambdaThreadSafeSupplierUnitTest {
|
|||
@Test
|
||||
public void whenCalledMultipleTimes_thenShouldBeCalledOnlyOnce() {
|
||||
@SuppressWarnings("unchecked") Supplier<String> mockedExpensiveFunction = Mockito.mock(Supplier.class);
|
||||
Mockito.when(mockedExpensiveFunction.get()).thenReturn("expensive call");
|
||||
Mockito.when(mockedExpensiveFunction.get())
|
||||
.thenReturn("expensive call");
|
||||
LazyLambdaThreadSafeSupplier<String> testee = new LazyLambdaThreadSafeSupplier<>(mockedExpensiveFunction);
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.never()).get();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.never())
|
||||
.get();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
testee.getData();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.times(1)).get();
|
||||
Mockito.verify(mockedExpensiveFunction, Mockito.times(1))
|
||||
.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue