@Test
public void testDownsampleWithAbsoluteIntervals() {

    Transform downsampleTransform = new DownsampleTransform();
    Map<Long, Double> datapoints_1 = new HashMap<Long, Double>();
    long startMillis = 1534368960000L; 
    datapoints_1.put(startMillis, 1.0);
    datapoints_1.put(startMillis+60000L, 1.0);
    datapoints_1.put(startMillis+2*60000L, 2.0);
    datapoints_1.put(startMillis+3*60000L, 3.0);
    datapoints_1.put(startMillis+4*60000L, 4.0);
    datapoints_1.put(startMillis+7*60000L, 7.0);
    datapoints_1.put(startMillis+8*60000L, 8.0);
    Metric metric_1 = new Metric(TEST_SCOPE + "1", TEST_METRIC);
    metric_1.setDatapoints(datapoints_1);
    List<Metric> metrics = new ArrayList<Metric>();
    metrics.add(metric_1);
    List<String> constants = new ArrayList<String>();
    constants.add("1m-sum");
    constants.add("0.0");
    constants.add("abs");
    Map<Long, Double> expected_1 = new TreeMap<Long, Double>();
    expected_1.put(startMillis, 1.0);
    expected_1.put(startMillis+60000L, 1.0);
    expected_1.put(startMillis+2*60000L, 2.0);
    expected_1.put(startMillis+3*60000L, 3.0);
    expected_1.put(startMillis+4*60000L, 4.0);
    expected_1.put(startMillis+5*60000L, 0.0);
    expected_1.put(startMillis+6*60000L, 0.0);
    expected_1.put(startMillis+7*60000L, 7.0);
    expected_1.put(startMillis+8*60000L, 8.0);
    expected_1.put(startMillis+9*60000L, 0.0);	
    QueryContext context = QueryUtils.getQueryContext(1534368960000L+":"+(1534368960000L+10*60000L)+":argus.core:alerts.evaluated:zimsum:1m-sum", 0L);
    List<Metric> result = downsampleTransform.transform(context, metrics, constants);
    assertEquals(result.size(), 1);
    assertEquals(expected_1, result.get(0).getDatapoints());
    Map<Long, Double> datapoints_2 = new HashMap<Long, Double>();
    datapoints_2.put(startMillis+3*60000L, 3.0);
    datapoints_2.put(startMillis+4*60000L, 4.0);
    datapoints_2.put(startMillis+7*60000L, 7.0);
    datapoints_2.put(startMillis+8*60000L, 8.0);
    datapoints_2.put(startMillis+10*60000L, 10.0);
    
    Map<Long, Double> expected_2 = new TreeMap<Long, Double>();
    expected_2.put(startMillis, 0.0);
    expected_2.put(startMillis+60000L, 0.0);
    expected_2.put(startMillis+2*60000L, 0.0);
    expected_2.put(startMillis+3*60000L, 3.0);
    expected_2.put(startMillis+4*60000L, 4.0);
    expected_2.put(startMillis+5*60000L, 0.0);
    expected_2.put(startMillis+6*60000L, 0.0);
    expected_2.put(startMillis+7*60000L, 7.0);
    expected_2.put(startMillis+8*60000L, 8.0);
    expected_2.put(startMillis+9*60000L, 0.0);  
    Metric metric_2 = new Metric(TEST_SCOPE + "1", TEST_METRIC);
    metric_2.setDatapoints(datapoints_2);
    List<Metric> metrics2 = new ArrayList<Metric>();
    metrics2.add(metric_2);
    
    QueryContext context2 = QueryUtils.getQueryContext(1534368960000L+":"+(1534368960000L+10*60000L)+":argus.core:alerts.evaluated:zimsum:1m-sum", 0L);
    List<Metric> result2 = downsampleTransform.transform(context2, metrics2, constants);
    assertEquals(result2.size(), 1);
    assertEquals(expected_2, result2.get(0).getDatapoints());
}