JAVA-33535: Fix errors after mockito upgrade. (#16389)
* Fix eureka-client * Fix eureka-server * Fix spring-cloud-zuul * Fix spring-reactive-data-couchbase * Fix and cleanup apache-poi
This commit is contained in:
+4
-2
@@ -14,14 +14,16 @@ import org.springframework.stereotype.Component;
|
||||
matchIfMissing = true)
|
||||
@Component
|
||||
public class ApplicationRunnerTaskExecutor implements ApplicationRunner {
|
||||
private TaskService taskService;
|
||||
|
||||
private final TaskService taskService;
|
||||
|
||||
public ApplicationRunnerTaskExecutor(TaskService taskService) {
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
public void run(ApplicationArguments args) {
|
||||
taskService.execute("application runner task");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,14 +13,14 @@ import org.springframework.stereotype.Component;
|
||||
matchIfMissing = true)
|
||||
@Component
|
||||
public class CommandLineTaskExecutor implements CommandLineRunner {
|
||||
private TaskService taskService;
|
||||
private final TaskService taskService;
|
||||
|
||||
public CommandLineTaskExecutor(TaskService taskService) {
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
public void run(String... args) {
|
||||
taskService.execute("command line runner task");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,9 +6,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TaskService {
|
||||
private static Logger logger = LoggerFactory.getLogger(TaskService.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(TaskService.class);
|
||||
|
||||
public void execute(String task) {
|
||||
logger.info("do " + task);
|
||||
logger.info("do {}", task);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-8
@@ -1,16 +1,13 @@
|
||||
package com.baeldung.prevent.commandline.application.runner.execution;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
|
||||
import com.baeldung.prevent.commandline.application.runner.execution.ApplicationRunnerTaskExecutor;
|
||||
import com.baeldung.prevent.commandline.application.runner.execution.CommandLineTaskExecutor;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
|
||||
@SpringBootTest
|
||||
class RunApplicationIntegrationTest {
|
||||
@SpyBean
|
||||
@@ -21,6 +18,6 @@ class RunApplicationIntegrationTest {
|
||||
@Test
|
||||
void whenContextLoads_thenRunnersRun() throws Exception {
|
||||
verify(applicationRunnerTaskExecutor, times(1)).run(any());
|
||||
verify(commandLineTaskExecutor, times(1)).run(any());
|
||||
verify(commandLineTaskExecutor, times(1)).run(any(String[].class));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user