From 582b843b3b1898a3217b8b777eefb357fea33d35 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Fri, 31 May 2024 12:43:11 +0800 Subject: [PATCH] Fix sonar issues --- .../service/StandaloneProcessPersistServiceTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistServiceTest.java b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistServiceTest.java index 8c9e53d028a68..6b646c42015dc 100644 --- a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistServiceTest.java +++ b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistServiceTest.java @@ -27,8 +27,7 @@ import java.sql.SQLException; import java.sql.Statement; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Collections; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -47,7 +46,7 @@ void setUp() { } @Test - void getProcessList() { + void assertGetProcessList() { ProcessRegistry processRegistry = mock(ProcessRegistry.class); when(ProcessRegistry.getInstance()).thenReturn(processRegistry); processPersistService.getProcessList(); @@ -55,14 +54,12 @@ void getProcessList() { } @Test - void killProcess() throws SQLException { + void assertKillProcess() throws SQLException { ProcessRegistry processRegistry = mock(ProcessRegistry.class); when(ProcessRegistry.getInstance()).thenReturn(processRegistry); Process process = mock(Process.class); Statement statement = mock(Statement.class); - Map processStatements = new ConcurrentHashMap<>(); - processStatements.put(1, statement); - when(process.getProcessStatements()).thenReturn(processStatements); + when(process.getProcessStatements()).thenReturn(Collections.singletonMap(1, statement)); when(processRegistry.get(any())).thenReturn(process); processPersistService.killProcess("foo_process_id"); verify(statement).cancel();