/** * No data to aggregate when no sampling rate is set. */ @Test public void noDataToAggregateWhenNoSamplingRateIsSet() { List<? extends DefaultData> resultList = null; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, 0, new ClassLoadingInformationDataAggregator()); assertThat((Object) dataObjects, is(equalTo((Object) resultList))); }
/** * When the passed data object list isn't empty, then the result list shouldn't be empty too. */ @Test public void resultValuesExist() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList, is(notNullValue())); }
/** * If all values are in one timeframe, then the result must be 1. */ @Test public void allValuesInOneTimeframe() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // from time is Sun Sep 14 06:00:00 CEST 2008 Date fromDate = new Date(1221364800000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList.size(), is(equalTo(1))); }
/** * If the from and to time are smaller then the time of the first data object, then no data * should be aggregated. */ @Test public void fromAndToBeforeDataExists() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // the fromDate is Mon Sep 15 10:00:00 CEST 2008 Date fromDate = new Date(1221465600000L); // the toDate is Mon Sep 15 10:30:00 CEST 2008 Date toDate = new Date(1221467400000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList.size(), is(equalTo(0))); }
/** * No data to aggregate when an empty list is passed. */ @Test public void emptyListAsParameter() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(null, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList, is(nullValue())); }
/** * If sampling rate is set, then values should be aggregated. */ @Test public void samplingRateIsSet() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList.size(), is(lessThanOrEqualTo(sensitivity.getValue()))); }
/** * All aggregated values must lie in between from and to. */ @Test public void aggregatedValuesBetweenFromTo() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); for (DefaultData defaultData : resultList) { long dataTime = defaultData.getTimeStamp().getTime(); assertThat(dataTime, is(greaterThanOrEqualTo(fromDate.getTime()))); assertThat(dataTime, is(lessThanOrEqualTo(toDate.getTime()))); } }
/** * No data to aggregate when sampling rate is bigger than the count of data objects. */ @Test public void noDataToAggregateWithLessObjectsThanSamplingRate() { List<? extends DefaultData> resultList = null; List<ClassLoadingInformationData> tempList = createDataObjects(30); Sensitivity sensitivity = SamplingRateControl.Sensitivity.MEDIUM; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(tempList, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList.size(), is(lessThan(sensitivity.getValue()))); }
/** * {@inheritDoc} */ @Override public void setInputDefinition(InputDefinition inputDefinition) { super.setInputDefinition(inputDefinition); template = new ClassLoadingInformationData(); template.setPlatformIdent(inputDefinition.getIdDefinition().getPlatformId()); template.setSensorTypeIdent(inputDefinition.getIdDefinition().getSensorTypeId()); template.setId(-1L); dataAccessService = inputDefinition.getRepositoryDefinition().getGlobalDataAccessService(); aggregator = new ClassLoadingInformationDataAggregator(); }
resultList = mode.adjustSamplingRate(tempList, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator());