Package com.google.ical.util

Examples of com.google.ical.util.DTBuilder


  public void testSerialMonthGenerator() throws Exception {
    runGeneratorTests(
        Generators.serialMonthGenerator(
            1, IcalParseUtil.parseDateValue("20060101")),
        new DTBuilder(2006, 1, 1), "month",
        "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12");
    runGeneratorTests(
        Generators.serialMonthGenerator(
            1, IcalParseUtil.parseDateValue("20060401")),
        new DTBuilder(2006, 4, 1), "month", "4, 5, 6, 7, 8, 9, 10, 11, 12");
    runGeneratorTests(
        Generators.serialMonthGenerator(
            2, IcalParseUtil.parseDateValue("20060401")),
        new DTBuilder(2006, 4, 1), "month", "4, 6, 8, 10, 12");
    Generator g = Generators.serialMonthGenerator(
        7, IcalParseUtil.parseDateValue("20060401"));
    runGeneratorTests(g, new DTBuilder(2006, 4, 1), "month", "4, 11");
    runGeneratorTests(g, new DTBuilder(2007, 11, 1), "month", "6");
    runGeneratorTests(g, new DTBuilder(2008, 6, 1), "month", "1, 8");
    Generator g2 = Generators.serialMonthGenerator(
        18, IcalParseUtil.parseDateValue("20060401"));
    runGeneratorTests(g2, new DTBuilder(2006, 4, 1), "month", "4");
    runGeneratorTests(g2, new DTBuilder(2007, 11, 1), "month", "10");
    runGeneratorTests(g2, new DTBuilder(2008, 6, 1), "month", "");
    runGeneratorTests(g2, new DTBuilder(2009, 6, 1), "month", "4");
  }
View Full Code Here


  public void testSerialYearGenerator() throws Exception {
    runGeneratorTests(
        Generators.serialYearGenerator(
            1, IcalParseUtil.parseDateValue("20060101")),
        new DTBuilder(2006, 1, 1), "year", "2006, 2007, 2008, 2009, 2010", 5);
    runGeneratorTests(
        Generators.serialYearGenerator(
            2, IcalParseUtil.parseDateValue("20060101")),
        new DTBuilder(2006, 1, 1), "year", "2006, 2008, 2010, 2012, 2014", 5);
  }
View Full Code Here

  }

  public void testSerialHourGeneratorGivenDate() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.serialHourGenerator(7, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 7:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 14:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 21:0:0", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 21:0:0", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 4:0:0", b.toString());
    b.day += 2;
    assertTrue(g.generate(b));
    assertEquals("2011-8-11 5:0:0", b.toString());
  }
View Full Code Here

  }

  public void testSerialHourGeneratorGivenTime() throws Exception {
    DateValue dtStart = new DateTimeValueImpl(2011, 8, 8, 1, 25, 30);
    Generator g = Generators.serialHourGenerator(7, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 1:25:30", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 8:25:30", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 15:25:30", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 22:25:30", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 22:25:30", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 5:25:30", b.toString());
    b.day += 2;
    assertTrue(g.generate(b));
    assertEquals("2011-8-11 6:25:30", b.toString());
  }
View Full Code Here

  }

  public void testSerialHourGeneratorRolledBack() throws Exception {
    DateValue dtStart = new DateTimeValueImpl(2011, 8, 8, 1, 25, 30);
    Generator g = Generators.serialHourGenerator(7, dtStart);
    DTBuilder b = new DTBuilder(new DateTimeValueImpl(2011, 8, 1, 0, 29, 50));
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 1:29:50", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 8:29:50", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 15:29:50", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 22:29:50", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-1 22:29:50", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-2 5:29:50", b.toString());
    b.day += 2;
    assertTrue(g.generate(b));
    assertEquals("2011-8-4 6:29:50", b.toString());
  }
View Full Code Here

  }

  public void testByHourGeneratorGivenDate() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.byHourGenerator(new int[] { 3, 9, 11 }, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 3:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 9:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 11:0:0", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 11:0:0", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 3:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 9:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 11:0:0", b.toString());
    ++b.month;
    assertTrue(g.generate(b));
    assertEquals("2011-9-9 3:0:0", b.toString());
  }
View Full Code Here

  }

  public void testByHourGeneratorGivenDateTime() throws Exception {
    DateValue dtStart = new DateTimeValueImpl(2011, 8, 8, 3, 11, 12);
    Generator g = Generators.byHourGenerator(new int[] { 3, 9, 11 }, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 3:11:12", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 9:11:12", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 11:11:12", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 11:11:12", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 3:11:12", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 9:11:12", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 11:11:12", b.toString());
    ++b.month;
    assertTrue(g.generate(b));
    assertEquals("2011-9-9 3:11:12", b.toString());
  }
View Full Code Here

  }

  public void testSingleByHourGeneratorGivenDateTime() throws Exception {
    DateValue dtStart = new DateTimeValueImpl(2011, 8, 8, 3, 11, 12);
    Generator g = Generators.byHourGenerator(new int[] { 7 }, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 7:11:12", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 7:11:12", b.toString());
    ++b.month;
    assertTrue(g.generate(b));
    assertEquals("2011-9-9 7:11:12", b.toString());
  }
View Full Code Here

  }

  public void testSerialMinuteGeneratorBigInterval() throws Exception {
    DateValue dtStart = new DateTimeValueImpl(2011, 8, 8, 15, 30, 0);
    Generator g = Generators.serialMinuteGenerator(100, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 15:30:0", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 15:30:0", b.toString());
    ++b.hour;
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 16:30:0", b.toString());
    ++b.hour;
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 17:10:0", b.toString());
    assertFalse(g.generate(b));
    ++b.hour;
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 18:50:0", b.toString());
    assertFalse(g.generate(b));
    ++b.hour;
    assertFalse(g.generate(b));
    ++b.hour;
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 20:30:0", b.toString());
    assertFalse(g.generate(b));
    ++b.hour;
    assertFalse(g.generate(b));
    ++b.hour;
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 22:10:0", b.toString());
    assertFalse(g.generate(b));
    ++b.hour;
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 23:50:0", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 23:50:0", b.toString());
    ++b.day;
    b.hour = 0;
    assertFalse(g.generate(b));
    ++b.hour;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 1:30:0", b.toString());
    b.day += 2;
    b.hour = 6;
    // Skipping over 3:10, 4:50, 6:30, 8:10, 9:50, 11:30, 13:10, 14:50, 16:30,
    //               18:10, 19:50, 21:30, 23:10,
    // on the 9th, and 0:50, 2:30, 4:10, 5:50, 7:30, 9:10, 10:50, 12:30,
    //               14:10, 15:50, 17:30, 19:10, 20:50, 22:30,
    // on the 10th, and 00:10, 1:50, 3:30, 5:10 on the 11th, to 6:50.
    assertTrue(g.generate(b));
    assertEquals("2011-8-11 6:50:0", b.toString());
  }
View Full Code Here

  }

  public void testSerialMinuteGeneratorSmallInterval() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.serialMinuteGenerator(15, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:15:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:30:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:45:0", b.toString());
    assertFalse(g.generate(b));
    ++b.hour;
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 1:0:0", b.toString());
  }
View Full Code Here

TOP

Related Classes of com.google.ical.util.DTBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.