Java Code Examples for com.datastax.driver.core.DataType#list()

The following examples show how to use com.datastax.driver.core.DataType#list() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraTypeConverterTest.java    From debezium-incubator with Apache License 2.0 6 votes vote down vote up
@Test
public void testList() {
    // list of ints
    // test non-frozen
    DataType listType = DataType.list(DataType.cint(), false);
    AbstractType<?> convertedType = CassandraTypeConverter.convert(listType);

    ListType<?> expectedType = ListType.getInstance(Int32Type.instance, true);
    Assert.assertEquals(expectedType, convertedType);

    // test frozen
    listType = DataType.list(DataType.cint(), true);
    convertedType = CassandraTypeConverter.convert(listType);
    expectedType = ListType.getInstance(Int32Type.instance, false);
    Assert.assertEquals(expectedType, convertedType);
    Assert.assertTrue("Expected convertedType to be frozen", convertedType.isFrozenCollection());
}
 
Example 2
Source File: CellValidatorTest.java    From deep-spark with Apache License 2.0 5 votes vote down vote up
public void testDataTypeListInstantiation() {
    try {
        assertNull(cellValidator((DataType) null));
        fail();
    } catch (Exception e) {
        //ok
    }

    DataType type = DataType.list(DataType.timeuuid());

    CellValidator cv = cellValidator(type);
    assertNotNull(cv);
    assertEquals(cv.getValidatorClassName(), ListType.class.getName());
    assertNotNull(cv.getValidatorTypes());
    assertEquals(cv.validatorKind(), Kind.LIST);
    assertEquals(cv.getValidatorTypes().size(), 1);
    assertEquals(cv.getValidatorTypes().iterator().next(), "timeuuid");
    assertEquals(DataType.Name.LIST, cv.getCqlTypeName());

    try {
        Collection<String> types = cv.getValidatorTypes();
        types.add("test");
        fail("Validator types collection must be inmutable");
    } catch (Exception ex) {
        // ok
    }

    //        assertNotNull(cv.getAbstractType());
    //        assertEquals(cv.getAbstractType(), ListType.getInstance(TimeUUIDType.instance));
}