use of com.datastax.oss.driver.api.core.type.TupleType in project java-driver by datastax.
the class DataTypeDetachableTest method attaching_tuple_should_attach_all_of_its_subtypes.
@Test
public void attaching_tuple_should_attach_all_of_its_subtypes() {
TupleType tuple1 = DataTypes.tupleOf(DataTypes.INT);
TupleType tuple2 = DataTypes.tupleOf(DataTypes.TEXT, tuple1);
assertThat(tuple1.isDetached()).isTrue();
assertThat(tuple2.isDetached()).isTrue();
tuple2.attach(attachmentPoint);
assertThat(tuple1.isDetached()).isFalse();
}
use of com.datastax.oss.driver.api.core.type.TupleType in project java-driver by datastax.
the class DataTypeDetachableTest method attaching_set_should_attach_its_element.
@Test
public void attaching_set_should_attach_its_element() {
TupleType tuple = DataTypes.tupleOf(DataTypes.INT);
SetType set = DataTypes.setOf(tuple);
assertThat(tuple.isDetached()).isTrue();
assertThat(set.isDetached()).isTrue();
set.attach(attachmentPoint);
assertThat(tuple.isDetached()).isFalse();
}
use of com.datastax.oss.driver.api.core.type.TupleType in project java-driver by datastax.
the class DataTypeDetachableTest method list_should_be_attached_if_its_element_is.
@Test
public void list_should_be_attached_if_its_element_is() {
TupleType tuple = DataTypes.tupleOf(DataTypes.INT);
ListType list = DataTypes.listOf(tuple);
assertThat(tuple.isDetached()).isTrue();
assertThat(list.isDetached()).isTrue();
tuple.attach(attachmentPoint);
assertThat(list.isDetached()).isFalse();
}
use of com.datastax.oss.driver.api.core.type.TupleType in project java-driver by datastax.
the class DataTypeDetachableTest method attaching_map_should_attach_all_of_its_subtypes.
@Test
public void attaching_map_should_attach_all_of_its_subtypes() {
TupleType tuple1 = DataTypes.tupleOf(DataTypes.INT);
TupleType tuple2 = DataTypes.tupleOf(DataTypes.TEXT);
MapType map = DataTypes.mapOf(tuple1, tuple2);
assertThat(tuple1.isDetached()).isTrue();
assertThat(tuple2.isDetached()).isTrue();
map.attach(attachmentPoint);
assertThat(tuple1.isDetached()).isFalse();
assertThat(tuple2.isDetached()).isFalse();
}
use of com.datastax.oss.driver.api.core.type.TupleType in project java-driver by datastax.
the class CachingCodecRegistryTestDataProviders method collectionsWithCqlAndJavaTypes.
@DataProvider
public static Object[][] collectionsWithCqlAndJavaTypes() throws UnknownHostException, ClassNotFoundException {
TupleType tupleType = DataTypes.tupleOf(DataTypes.INT, DataTypes.listOf(DataTypes.TEXT));
TupleValue tupleValue = tupleType.newValue();
UserDefinedType userType = new UserDefinedTypeBuilder(CqlIdentifier.fromInternal("ks"), CqlIdentifier.fromInternal("type")).withField(CqlIdentifier.fromInternal("field1"), DataTypes.INT).withField(CqlIdentifier.fromInternal("field2"), DataTypes.listOf(DataTypes.TEXT)).build();
UdtValue udtValue = userType.newValue();
return new Object[][] { // lists
{ DataTypes.listOf(DataTypes.INT), GenericType.listOf(Integer.class), GenericType.listOf(Integer.class), ImmutableList.of(1) }, { DataTypes.listOf(DataTypes.TEXT), GenericType.listOf(String.class), GenericType.listOf(String.class), ImmutableList.of("foo") }, { DataTypes.listOf(DataTypes.BLOB), GenericType.listOf(ByteBuffer.class), GenericType.listOf(Class.forName("java.nio.HeapByteBuffer")), ImmutableList.of(ByteBuffer.wrap(new byte[] { 127, 0, 0, 1 })) }, { DataTypes.listOf(DataTypes.INET), GenericType.listOf(InetAddress.class), GenericType.listOf(Inet4Address.class), ImmutableList.of(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 })) }, { DataTypes.listOf(tupleType), GenericType.listOf(TupleValue.class), GenericType.listOf(DefaultTupleValue.class), ImmutableList.of(tupleValue) }, { DataTypes.listOf(userType), GenericType.listOf(UdtValue.class), GenericType.listOf(DefaultUdtValue.class), ImmutableList.of(udtValue) }, { DataTypes.listOf(DataTypes.listOf(DataTypes.INT)), GenericType.listOf(GenericType.listOf(Integer.class)), GenericType.listOf(GenericType.listOf(Integer.class)), ImmutableList.of(ImmutableList.of(1)) }, { DataTypes.listOf(DataTypes.listOf(tupleType)), GenericType.listOf(GenericType.listOf(TupleValue.class)), GenericType.listOf(GenericType.listOf(DefaultTupleValue.class)), ImmutableList.of(ImmutableList.of(tupleValue)) }, { DataTypes.listOf(DataTypes.listOf(userType)), GenericType.listOf(GenericType.listOf(UdtValue.class)), GenericType.listOf(GenericType.listOf(DefaultUdtValue.class)), ImmutableList.of(ImmutableList.of(udtValue)) }, // sets
{ DataTypes.setOf(DataTypes.INT), GenericType.setOf(Integer.class), GenericType.setOf(Integer.class), ImmutableSet.of(1) }, { DataTypes.setOf(DataTypes.TEXT), GenericType.setOf(String.class), GenericType.setOf(String.class), ImmutableSet.of("foo") }, { DataTypes.setOf(DataTypes.BLOB), GenericType.setOf(ByteBuffer.class), GenericType.setOf(Class.forName("java.nio.HeapByteBuffer")), ImmutableSet.of(ByteBuffer.wrap(new byte[] { 127, 0, 0, 1 })) }, { DataTypes.setOf(DataTypes.INET), GenericType.setOf(InetAddress.class), GenericType.setOf(Inet4Address.class), ImmutableSet.of(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 })) }, { DataTypes.setOf(tupleType), GenericType.setOf(TupleValue.class), GenericType.setOf(DefaultTupleValue.class), ImmutableSet.of(tupleValue) }, { DataTypes.setOf(userType), GenericType.setOf(UdtValue.class), GenericType.setOf(DefaultUdtValue.class), ImmutableSet.of(udtValue) }, { DataTypes.setOf(DataTypes.setOf(DataTypes.INT)), GenericType.setOf(GenericType.setOf(Integer.class)), GenericType.setOf(GenericType.setOf(Integer.class)), ImmutableSet.of(ImmutableSet.of(1)) }, { DataTypes.setOf(DataTypes.setOf(tupleType)), GenericType.setOf(GenericType.setOf(TupleValue.class)), GenericType.setOf(GenericType.setOf(DefaultTupleValue.class)), ImmutableSet.of(ImmutableSet.of(tupleValue)) }, { DataTypes.setOf(DataTypes.setOf(userType)), GenericType.setOf(GenericType.setOf(UdtValue.class)), GenericType.setOf(GenericType.setOf(DefaultUdtValue.class)), ImmutableSet.of(ImmutableSet.of(udtValue)) }, // maps
{ DataTypes.mapOf(DataTypes.INT, DataTypes.TEXT), GenericType.mapOf(Integer.class, String.class), GenericType.mapOf(Integer.class, String.class), ImmutableMap.of(1, "foo") }, { DataTypes.mapOf(DataTypes.BLOB, DataTypes.INET), GenericType.mapOf(ByteBuffer.class, InetAddress.class), GenericType.mapOf(Class.forName("java.nio.HeapByteBuffer"), Inet4Address.class), ImmutableMap.of(ByteBuffer.wrap(new byte[] { 127, 0, 0, 1 }), InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 })) }, { DataTypes.mapOf(tupleType, tupleType), GenericType.mapOf(TupleValue.class, TupleValue.class), GenericType.mapOf(DefaultTupleValue.class, DefaultTupleValue.class), ImmutableMap.of(tupleValue, tupleValue) }, { DataTypes.mapOf(userType, userType), GenericType.mapOf(UdtValue.class, UdtValue.class), GenericType.mapOf(DefaultUdtValue.class, DefaultUdtValue.class), ImmutableMap.of(udtValue, udtValue) }, { DataTypes.mapOf(DataTypes.UUID, DataTypes.mapOf(DataTypes.INT, DataTypes.TEXT)), GenericType.mapOf(GenericType.UUID, GenericType.mapOf(Integer.class, String.class)), GenericType.mapOf(GenericType.UUID, GenericType.mapOf(Integer.class, String.class)), ImmutableMap.of(UUID.randomUUID(), ImmutableMap.of(1, "foo")) }, { DataTypes.mapOf(DataTypes.mapOf(userType, userType), DataTypes.mapOf(tupleType, tupleType)), GenericType.mapOf(GenericType.mapOf(UdtValue.class, UdtValue.class), GenericType.mapOf(TupleValue.class, TupleValue.class)), GenericType.mapOf(GenericType.mapOf(DefaultUdtValue.class, DefaultUdtValue.class), GenericType.mapOf(DefaultTupleValue.class, DefaultTupleValue.class)), ImmutableMap.of(ImmutableMap.of(udtValue, udtValue), ImmutableMap.of(tupleValue, tupleValue)) } };
}
Aggregations