@Test
 public void getter() {
   assertEquals(
       "CouponONCompounded definition: getter",
       EUR_OIS,
       ON_COMPOUNDED_COUPON_DEFINITION.getIndex());
   final ZonedDateTime[] FixingDateArray = ON_COMPOUNDED_COUPON_DEFINITION.getFixingPeriodDates();
   final ZonedDateTime firstFixingPeriod = FixingDateArray[0];
   final ZonedDateTime lastFixingPeriodEndDate = FixingDateArray[FixingDateArray.length - 1];
   assertEquals("CouponONCompounded definition: getter", START_ACCRUAL_DATE, firstFixingPeriod);
   assertEquals(
       "CouponONCompounded definition: getter", lastFixingPeriodEndDate, EUR_END_ACCRUAL_DATE);
   assertEquals(
       "CouponONCompounded definition: getter",
       EUR_LAST_FIXING_DATE,
       LocalDateTime.of(2011, 9, 15, 0, 0, 0, 0).atZone(ZoneOffset.UTC));
   assertEquals(
       "CouponONCompounded definition: getter",
       lastFixingPeriodEndDate,
       LocalDateTime.of(2011, 9, 16, 0, 0, 0, 0).atZone(ZoneOffset.UTC));
   double aftot = 0.0;
   for (int loopperiod = 0;
       loopperiod < ON_COMPOUNDED_COUPON_DEFINITION.getFixingPeriodAccrualFactors().length;
       loopperiod++) {
     aftot += ON_COMPOUNDED_COUPON_DEFINITION.getFixingPeriodAccrualFactors()[loopperiod];
   }
   assertEquals("CouponONCompounded definition: getter", EUR_FIXING_YEAR_FRACTION, aftot, 1.0E-10);
 }
 // -------------------------------------------------------------------------
 private static ZonedDateTime zdt(
     int y, int m, int d, int hr, int min, int sec, int nanos, ZoneId zone) {
   return LocalDateTime.of(y, m, d, hr, min, sec, nanos).atZone(zone);
 }
public class TestPersistentLocalDateTimeAsString extends DatabaseCapable {

  private static final LocalDateTime[] localDateTimes =
      new LocalDateTime[] {
        LocalDateTime.of(2004, 2, 25, 12, 11, 10), LocalDateTime.of(1980, 3, 11, 13, 12, 11)
      };

  private static EntityManagerFactory factory;

  @BeforeClass
  public static void setup() {
    factory = Persistence.createEntityManagerFactory("test1");
  }

  @AfterClass
  public static void tearDown() {
    factory.close();
  }

  @Test
  public void testPersist() {

    EntityManager manager = factory.createEntityManager();

    manager.getTransaction().begin();

    for (int i = 0; i < localDateTimes.length; i++) {

      LocalDateTimeAsStringHolder item = new LocalDateTimeAsStringHolder();
      item.setId(i);
      item.setName("test_" + i);
      item.setLocalDateTime(localDateTimes[i]);

      manager.persist(item);
    }

    manager.flush();

    manager.getTransaction().commit();

    manager.close();

    manager = factory.createEntityManager();

    for (int i = 0; i < localDateTimes.length; i++) {

      LocalDateTimeAsStringHolder item =
          manager.find(LocalDateTimeAsStringHolder.class, Long.valueOf(i));

      assertNotNull(item);
      assertEquals(i, item.getId());
      assertEquals("test_" + i, item.getName());
      assertEquals(localDateTimes[i], item.getLocalDateTime());
    }

    verifyDatabaseTable(
        manager, LocalDateTimeAsStringHolder.class.getAnnotation(Table.class).name());

    manager.close();
  }
}
  /**
   * Get US bond future security for testing
   *
   * @return the bond future security
   */
  public static BondFutureSecurity getBondFutureSecurity() {
    Expiry expiry =
        new Expiry(
            ZonedDateTime.of(LocalDateTime.of(2010, Month.JUNE, 21, 19, 0), ZoneOffset.UTC),
            ExpiryAccuracy.MIN_HOUR_DAY_MONTH_YEAR);
    Set<BondFutureDeliverable> basket = new HashSet<BondFutureDeliverable>();
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EV6")), 1.0858));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FB9")), 1.0132));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PX0")), 0.7984));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FG8")), 0.9169));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QD3")), 0.7771));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FF0")), 0.9174));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PW2")), 0.7825));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FE3")), 0.9454));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QH4")), 0.7757));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PU6")), 0.8675));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EX2")), 1.0765));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FT0")), 0.8054));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FJ2")), 1.0141));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PT9")), 0.8352));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QE1")), 0.8109));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FP8")), 0.9268));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QA9")), 0.6606));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FM5")), 1.0286));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EY0")), 1.0513));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QB7")), 0.7616));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QC5")), 0.795));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EZ7")), 1.0649));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EW4")), 1.0));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FA1")), 1.0396));

    BondFutureSecurity sec =
        new BondFutureSecurity(
            expiry,
            "XCBT",
            "XCBT",
            Currency.USD,
            1000,
            basket,
            LocalDate.of(2010, 6, 01).atStartOfDay(ZoneOffset.UTC),
            LocalDate.of(2010, 6, 01).atStartOfDay(ZoneOffset.UTC),
            "Bond");
    sec.setName("US LONG BOND(CBT) Jun10");
    Set<ExternalId> identifiers = new HashSet<ExternalId>();
    identifiers.add(ExternalSchemes.bloombergBuidSecurityId("IX8530684-0"));
    identifiers.add(ExternalSchemes.cusipSecurityId("USM10"));
    identifiers.add(ExternalSchemes.bloombergTickerSecurityId("USM10 Comdty"));
    sec.setExternalIdBundle(ExternalIdBundle.of(identifiers));
    return sec;
  }