@Override Type newElementType() { return Type.bool(); } }.test();
@Override Type newType() { return Type.bool(); } }.test();
@Override public boolean getBoolean(int columnIndex) { checkNonNullOfType(columnIndex, Type.bool(), columnIndex); return getBooleanInternal(columnIndex); }
@Override public List<Boolean> getBoolArray() { throw defaultGetter(Type.array(Type.bool())); }
@Override public boolean getBool() { checkType(Type.bool()); checkNotNull(); return value; }
@Override public boolean getBoolean(String columnName) { int columnIndex = getColumnIndex(columnName); checkNonNullOfType(columnIndex, Type.bool(), columnName); return getBooleanInternal(columnIndex); }
@Override public List<Boolean> getBooleanList(int columnIndex) { checkNonNullOfType(columnIndex, Type.array(Type.bool()), columnIndex); return getBooleanListInternal(columnIndex); }
@Override public boolean[] getBooleanArray(int columnIndex) { checkNonNullOfType(columnIndex, Type.array(Type.bool()), columnIndex); return getBooleanArrayInternal(columnIndex); }
@Override public boolean[] getBooleanArray(String columnName) { int columnIndex = getColumnIndex(columnName); checkNonNullOfType(columnIndex, Type.array(Type.bool()), columnName); return getBooleanArrayInternal(columnIndex); }
@Override public List<Boolean> getBooleanList(String columnName) { int columnIndex = getColumnIndex(columnName); checkNonNullOfType(columnIndex, Type.array(Type.bool()), columnName); return getBooleanListInternal(columnIndex); }
@Test public void bool() { Value v = Value.bool(true); assertThat(v.getType()).isEqualTo(Type.bool()); assertThat(v.isNull()).isFalse(); assertThat(v.getBool()).isTrue(); assertThat(v.toString()).isEqualTo("true"); }
@Test public void boolWrapper() { Value v = Value.bool(Boolean.FALSE); assertThat(v.getType()).isEqualTo(Type.bool()); assertThat(v.isNull()).isFalse(); assertThat(v.getBool()).isFalse(); assertThat(v.toString()).isEqualTo("false"); }
@Test public void bindBoolArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toBoolArray(Arrays.<Boolean>asList()), Type.array(Type.bool())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getBooleanList(0)).containsExactly(); }
@Test public void boolWrapperNull() { Value v = Value.bool(null); assertThat(v.getType()).isEqualTo(Type.bool()); assertThat(v.isNull()).isTrue(); assertThat(v.toString()).isEqualTo(NULL_STRING); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("null value"); v.getBool(); }
@Test public void bindBoolArray() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toBoolArray(asList(true, null, false)), Type.array(Type.bool())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getBooleanList(0)).containsExactly(true, null, false).inOrder(); }
@Test public void bindBoolNull() { Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to((Boolean) null), Type.bool()); assertThat(row.isNull(0)).isTrue(); }
@Test public void bindBool() { Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(true).build(), Type.bool()); assertThat(row.isNull(0)).isFalse(); assertThat(row.getBoolean(0)).isEqualTo(true); }
@Test public void bindBoolArrayNull() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toBoolArray((boolean[]) null), Type.array(Type.bool())); assertThat(row.isNull(0)).isTrue(); }
@Test public void bindEmptyStruct() { Struct p = Struct.newBuilder().build(); Struct row = execute(Statement.newBuilder("SELECT @p IS NULL").bind("p").to(p).build(), Type.bool()); assertThat(row.getBoolean(0)).isFalse(); }
@Test public void bindStructWithNullStructField() { Type emptyStructType = Type.struct(new ArrayList<StructField>()); Struct p = Struct.newBuilder().set("f1").to(emptyStructType, null).build(); Struct row = execute(Statement.newBuilder("SELECT @p.f1 IS NULL").bind("p").to(p).build(), Type.bool()); assertThat(row.getBoolean(0)).isTrue(); }