@Test public void getPidsReturnsCorrectlySizedArray() { int pidsToReturn = 2; int[] input = new int[]{123, 321, 5, 19, 0, 0, 0, 0, 0}; psapi.setEnumProcessesReturnValue(true); psapi.setEnumProcessesPids(input); psapi.setEnumProcessesBytesReturned(pidsToReturn * WinApiConstants.SIZEOF_INT); int[] expectedReturn = Arrays.copyOf(input, pidsToReturn); List<Integer> returned = enumerator.getPids(); int[] returnedAsArray = returned.stream().mapToInt(i -> i).toArray(); assertArrayEquals(expectedReturn, returnedAsArray); }
@Override public List<Integer> getPids() { int[] pidBuffer = createMaxSizePidBuffer(); int pidCount = fillBufferWithProcessIds(pidBuffer); return Arrays.stream(pidBuffer, 0, pidCount) .boxed() .collect(Collectors.toList()); }
WindowsPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int[] pidBuffer = createMaxSizePidBuffer(); int pidCount = fillBufferWithProcessIds(pidBuffer); return Arrays.stream(pidBuffer, 0, pidCount) .boxed() .collect(Collectors.toList()); } }
WindowsPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int[] pidBuffer = createMaxSizePidBuffer(); int pidCount = fillBufferWithProcessIds(pidBuffer); return Arrays.stream(pidBuffer, 0, pidCount) .boxed() .collect(Collectors.toList()); } WindowsPidEnumerator(Psapi psapi); }
WindowsPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int[] pidBuffer = createMaxSizePidBuffer(); int pidCount = fillBufferWithProcessIds(pidBuffer); return Arrays.stream(pidBuffer, 0, pidCount) .boxed() .collect(Collectors.toList()); } WindowsPidEnumerator(Psapi psapi); @Override List<Integer> getPids(); }
WindowsPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int[] pidBuffer = createMaxSizePidBuffer(); int pidCount = fillBufferWithProcessIds(pidBuffer); return Arrays.stream(pidBuffer, 0, pidCount) .boxed() .collect(Collectors.toList()); } WindowsPidEnumerator(Psapi psapi); @Override List<Integer> getPids();  }