/** * {@inheritDoc} */ @Override public Object getAggregationKey(MemoryInformationData object) { return object.getPlatformIdent(); }
/** * {@inheritDoc} */ @Override public MemoryInformationData getClone(MemoryInformationData memoryInformationData) { MemoryInformationData clone = new MemoryInformationData(); clone.setPlatformIdent(memoryInformationData.getPlatformIdent()); clone.setSensorTypeIdent(memoryInformationData.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.MemoryInformation.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))); }
when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getCount()).thenReturn(5);
MemoryInformationData memoryInformationData = (MemoryInformationData) this.cut.get(); assertThat(memoryInformationData.getPlatformIdent(), is(1L)); assertThat(memoryInformationData.getSensorTypeIdent(), is(2L)); assertThat(memoryInformationData.getCount(), is(0));
assertThat(memoryInformationData.getPlatformIdent(), is(1L)); assertThat(memoryInformationData.getSensorTypeIdent(), is(2L)); assertThat(memoryInformationData.getCount(), is(3));
when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getCount()).thenReturn(5);
MemoryInformationData newMemoryInformationData = new MemoryInformationData(); newMemoryInformationData.setPlatformIdent(this.memoryInformationData.getPlatformIdent()); newMemoryInformationData.setSensorTypeIdent(this.memoryInformationData.getSensorTypeIdent()); newMemoryInformationData.setCount(this.memoryInformationData.getCount());