Code formatting

This commit is contained in:
maenolis 2023-11-15 08:36:28 +02:00
parent 7135047ba1
commit 2ed78462c8
3 changed files with 19 additions and 11 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}