}
// add the trait data (it stores it in db (without name field))
measurementDataManager.addTraitData(expectedResult);
// get back the trait data by schedule id
MeasurementDataTraitCriteria criteria = new MeasurementDataTraitCriteria();
criteria.addFilterScheduleId(schedule1.getId());
List<MeasurementDataTrait> actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
Set<MeasurementData> actualResultSet = new HashSet<MeasurementData>(actualResult);
assertEquals(expectedResult, actualResultSet);
// get back the trait data by resource id
criteria = new MeasurementDataTraitCriteria();
criteria.addFilterResourceId(resource1.getId());
actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
actualResultSet = new HashSet<MeasurementData>(actualResult);
assertEquals(expectedResult, actualResultSet);
// get back the trait data by schedule id and resource id
criteria = new MeasurementDataTraitCriteria();
criteria.addFilterScheduleId(schedule1.getId());
criteria.addFilterResourceId(resource1.getId());
actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
actualResultSet = new HashSet<MeasurementData>(actualResult);
assertEquals(expectedResult, actualResultSet);
// get back the trait data by wrong schedule id
criteria = new MeasurementDataTraitCriteria();
criteria.addFilterScheduleId(Integer.MIN_VALUE);
actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
assertTrue(actualResult.isEmpty());
} catch (Exception e) {
e.printStackTrace();
fail();