Search in sources :

Example 1 with LocalTimeTestEntity

use of org.apache.cayenne.joda.db.LocalTimeTestEntity in project cayenne by apache.

the class JodaModuleIT method testJodaLocalTime.

@Test
public void testJodaLocalTime() {
    ObjectContext context = runtime.newContext();
    LocalTimeTestEntity localTimeTestEntity = context.newObject(LocalTimeTestEntity.class);
    LocalTime localTime = LocalTime.now();
    localTimeTestEntity.setTime(localTime);
    context.commitChanges();
    LocalTimeTestEntity testRead = ObjectSelect.query(LocalTimeTestEntity.class).selectOne(context);
    LocalTime time = testRead.getTime();
    assertNotNull(time);
    assertEquals(LocalTime.class, time.getClass());
    assertEquals(localTime.getSecondOfMinute(), time.getSecondOfMinute());
    assertEquals(localTime.getMinuteOfHour(), time.getMinuteOfHour());
    assertEquals(localTime.getHourOfDay(), time.getHourOfDay());
}
Also used : LocalTime(org.joda.time.LocalTime) LocalTimeTestEntity(org.apache.cayenne.joda.db.LocalTimeTestEntity) ObjectContext(org.apache.cayenne.ObjectContext) Test(org.junit.Test)

Aggregations

ObjectContext (org.apache.cayenne.ObjectContext)1 LocalTimeTestEntity (org.apache.cayenne.joda.db.LocalTimeTestEntity)1 LocalTime (org.joda.time.LocalTime)1 Test (org.junit.Test)1