Binders { public static Binder defaultBinder() { return DEFAULT_BINDER; } private  Binders(); static Binder defaultBinder(); static Binder stringBinder(); static Binder dateBinder(); static Binder timestampBinder(); static Binder timeBinder(); static Binder decimalBinder(); static Binder integerBinder();  }
@Test public void defaultBinderBindsObject() throws SQLException { Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, Boolean.TRUE); verify(stmt).setObject(1, Boolean.TRUE); }
@Test public void defaultBinderBindsNull() throws SQLException { Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, null); verify(stmt).setObject(1, null); }
@Test public void defaultBinderBindsEnum() throws SQLException { Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, TestEnum.BAR); verify(stmt).setString(1, TestEnum.BAR.name()); }
@Test public void defaultBinderBindsUtilDate() throws SQLException { java.util.Date date = new java.util.Date(Date.valueOf("1975-07-19").getTime()); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, date); verify(stmt).setTimestamp(1, new Timestamp(date.getTime())); }
@Test public void defaultBinderBindsCalendar() throws SQLException { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(Date.valueOf("1975-07-19").getTime()); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, calendar); verify(stmt).setTimestamp(1, new Timestamp(calendar.getTime().getTime()), calendar); }
@Test public void defaultBinderBindsLocalDate() throws SQLException { LocalDate localDate = LocalDate.parse("1975-07-19"); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, localDate); verify(stmt).setDate(1, Date.valueOf(localDate)); }
@Test public void defaultBinderBindsLocalTime() throws SQLException { LocalTime localTime = LocalTime.parse("01:02:03.000"); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, localTime); verify(stmt).setTime(1, Time.valueOf("01:02:03")); }
@Test public void defaultBinderBindsLocalDateTime() throws SQLException { LocalDateTime localDateTime = LocalDateTime.parse("1975-07-19T01:02:03.000"); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, localDateTime); verify(stmt).setTimestamp(1, Timestamp.valueOf("1975-07-19 01:02:03")); }
@Test public void defaultBinderBindsInstant() throws SQLException { Instant instant = LocalDateTime.parse("1975-07-19T01:02:03.000").atZone(ZoneId.systemDefault()).toInstant(); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, instant); verify(stmt).setTimestamp(1, Timestamp.valueOf("1975-07-19 01:02:03")); }
@Test public void defaultBinderBindsZonedDateTime() throws SQLException { ZonedDateTime zonedDateTime = LocalDateTime.parse("1975-07-19T01:02:03.000").atZone(ZoneOffset.UTC); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, zonedDateTime); verify(stmt).setTimestamp(eq(1), eq(Timestamp.from(zonedDateTime.toInstant())), calendarWithTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC))); }
@Test public void defaultBinderBindsOffsetDateTime() throws SQLException { OffsetDateTime offsetDateTime = LocalDateTime.parse("1975-07-19T01:02:03.000").atOffset(ZoneOffset.UTC); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, offsetDateTime); verify(stmt).setTimestamp(eq(1), eq(Timestamp.from(offsetDateTime.toInstant())), calendarWithTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC))); }
@Test public void defaultBinderBindsOffsetTime() throws SQLException { OffsetTime offsetTime = LocalTime.parse("01:02:03.000").atOffset(ZoneOffset.UTC); Binder binder = Binders.defaultBinder(); binder.bind(stmt, 1, offsetTime); verify(stmt).setTime(eq(1), eq(Time.valueOf(offsetTime.toLocalTime())), calendarWithTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC))); }