Code example for ResultSet

Methods: getInt, getLong, getString, next

0
        assertThat(resultSet.next()).isTrue();
        assertThat(resultSet.getInt(1)).isEqualTo(2);
 
        statement = shadowOf(database).getConnection().createStatement();
        resultSet = statement.executeQuery("SELECT `id`, `name` ,`lastUsed` FROM `routine`");
        assertThat(resultSet.next()).isTrue();
        assertThat(resultSet.getInt(1)).isEqualTo(1);
        assertThat(resultSet.getString(2)).isEqualTo("Leg Press");
        assertThat(resultSet.getInt(3)).isEqualTo(0);
        assertThat(resultSet.next()).isTrue();
        assertThat(resultSet.getLong(1)).isEqualTo(2L);
        assertThat(resultSet.getString(2)).isEqualTo("Bench Press");
        assertThat(resultSet.getInt(3)).isEqualTo(1);
    } 
 
    @Test(expected = android.database.SQLException.class) 
    public void testExecSQLException() throws Exception { 
        database.execSQL("INSERT INTO table_name;");    // invalid SQL
    } 
 
    @Test(expected = IllegalArgumentException.class)