@Test public void shouldHandleNoProcessesPresent() { when(os.getProcesses(anyInt(), any(OperatingSystem.ProcessSort.class))).thenReturn(Collections.emptyList()); ProcessesInfo processesInfo = provider.processesInfo(ProcessSort.CPU, 0); assertTrue(processesInfo.getProcesses().isEmpty()); }
@NotNull @Override public ProcessesInfo processesInfo(@NotNull ProcessSort sortBy, int limit) { MemoryLoad memory = memoryLoad(); List<Process> processes = Collections.emptyList(); if (limit > -1) { processes = operatingSystem.getProcesses(limit, ExtensionsKt.asOshiProcessSort(sortBy)) .stream() .map(p -> Process.create(p, memory)) .collect(Collectors.toList()); } return new ProcessesInfo( memory, operatingSystem.getProcessId(), operatingSystem.getThreadCount(), operatingSystem.getProcessCount(), processes ); }
DefaultProcessesMetrics implements ProcessesMetrics { @NotNull @Override public ProcessesInfo processesInfo(@NotNull ProcessSort sortBy, int limit) { MemoryLoad memory = memoryLoad(); List<Process> processes = Collections.emptyList(); if (limit > -1) { processes = operatingSystem.getProcesses(limit, ExtensionsKt.asOshiProcessSort(sortBy)) .stream() .map(p -> Process.create(p, memory)) .collect(Collectors.toList()); } return new ProcessesInfo( memory, operatingSystem.getProcessId(), operatingSystem.getThreadCount(), operatingSystem.getProcessCount(), processes ); } }
DefaultProcessesMetrics implements ProcessesMetrics { @NotNull @Override public ProcessesInfo processesInfo(@NotNull ProcessSort sortBy, int limit) { MemoryLoad memory = memoryLoad(); List<Process> processes = Collections.emptyList(); if (limit > -1) { processes = operatingSystem.getProcesses(limit, ExtensionsKt.asOshiProcessSort(sortBy)) .stream() .map(p -> Process.create(p, memory)) .collect(Collectors.toList()); } return new ProcessesInfo( memory, operatingSystem.getProcessId(), operatingSystem.getThreadCount(), operatingSystem.getProcessCount(), processes ); } DefaultProcessesMetrics(OperatingSystem operatingSystem, HardwareAbstractionLayer hal); }
DefaultProcessesMetrics implements ProcessesMetrics { @NotNull @Override public ProcessesInfo processesInfo(@NotNull ProcessSort sortBy, int limit) { MemoryLoad memory = memoryLoad(); List<Process> processes = Collections.emptyList(); if (limit > -1) { processes = operatingSystem.getProcesses(limit, ExtensionsKt.asOshiProcessSort(sortBy)) .stream() .map(p -> Process.create(p, memory)) .collect(Collectors.toList()); } return new ProcessesInfo( memory, operatingSystem.getProcessId(), operatingSystem.getThreadCount(), operatingSystem.getProcessCount(), processes ); } DefaultProcessesMetrics(OperatingSystem operatingSystem, HardwareAbstractionLayer hal); @Override Optional<Process> getProcessByPid(int pid); MemoryLoad memoryLoad(); @NotNull @Override ProcessesInfo processesInfo(@NotNull ProcessSort sortBy, int limit); }
DefaultProcessesMetrics implements ProcessesMetrics { @NotNull @Override public ProcessesInfo processesInfo(@NotNull ProcessSort sortBy, int limit) { MemoryLoad memory = memoryLoad(); List<Process> processes = Collections.emptyList(); if (limit > -1) { processes = operatingSystem.getProcesses(limit, ExtensionsKt.asOshiProcessSort(sortBy)) .stream() .map(p -> Process.create(p, memory)) .collect(Collectors.toList()); } return new ProcessesInfo( memory, operatingSystem.getProcessId(), operatingSystem.getThreadCount(), operatingSystem.getProcessCount(), processes ); } DefaultProcessesMetrics(OperatingSystem operatingSystem, HardwareAbstractionLayer hal); @Override Optional<Process> getProcessByPid(int pid); MemoryLoad memoryLoad(); @NotNull @Override ProcessesInfo processesInfo(@NotNull ProcessSort sortBy, int limit);  }