#420 - Review JodaLocalTime (being stored and fetched using UTC)

This commit is contained in:
Robin Bygrave
2016-02-17 21:34:52 +13:00
parent a22574b0c9
commit f055a0d0cb
7 changed files with 141 additions and 10 deletions
@@ -2,14 +2,28 @@ package com.avaje.ebeaninternal.server.type;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
import org.junit.Test;
import java.sql.Timestamp;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
public class ScalarTypeJodaLocalTimeTest {
ScalarTypeJodaLocalTime type = new ScalarTypeJodaLocalTime();
@Test
public void toJdbcType_toBeanType() {
LocalTime localTime0 = new LocalTime();
Object time = type.toJdbcType(localTime0);
LocalTime localTime1 = type.toBeanType(time);
assertThat(localTime0).isEqualTo(localTime1);
}
@Test
public void test() {
@@ -1,5 +1,6 @@
package com.avaje.tests.basic;
import org.joda.time.LocalTime;
import org.junit.Assert;
import org.junit.Test;
@@ -11,6 +12,8 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import com.avaje.ebeaninternal.server.type.ScalarType;
import com.avaje.tests.model.basic.TJodaEntity;
import static org.assertj.core.api.Assertions.assertThat;
public class TestJodaType extends BaseTestCase {
@Test
@@ -23,5 +26,19 @@ public class TestJodaType extends BaseTestCase {
Assert.assertNotNull(scalarType);
}
@Test
public void test_insert_find() {
LocalTime now = new LocalTime().withMillisOfSecond(0);
TJodaEntity bean = new TJodaEntity();
bean.setLocalTime(now);
Ebean.save(bean);
TJodaEntity foundBean = Ebean.find(TJodaEntity.class, bean.getId());
assertThat(foundBean.getLocalTime()).isEqualTo(bean.getLocalTime());
}
}