mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#420 - Review JodaLocalTime (being stored and fetched using UTC)
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user