/** * {@inheritDoc} */ @Override public Object getAggregationKey(ClassLoadingInformationData object) { return object.getPlatformIdent(); }
/** * {@inheritDoc} */ @Override public ClassLoadingInformationData getClone(ClassLoadingInformationData classLoadingInformationData) { ClassLoadingInformationData clone = new ClassLoadingInformationData(); clone.setPlatformIdent(classLoadingInformationData.getPlatformIdent()); clone.setSensorTypeIdent(classLoadingInformationData.getSensorTypeIdent()); return clone; }
@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)); when(data.getCount()).thenReturn(1); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.ClassLoadingInfomation.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 happyPath() 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)); when(data.getCount()).thenReturn(5); when(data.getTotalLoadedClassCount()).thenReturn(RandomUtils.nextInt()); when(data.getTotalTotalLoadedClassCount()).thenReturn(RandomUtils.nextLong()); when(data.getTotalUnloadedClassCount()).thenReturn(RandomUtils.nextLong()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.ClassLoadingInfomation.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))); assertThat(getFields(pointBuilder), hasEntry(Series.ClassLoadingInfomation.FIELD_LOADED_CLASSES, (Object) ((long) data.getTotalLoadedClassCount() / data.getCount()))); assertThat(getFields(pointBuilder), hasEntry(Series.ClassLoadingInfomation.FIELD_TOTAL_LOADED_CLASSES, (Object) (data.getTotalTotalLoadedClassCount() / data.getCount()))); assertThat(getFields(pointBuilder), hasEntry(Series.ClassLoadingInfomation.FIELD_UNLOADED_CLASSES, (Object) (data.getTotalUnloadedClassCount() / data.getCount()))); }
assertThat(classLoadingInformationData.getPlatformIdent(), is(1L)); assertThat(classLoadingInformationData.getSensorTypeIdent(), is(2L)); assertThat(classLoadingInformationData.getCount(), is(3));
ClassLoadingInformationData classLoadingInformationData = (ClassLoadingInformationData) this.cut.get(); assertThat(classLoadingInformationData.getPlatformIdent(), is(1L)); assertThat(classLoadingInformationData.getSensorTypeIdent(), is(2L)); assertThat(classLoadingInformationData.getCount(), is(0));
/** * {@inheritDoc} */ @Override public SystemSensorData get() { ClassLoadingInformationData newClassLoadingInformationData = new ClassLoadingInformationData(); newClassLoadingInformationData.setPlatformIdent(this.classLoadingInformationData.getPlatformIdent()); newClassLoadingInformationData.setSensorTypeIdent(this.classLoadingInformationData.getSensorTypeIdent()); newClassLoadingInformationData.setCount(this.classLoadingInformationData.getCount()); newClassLoadingInformationData.setTotalLoadedClassCount(this.classLoadingInformationData.getTotalLoadedClassCount()); newClassLoadingInformationData.setMinLoadedClassCount(this.classLoadingInformationData.getMinLoadedClassCount()); newClassLoadingInformationData.setMaxLoadedClassCount(this.classLoadingInformationData.getMaxLoadedClassCount()); newClassLoadingInformationData.setTotalTotalLoadedClassCount(this.classLoadingInformationData.getTotalTotalLoadedClassCount()); newClassLoadingInformationData.setMinTotalLoadedClassCount(this.classLoadingInformationData.getMinTotalLoadedClassCount()); newClassLoadingInformationData.setMaxTotalLoadedClassCount(this.classLoadingInformationData.getMaxTotalLoadedClassCount()); newClassLoadingInformationData.setTotalUnloadedClassCount(this.classLoadingInformationData.getTotalUnloadedClassCount()); newClassLoadingInformationData.setMinUnloadedClassCount(this.classLoadingInformationData.getMinUnloadedClassCount()); newClassLoadingInformationData.setMaxUnloadedClassCount(this.classLoadingInformationData.getMaxUnloadedClassCount()); newClassLoadingInformationData.setTimeStamp(this.classLoadingInformationData.getTimeStamp()); return newClassLoadingInformationData; }