NodeStatusServiceUtil { CPUStats createLinuxStats(String lines) { if (lines == null) { return null; } Pattern pattern = Pattern.compile("[0-9]+"); Matcher matcher = pattern.matcher(lines); CPUStats statLine = new CPUStats(); matcher.find(); statLine.user = Long.valueOf(matcher.group()); matcher.find(); statLine.nice = Long.valueOf(matcher.group()); matcher.find(); statLine.system = Long.valueOf(matcher.group()); matcher.find(); statLine.idle = Long.valueOf(matcher.group()); matcher.find(); statLine.ioWait = Long.valueOf(matcher.group()); matcher.find(); statLine.irq = Long.valueOf(matcher.group()); matcher.find(); statLine.softirq = Long.valueOf(matcher.group()); int btimeStart = lines.indexOf("btime"); matcher = pattern.matcher(lines.substring(btimeStart)); matcher.find(); return statLine; } @Inject  NodeStatusServiceUtil(final NodeInfo nodeInfo,
                                 final RecordCountService recordCountService); List<InternalStatisticEvent> buildNodeStatus();  }
@Test void testCreateLinuxStats() { final NodeStatusServiceUtil nodeStatusServiceUtil = new NodeStatusServiceUtil(null, null); final CPUStats cpuStats = nodeStatusServiceUtil.createLinuxStats(output); assertThat(cpuStats.user.longValue()).isEqualTo(4723476392L); assertThat(cpuStats.nice.longValue()).isEqualTo(160361L); assertThat(cpuStats.system.longValue()).isEqualTo(77496194L); assertThat(cpuStats.idle.longValue()).isEqualTo(8438714515L); assertThat(cpuStats.ioWait.longValue()).isEqualTo(57132415L); assertThat(cpuStats.irq.longValue()).isEqualTo(3363L); assertThat(cpuStats.softirq.longValue()).isEqualTo(1832867L); }