@Test public void getsCorrectProcessOwners() { Map<Integer, String> pidOwners = new HashMap<>(); pidOwners.put(123, "me"); pidOwners.put(3848, "you"); pidOwners.put(1, null); List<Integer> expectedPids = new ArrayList<>(pidOwners.keySet()); pidEnumerator = () -> new ArrayList<>(expectedPids); collector = pid -> new NativeProcessImpl(pid, null, pidOwners.get(pid)); List<NativeProcess> processes = enumerator.getProcesses(); for (NativeProcess process : processes) { int pid = process.getPid(); String owner = process.getOwner(); assertEquals(pidOwners.get(pid), owner); } }
@Override public List<NativeProcess> getProcesses() { return pidEnumerator .getPids() .stream() .map(processCollector::collect) .collect(Collectors.toList()); }
NativeProcessEnumeratorImpl implements NativeProcessEnumerator { @Override public List<NativeProcess> getProcesses() { return pidEnumerator .getPids() .stream() .map(processCollector::collect) .collect(Collectors.toList()); } }
NativeProcessEnumeratorImpl implements NativeProcessEnumerator { @Override public List<NativeProcess> getProcesses() { return pidEnumerator .getPids() .stream() .map(processCollector::collect) .collect(Collectors.toList()); } NativeProcessEnumeratorImpl(PidEnumerator pidEnumerator,
                                       NativeProcessCollector processCollector); }
NativeProcessEnumeratorImpl implements NativeProcessEnumerator { @Override public List<NativeProcess> getProcesses() { return pidEnumerator .getPids() .stream() .map(processCollector::collect) .collect(Collectors.toList()); } NativeProcessEnumeratorImpl(PidEnumerator pidEnumerator,
                                       NativeProcessCollector processCollector); @Override List<NativeProcess> getProcesses(); }
NativeProcessEnumeratorImpl implements NativeProcessEnumerator { @Override public List<NativeProcess> getProcesses() { return pidEnumerator .getPids() .stream() .map(processCollector::collect) .collect(Collectors.toList()); } NativeProcessEnumeratorImpl(PidEnumerator pidEnumerator,
                                       NativeProcessCollector processCollector); @Override List<NativeProcess> getProcesses();  }