Java Code Examples for com.datastax.driver.core.DataType#map()
The following examples show how to use
com.datastax.driver.core.DataType#map() .
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 |
@Test public void testMap() { // map from ASCII to Double // test non-frozen DataType mapType = DataType.map(DataType.ascii(), DataType.cdouble()); AbstractType<?> convertedType = CassandraTypeConverter.convert(mapType); MapType<?, ?> expectedType = MapType.getInstance(AsciiType.instance, DoubleType.instance, true); Assert.assertEquals(expectedType, convertedType); // test frozen mapType = DataType.map(DataType.ascii(), DataType.cdouble(), true); convertedType = CassandraTypeConverter.convert(mapType); expectedType = MapType.getInstance(AsciiType.instance, DoubleType.instance, false); Assert.assertEquals(expectedType, convertedType); Assert.assertTrue("Expected convertType to be frozen", convertedType.isFrozenCollection()); }
Example 2
Source File: CellValidatorTest.java From deep-spark with Apache License 2.0 | 6 votes |
public void testDataTypeMapInstantiation() { DataType type = DataType.map(DataType.text(), DataType.bigint()); CellValidator cv = cellValidator(type); assertNotNull(cv); assertEquals(cv.getValidatorClassName(), MapType.class.getName()); assertNotNull(cv.getValidatorTypes()); assertEquals(cv.validatorKind(), Kind.MAP); assertEquals(cv.getValidatorTypes().size(), 2); Iterator<String> types = cv.getValidatorTypes().iterator(); assertEquals(types.next(), "text"); assertEquals(types.next(), "bigint"); assertEquals(DataType.Name.MAP, cv.getCqlTypeName()); try { Collection<String> ctypes = cv.getValidatorTypes(); ctypes.add("test"); fail("Validator types collection must be inmutable"); } catch (Exception ex) { // ok } // assertNotNull(cv.getAbstractType()); // assertEquals(cv.getAbstractType(), MapType.getInstance(UTF8Type.instance, LongType.instance)); }
Example 3
Source File: CellValidatorTest.java From deep-spark with Apache License 2.0 | 5 votes |
public void testEquality() { DataType type = DataType.map(DataType.text(), DataType.bigint()); CellValidator cv = cellValidator(type); assertFalse(cv.equals(null)); assertTrue(cv.equals(cv)); assertFalse(cv.equals(cellValidator(DataType.timeuuid()))); assertFalse(cv.equals(cellValidator(DataType.map(DataType.timestamp(), DataType.uuid())))); assertTrue(cv.equals(cellValidator(DataType.map(DataType.text(), DataType.bigint())))); assertEquals(DataType.Name.MAP, cv.getCqlTypeName()); }