use of com.google.cloud.ByteArray in project google-cloud-java by GoogleCloudPlatform.
the class ValueTest method bytesArray.
@Test
public void bytesArray() {
ByteArray a = newByteArray("a");
ByteArray c = newByteArray("c");
Value v = Value.bytesArray(Arrays.asList(a, null, c));
assertThat(v.isNull()).isFalse();
assertThat(v.getBytesArray()).containsExactly(a, null, c).inOrder();
assertThat(v.toString()).isEqualTo(String.format("[%s,NULL,%s]", a, c));
}
use of com.google.cloud.ByteArray in project google-cloud-java by GoogleCloudPlatform.
the class ValueTest method bytes.
@Test
public void bytes() {
ByteArray bytes = newByteArray("abc");
Value v = Value.bytes(bytes);
assertThat(v.getType()).isEqualTo(Type.bytes());
assertThat(v.isNull()).isFalse();
assertThat(v.getBytes()).isSameAs(bytes);
assertThat(v.toString()).isEqualTo(bytes.toString());
}
use of com.google.cloud.ByteArray in project google-cloud-java by GoogleCloudPlatform.
the class ValueTest method bytesUnprintable.
@Test
public void bytesUnprintable() {
ByteArray bytes = ByteArray.copyFrom(new byte[] { 'a', 0, 15, -1, 'e' });
Value v = Value.bytes(bytes);
assertThat(v.getBytes()).isSameAs(bytes);
assertThat(v.toString()).isEqualTo(bytes.toString());
}
use of com.google.cloud.ByteArray in project google-cloud-java by GoogleCloudPlatform.
the class ITLargeReadTest method validate.
private void validate(ResultSet resultSet) {
int i = 0;
while (resultSet.next()) {
assertThat(resultSet.getLong(0)).isEqualTo(i);
ByteArray data = resultSet.getBytes(1);
assertThat(data.length()).isEqualTo(resultSet.getLong(3));
assertThat(resultSet.getLong(2)).isEqualTo(hasher.hashBytes(data.toByteArray()).asLong());
assertThat(++i).isAtMost(numRows);
}
assertThat(i).isEqualTo(numRows);
}
use of com.google.cloud.ByteArray in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindBytesArrayEmpty.
@Test
public void bindBytesArrayEmpty() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toBytesArray(Arrays.<ByteArray>asList()), Type.array(Type.bytes()));
assertThat(row.isNull(0)).isFalse();
assertThat(row.getBytesList(0)).isEmpty();
}
Aggregations