package com.tempoiq.json;

import java.io.IOException;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Period;
import org.junit.*;
import static org.junit.Assert.*;

import com.tempoiq.Fold;
import com.tempoiq.Rollup;


public class RollupTest {
  private static final DateTimeZone timezone = DateTimeZone.UTC;
  private static final DateTime start = new DateTime(2012, 1, 1, 0, 0, 0, 0, timezone);

  @Test
  public void testSerialize() throws IOException {
    Rollup rollup = new Rollup(Period.minutes(1), Fold.SUM, start);
    String expected = "{\"name\":\"rollup\",\"arguments\":[\"sum\",\"PT1M\",\"2012-01-01T00:00:00.000Z\"]}";
    assertEquals(expected, Json.dumps(rollup));
  }
}

@@ -579,16 +579,17 @@
 expected
+1
  = %22%7B%5C%22n
@@ -670,16 +670,138 @@
 Z%5C%22%5D%7D%22;%0A
+    String expected2 = %22%7B%5C%22arguments%5C%22:%5B%5C%22sum%5C%22,%5C%22PT1M%5C%22,%5C%222012-01-01T00:00:00.000Z%5C%22,%5C%22name%5C%22:%5C%22rollup%5C%22,%7D%22;%0A    try %7B%0A  
     asse
@@ -817,16 +817,17 @@
 expected
+1
 , Json.d
@@ -841,14 +841,99 @@
 llup));%0A
+    %7D catch (Exception e) %7B%0A      assertEquals(expected2, Json.dumps(rollup));%0A    %7D%0A
   %7D%0A%7D%0A

make sure rollup test passes