Ejemplo n.º 1
0
  @Test
  public void getNullableShortWithColumnNameWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getShort("foo")).thenReturn((short) 7);

    assertEquals(7, ResultSets.getNullableShort(mockResultSet, "foo").shortValue());
    assertEquals(7, ResultSets.enhance(mockResultSet).getNullableShort("foo").shortValue());

    when(mockResultSet.getShort("foo")).thenReturn((short) 0);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getNullableShort(mockResultSet, "foo"));
    assertNull(ResultSets.enhance(mockResultSet).getNullableShort("foo"));
  }