Skip to content

Commit

Permalink
TSK-1709: optimized other mockStatic calls to match recommendation
Browse files Browse the repository at this point in the history
which is to use mockStatic together with a try-with-resources statement
  • Loading branch information
mustaphazorgati committed Aug 19, 2021
1 parent 9d329c5 commit 3812e9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

class LoggingTestClass {

public void logInternalMethod() {
System.out.println("PENIS");
}
public void logInternalMethod() {}

@SuppressWarnings("UnusedReturnValue")
public String logInternalMethodWithReturnValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ void testQueryTaskValuesForColumnNameOnAttachments() {
@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")
Expand Down

0 comments on commit 3812e9e

Please sign in to comment.