Skip to content

Commit

Permalink
Fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 31, 2024
1 parent 57f7677 commit 582b843
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,22 +46,20 @@ void setUp() {
}

@Test
void getProcessList() {
void assertGetProcessList() {
ProcessRegistry processRegistry = mock(ProcessRegistry.class);
when(ProcessRegistry.getInstance()).thenReturn(processRegistry);
processPersistService.getProcessList();
verify(processRegistry).listAll();
}

@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<Integer, Statement> 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();
Expand Down

0 comments on commit 582b843

Please sign in to comment.