@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.SystemInformation.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), not(hasKey(Series.TAG_AGENT_NAME))); }
@Test public void vmArgs() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); Set<VmArgumentData> vmSet = new HashSet<>(); vmSet.add(new VmArgumentData("key1", "value1")); vmSet.add(new VmArgumentData("key2", "value2")); when(data.getVmSet()).thenReturn(vmSet ); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.SystemInformation.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); Object vmArgs = "key1=value1" + System.getProperty("line.separator") + "key2=value2"; assertThat(getFields(pointBuilder), hasEntry(Series.SystemInformation.FIELD_VM_ATTRIBUTES, vmArgs)); }
SystemInformationData systemInformationData = (SystemInformationData) this.cut.getSystemSensorData(); assertThat(systemInformationData.getTimeStamp().getTime(), is(not(1L)));
when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getArchitecture()).thenReturn(null); when(data.getBootClassPath()).thenReturn(null);
SystemInformationData systemInformationData = (SystemInformationData) this.cut.getSystemSensorData(); assertThat(systemInformationData.getTimeStamp().getTime(), is(not(1L)));
when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getArchitecture()).thenReturn("arch"); when(data.getAvailableProcessors()).thenReturn(RandomUtils.nextInt());