#578 - Deprecated Joda Time API - LocalDate.toDateMidnight() usage causes exception to be thrown, change to LocalDate.toDateTimeAtStartOfDay()

This commit is contained in:
Robin Bygrave
2016-03-01 16:09:57 +13:00
parent 8d3b4a0407
commit ed2ea13deb
2 changed files with 60 additions and 5 deletions
@@ -0,0 +1,56 @@
package com.avaje.ebeaninternal.server.type;
import org.joda.time.LocalDate;
import org.junit.Test;
import java.sql.Date;
import static org.assertj.core.api.Assertions.assertThat;
public class ScalarTypeJodaLocalDateTest {
ScalarTypeJodaLocalDate type = new ScalarTypeJodaLocalDate();
@Test
public void convertToMillis_convertFromMillis() throws Exception {
LocalDate localDate = new LocalDate();
long millis = type.convertToMillis(localDate);
LocalDate localDate1 = type.convertFromMillis(millis);
assertThat(localDate).isEqualTo(localDate1);
}
@Test
public void convertToDate_convertFromDate() throws Exception {
LocalDate localDate = new LocalDate();
Date dateValue = type.convertToDate(localDate);
LocalDate localDate1 = type.convertFromDate(dateValue);
assertThat(localDate).isEqualTo(localDate1);
}
@Test
public void toJdbcType() throws Exception {
LocalDate localDate = new LocalDate();
Object jdbcType = type.toJdbcType(localDate);
Date dateValue = type.convertToDate(localDate);
assertThat(jdbcType).isEqualTo(dateValue);
}
@Test
public void toBeanType() throws Exception {
LocalDate localDate = new LocalDate();
Date dateValue = type.convertToDate(localDate);
LocalDate beanType = type.toBeanType(dateValue);
assertThat(beanType).isEqualTo(localDate);
}
}