@Test
public void testSnappingDays(){

    Transform downsampleTransform = new DownsampleTransform();
    Map<Long, Double> datapoints = new HashMap<Long, Double>();
    GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
    calendar.set(2010, 11, 9, 3, 31, 31); 
    datapoints.put(calendar.getTimeInMillis(), 1.0);
    calendar.set(Calendar.DAY_OF_MONTH, 10);
    datapoints.put(calendar.getTimeInMillis(), 1.0);
    calendar.set(Calendar.DAY_OF_MONTH, 11);
    datapoints.put(calendar.getTimeInMillis(), 1.0);
    calendar.set(Calendar.DAY_OF_MONTH, 12);
    datapoints.put(calendar.getTimeInMillis(), 1.0);
    calendar.set(Calendar.DAY_OF_MONTH, 18);
    datapoints.put(calendar.getTimeInMillis(), 1.0);
    calendar.set(Calendar.HOUR_OF_DAY, 18);
    datapoints.put(calendar.getTimeInMillis(), 1.0);
    Metric metric_1 = new Metric(TEST_SCOPE + "1", TEST_METRIC);
    metric_1.setDatapoints(datapoints);
    List<Metric> metrics = new ArrayList<Metric>();
    metrics.add(metric_1);
    List<String> constants = new ArrayList<String>();
    constants.add("7d-sum");
    Map<Long, Double> expected_1 = new HashMap<Long, Double>();
    calendar.set(2010, 11, 9, 0, 0, 0); 
    calendar.set(Calendar.MILLISECOND, 0);
    expected_1.put(calendar.getTimeInMillis(), 4.0);
    calendar.set(Calendar.DAY_OF_MONTH, 16);
    expected_1.put(calendar.getTimeInMillis(), 2.0);
    List<Metric> result = downsampleTransform.transform(null, metrics, constants);
    assertEquals(result.size(), 1);
    assertEquals(expected_1, result.get(0).getDatapoints());
}