@Test public void getReturnsCorrectlyTrimmedString() { final String description = "toasters.exe"; final int howManyBytesWeClaimToHaveCopied = description.length() - 1; final String expected = description.substring(0, howManyBytesWeClaimToHaveCopied); nameQuerier = (procHandle, flags, exeName, bufSize) -> { char[] name = description.toCharArray(); System.arraycopy(name, 0, exeName, 0, howManyBytesWeClaimToHaveCopied); bufSize.setValue(howManyBytesWeClaimToHaveCopied); return true; }; Optional<String> result = getter.get(handle); assertEquals(expected, result.get()); }
@Override public Optional<String> get(ProcessHandle processHandle) { Objects.requireNonNull(processHandle, "processHandle cannot be null!"); return getProcessImageName(processHandle.getNativeHandle()); }
WindowsProcessDescriptionGetter implements ProcessDescriptionGetter { @Override public Optional<String> get(ProcessHandle processHandle) { Objects.requireNonNull(processHandle, "processHandle cannot be null!"); return getProcessImageName(processHandle.getNativeHandle()); } }
WindowsProcessDescriptionGetter implements ProcessDescriptionGetter { @Override public Optional<String> get(ProcessHandle processHandle) { Objects.requireNonNull(processHandle, "processHandle cannot be null!"); return getProcessImageName(processHandle.getNativeHandle()); } WindowsProcessDescriptionGetter(QueryFullProcessImageName winapi); }
WindowsProcessDescriptionGetter implements ProcessDescriptionGetter { @Override public Optional<String> get(ProcessHandle processHandle) { Objects.requireNonNull(processHandle, "processHandle cannot be null!"); return getProcessImageName(processHandle.getNativeHandle()); } WindowsProcessDescriptionGetter(QueryFullProcessImageName winapi); @Override Optional<String> get(ProcessHandle processHandle); }
WindowsProcessDescriptionGetter implements ProcessDescriptionGetter { @Override public Optional<String> get(ProcessHandle processHandle) { Objects.requireNonNull(processHandle, "processHandle cannot be null!"); return getProcessImageName(processHandle.getNativeHandle()); } WindowsProcessDescriptionGetter(QueryFullProcessImageName winapi); @Override Optional<String> get(ProcessHandle processHandle);  }