ProcessMonitorImpl implements ProcessMonitor { @Override public void add(ProcessLauncher processLauncher) { String id = processLauncher.getProcessId(); if (processMap.containsKey(id)) { String msg = String.format("An active process already exists with the Id '%s'", id); LOG.error(msg); throw new ProcessLauncherException(msg); } processMap.put(id, processLauncher); }  @Override ProcessLauncher get(String processId); @Override void add(ProcessLauncher processLauncher); @Override void remove(ProcessLauncher processLauncher); @Override Set<String> getProcessIds(); @Override void stop(String processId); @Override void stopAll();  }
@Test public void testAdd() throws Exception { when(processLauncherMock1.getProcessId()).thenReturn("p1"); when(processLauncherMock2.getProcessId()).thenReturn("p2"); Set<String> processIds = testling.getProcessIds(); Assert.assertEquals(processIds.size(), 0); testling.add(processLauncherMock1); processIds = testling.getProcessIds(); Assert.assertEquals(processIds.size(), 1); testling.add(processLauncherMock2); processIds = testling.getProcessIds(); Assert.assertEquals(processIds.size(), 2); }