下面列出了com.datastax.driver.core.DataType#list ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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());
}
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));
}