TSK-1709: optimized other mockStatic calls to match recommendation

which is to use mockStatic together with a try-with-resources statement
This commit is contained in:
Mustapha Zorgati 2021-08-19 19:00:54 +02:00
parent 9d329c5a83
commit 3812e9e883
No known key found for this signature in database
GPG Key ID: BFF92FDA34CDC6FB
2 changed files with 8 additions and 9 deletions

View File

@ -2,9 +2,7 @@ package pro.taskana.common.internal.logging;
class LoggingTestClass {
public void logInternalMethod() {
System.out.println("PENIS");
}
public void logInternalMethod() {}
@SuppressWarnings("UnusedReturnValue")
public String logInternalMethodWithReturnValue() {

View File

@ -136,14 +136,15 @@ class QueryTasksAccTest extends AbstractAccTest {
@WithAccessId(user = "admin")
@Test
void should_SplitTaskListIntoChunksOf32000_When_AugmentingTasksAfterTaskQuery() {
MockedStatic<CollectionUtil> listUtilMock = Mockito.mockStatic(CollectionUtil.class);
listUtilMock
.when(() -> CollectionUtil.partitionBasedOnSize(any(), anyInt()))
.thenCallRealMethod();
try (MockedStatic<CollectionUtil> listUtilMock = Mockito.mockStatic(CollectionUtil.class)) {
listUtilMock
.when(() -> CollectionUtil.partitionBasedOnSize(any(), anyInt()))
.thenCallRealMethod();
TASK_SERVICE.createTaskQuery().list();
TASK_SERVICE.createTaskQuery().list();
listUtilMock.verify(() -> CollectionUtil.partitionBasedOnSize(any(), eq(32000)));
listUtilMock.verify(() -> CollectionUtil.partitionBasedOnSize(any(), eq(32000)));
}
}
@WithAccessId(user = "admin")