@Test void updateProcessCpuTime() { when(this.osBean.getProcessCpuTime()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); CpuInformationData collector = (CpuInformationData) this.cut.get(); assertThat(collector.getProcessCpuTime(), is(11L)); }
@Test void collectorClassIsResetted() throws Exception { CpuInformationData collector = (CpuInformationData) this.cut.getSystemSensorData(); collector.setCount(1); collector.setPlatformIdent(2L); collector.setSensorTypeIdent(3L); collector.setProcessCpuTime(4L); collector.setTotalCpuUsage(5f); collector.setMaxCpuUsage(6f); collector.setMinCpuUsage(7f); collector.setTimeStamp(new Timestamp(8L)); this.cut.reset(); CpuInformationData cpuInformationData = (CpuInformationData) this.cut.get(); assertThat(cpuInformationData.getCount(), is(0)); assertThat(cpuInformationData.getPlatformIdent(), is(2L)); assertThat(cpuInformationData.getSensorTypeIdent(), is(3L)); assertThat(cpuInformationData.getProcessCpuTime(), is(0L)); assertThat(cpuInformationData.getTotalCpuUsage(), is(0f)); assertThat(cpuInformationData.getMaxCpuUsage(), is(0f)); assertThat(cpuInformationData.getMinCpuUsage(), is(Float.MAX_VALUE)); assertThat(cpuInformationData.getTimeStamp().getTime(), is(not(8L))); } }
@Test void getNewCpuInformationData() throws Exception { CpuInformationData collector = (CpuInformationData) this.cut.getSystemSensorData(); collector.setCount(1); collector.setPlatformIdent(2L); collector.setSensorTypeIdent(3L); collector.setProcessCpuTime(4L); collector.setTotalCpuUsage(5f); collector.setMaxCpuUsage(6f); collector.setMinCpuUsage(7f); collector.setTimeStamp(new Timestamp(8L)); CpuInformationData cpuInformationData = (CpuInformationData) this.cut.get(); assertThat(cpuInformationData.getCount(), is(1)); assertThat(cpuInformationData.getPlatformIdent(), is(2L)); assertThat(cpuInformationData.getSensorTypeIdent(), is(3L)); assertThat(cpuInformationData.getProcessCpuTime(), is(4L)); assertThat(cpuInformationData.getTotalCpuUsage(), is(5f)); assertThat(cpuInformationData.getMaxCpuUsage(), is(6f)); assertThat(cpuInformationData.getMinCpuUsage(), is(7f)); assertThat(cpuInformationData.getTimeStamp().getTime(), is(8L)); } }
/** * {@inheritDoc} */ @Override public SystemSensorData get() { CpuInformationData newCpuInformationData = new CpuInformationData(); newCpuInformationData.setPlatformIdent(this.cpuInformationData.getPlatformIdent()); newCpuInformationData.setSensorTypeIdent(this.cpuInformationData.getSensorTypeIdent()); newCpuInformationData.setCount(this.cpuInformationData.getCount()); newCpuInformationData.setProcessCpuTime(this.cpuInformationData.getProcessCpuTime()); newCpuInformationData.setTotalCpuUsage(this.cpuInformationData.getTotalCpuUsage()); newCpuInformationData.setMinCpuUsage(this.cpuInformationData.getMinCpuUsage()); newCpuInformationData.setMaxCpuUsage(this.cpuInformationData.getMaxCpuUsage()); newCpuInformationData.setTimeStamp(this.cpuInformationData.getTimeStamp()); return newCpuInformationData; }