Search in sources :

Example 11 with SetType

use of com.datastax.oss.driver.api.core.type.SetType in project java-driver by datastax.

the class UserDefinedTypeListParserTest method should_resolve_set_dependency.

@Test
public void should_resolve_set_dependency() {
    UserDefinedTypeParser parser = new UserDefinedTypeParser(new DataTypeCqlNameParser(), context);
    Map<CqlIdentifier, UserDefinedType> types = parser.parse(KEYSPACE_ID, mockTypeRow("ks", "a", ImmutableList.of("bs"), ImmutableList.of("frozen<set<frozen<b>>>")), mockTypeRow("ks", "b", ImmutableList.of("i"), ImmutableList.of("int")));
    assertThat(types).hasSize(2);
    UserDefinedType aType = types.get(CqlIdentifier.fromInternal("a"));
    UserDefinedType bType = types.get(CqlIdentifier.fromInternal("b"));
    assertThat(((SetType) aType.getFieldTypes().get(0)).getElementType()).isEqualTo(bType);
}
Also used : SetType(com.datastax.oss.driver.api.core.type.SetType) UserDefinedType(com.datastax.oss.driver.api.core.type.UserDefinedType) CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) Test(org.junit.Test)

Example 12 with SetType

use of com.datastax.oss.driver.api.core.type.SetType 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();
}
Also used : SetType(com.datastax.oss.driver.api.core.type.SetType) TupleType(com.datastax.oss.driver.api.core.type.TupleType) Test(org.junit.Test)

Aggregations

SetType (com.datastax.oss.driver.api.core.type.SetType)12 DataType (com.datastax.oss.driver.api.core.type.DataType)8 ListType (com.datastax.oss.driver.api.core.type.ListType)7 MapType (com.datastax.oss.driver.api.core.type.MapType)7 TupleType (com.datastax.oss.driver.api.core.type.TupleType)6 UserDefinedType (com.datastax.oss.driver.api.core.type.UserDefinedType)5 Test (org.junit.Test)4 CustomType (com.datastax.oss.driver.api.core.type.CustomType)3 CodecNotFoundException (com.datastax.oss.driver.api.core.type.codec.CodecNotFoundException)3 NonNull (edu.umd.cs.findbugs.annotations.NonNull)3 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)2 TypeCodec (com.datastax.oss.driver.api.core.type.codec.TypeCodec)2 TupleValue (com.datastax.oss.driver.api.core.data.TupleValue)1 UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)1 ColumnMetadata (com.datastax.oss.driver.api.core.metadata.schema.ColumnMetadata)1 TableMetadata (com.datastax.oss.driver.api.core.metadata.schema.TableMetadata)1 ViewMetadata (com.datastax.oss.driver.api.core.metadata.schema.ViewMetadata)1 GenericType (com.datastax.oss.driver.api.core.type.reflect.GenericType)1 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)1 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)1