any(List.class) to anyList()

This commit is contained in:
Ludy87 2025-05-25 22:11:23 +02:00
parent f2f11496a2
commit b4f4be11f9
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
2 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -13,7 +13,6 @@ import static org.mockito.Mockito.when;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -143,7 +142,7 @@ class CheckProgramInstallTest {
void testGetAvailablePythonCommand_WhenNoPythonIsAvailable() void testGetAvailablePythonCommand_WhenNoPythonIsAvailable()
throws IOException, InterruptedException { throws IOException, InterruptedException {
// Arrange // Arrange
when(mockExecutor.runCommandWithOutputHandling(any(List.class))) when(mockExecutor.runCommandWithOutputHandling(anyList()))
.thenThrow(new IOException("Command not found")); .thenThrow(new IOException("Command not found"));
// Act // Act
@ -171,7 +170,7 @@ class CheckProgramInstallTest {
String firstCall = CheckProgramInstall.getAvailablePythonCommand(); String firstCall = CheckProgramInstall.getAvailablePythonCommand();
// Change the mock to simulate a change in the environment // Change the mock to simulate a change in the environment
when(mockExecutor.runCommandWithOutputHandling(any(List.class))) when(mockExecutor.runCommandWithOutputHandling(anyList()))
.thenThrow(new IOException("Command not found")); .thenThrow(new IOException("Command not found"));
String secondCall = CheckProgramInstall.getAvailablePythonCommand(); String secondCall = CheckProgramInstall.getAvailablePythonCommand();

View File

@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -132,7 +133,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML)) .when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
.thenReturn(mockProcessExecutor); .thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class))) when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
.thenAnswer( .thenAnswer(
invocation -> { invocation -> {
// When command is executed, simulate creation of output files // When command is executed, simulate creation of output files
@ -175,7 +176,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML)) .when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
.thenReturn(mockProcessExecutor); .thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class))) when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
.thenAnswer( .thenAnswer(
invocation -> { invocation -> {
// When command is executed, simulate creation of output files // When command is executed, simulate creation of output files
@ -251,7 +252,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML)) .when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
.thenReturn(mockProcessExecutor); .thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class))) when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
.thenAnswer( .thenAnswer(
invocation -> { invocation -> {
// When command is executed, simulate creation of output files // When command is executed, simulate creation of output files
@ -537,7 +538,7 @@ class PDFToFileTest {
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.LIBRE_OFFICE)) .when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.LIBRE_OFFICE))
.thenReturn(mockProcessExecutor); .thenReturn(mockProcessExecutor);
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class))) when(mockProcessExecutor.runCommandWithOutputHandling(anyList()))
.thenAnswer( .thenAnswer(
invocation -> { invocation -> {
// When command is executed, find the output directory argument // When command is executed, find the output directory argument