use of com.datastax.oss.driver.api.core.cql.ColumnDefinition in project java-driver by datastax.
the class ConversionsTest method variables.
private ColumnDefinitions variables(String... columnNames) {
ImmutableList.Builder<ColumnDefinition> columns = ImmutableList.builderWithExpectedSize(columnNames.length);
for (String columnName : columnNames) {
ColumnDefinition column = mock(ColumnDefinition.class);
when(column.getName()).thenReturn(CqlIdentifier.fromInternal(columnName));
columns.add(column);
}
return DefaultColumnDefinitions.valueOf(columns.build());
}
use of com.datastax.oss.driver.api.core.cql.ColumnDefinition in project java-driver by datastax.
the class DefaultAsyncResultSetTest method should_fail_to_report_if_applied_if_column_present_but_empty.
@Test(expected = IllegalStateException.class)
public void should_fail_to_report_if_applied_if_column_present_but_empty() {
// Given
when(columnDefinitions.contains("[applied]")).thenReturn(true);
ColumnDefinition columnDefinition = mock(ColumnDefinition.class);
when(columnDefinition.getType()).thenReturn(DataTypes.BOOLEAN);
when(columnDefinitions.get("[applied]")).thenReturn(columnDefinition);
// When
DefaultAsyncResultSet resultSet = new DefaultAsyncResultSet(columnDefinitions, executionInfo, new ArrayDeque<>(), session, context);
// Then
resultSet.wasApplied();
}
use of com.datastax.oss.driver.api.core.cql.ColumnDefinition in project java-driver by datastax.
the class DefaultAsyncResultSetTest method should_report_not_applied_if_column_present_and_true.
@Test
public void should_report_not_applied_if_column_present_and_true() {
// Given
when(columnDefinitions.contains("[applied]")).thenReturn(true);
ColumnDefinition columnDefinition = mock(ColumnDefinition.class);
when(columnDefinition.getType()).thenReturn(DataTypes.BOOLEAN);
when(columnDefinitions.get("[applied]")).thenReturn(columnDefinition);
when(columnDefinitions.firstIndexOf("[applied]")).thenReturn(0);
when(columnDefinitions.get(0)).thenReturn(columnDefinition);
Queue<List<ByteBuffer>> data = new ArrayDeque<>();
data.add(Lists.newArrayList(TypeCodecs.BOOLEAN.encode(true, DefaultProtocolVersion.DEFAULT)));
// When
DefaultAsyncResultSet resultSet = new DefaultAsyncResultSet(columnDefinitions, executionInfo, data, session, context);
// Then
assertThat(resultSet.wasApplied()).isTrue();
}
use of com.datastax.oss.driver.api.core.cql.ColumnDefinition in project java-driver by datastax.
the class Conversions method toColumnDefinitions.
public static ColumnDefinitions toColumnDefinitions(RowsMetadata metadata, InternalDriverContext context) {
ColumnDefinition[] values = new ColumnDefinition[metadata.columnSpecs.size()];
int i = 0;
for (ColumnSpec columnSpec : metadata.columnSpecs) {
values[i++] = new DefaultColumnDefinition(columnSpec, context);
}
return DefaultColumnDefinitions.valueOf(ImmutableList.copyOf(values));
}
use of com.datastax.oss.driver.api.core.cql.ColumnDefinition in project java-driver by datastax.
the class RequestLogFormatterTest method mockPreparedStatement.
private PreparedStatement mockPreparedStatement(String query, Map<String, DataType> variables) {
ImmutableList.Builder<ColumnDefinition> definitions = ImmutableList.builder();
int i = 0;
for (Map.Entry<String, DataType> entry : variables.entrySet()) {
definitions.add(new DefaultColumnDefinition(new ColumnSpec("test", "foo", entry.getKey(), i, RawType.PRIMITIVES.get(entry.getValue().getProtocolCode())), context));
}
return new DefaultPreparedStatement(Bytes.fromHexString("0x"), query, DefaultColumnDefinitions.valueOf(definitions.build()), Collections.emptyList(), null, null, null, Collections.emptyMap(), null, null, null, null, null, Collections.emptyMap(), null, null, null, Integer.MIN_VALUE, null, null, false, context.getCodecRegistry(), context.getProtocolVersion());
}
Aggregations