Package org.cassandraunit.model

Examples of org.cassandraunit.model.ColumnFamilyModel


    KeyspaceModel keyspace = new KeyspaceModel();
    keyspace.setName("keyspace");
    List<ColumnFamilyModel> columnFamilies = new ArrayList<ColumnFamilyModel>();

    /* column family */
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("columnFamily");
    columnFamily.setDefaultColumnValueType(ComparatorType.LONGTYPE);

    columnFamilies.add(columnFamily);
    keyspace.setColumnFamilies(columnFamilies);

    when(mockDataSet.getKeyspace()).thenReturn(keyspace);
View Full Code Here


    KeyspaceModel keyspace = new KeyspaceModel();
    keyspace.setName("compositeKeyspace");
    keyspace.getColumnFamilies();

    /* column family */
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("columnFamilyWithCompositeType");
    columnFamily.setKeyType(ComparatorType.UTF8TYPE);
    columnFamily.setComparatorType(ComparatorType.COMPOSITETYPE);
    columnFamily.setComparatorTypeAlias("(LongType,UTF8Type,IntegerType)");
    columnFamily.setDefaultColumnValueType(ComparatorType.UTF8TYPE);

    /* row1 */
    RowModel row = new RowModel();
    row.setKey(new GenericType("row1", GenericTypeEnum.UTF_8_TYPE));

    /* column1 */
    ColumnModel column1 = new ColumnModel();
    column1.setName(new GenericType(new String[] { "11", "aa", "11" }, new GenericTypeEnum[] {
        GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE }));
    column1.setValue(new GenericType("v1", GenericTypeEnum.UTF_8_TYPE));
    row.getColumns().add(column1);

    /* column2 */
    ColumnModel column2 = new ColumnModel();
    column2.setName(new GenericType(new String[] { "11", "ab", "11" }, new GenericTypeEnum[] {
        GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE }));
    column2.setValue(new GenericType("v2", GenericTypeEnum.UTF_8_TYPE));
    row.getColumns().add(column2);

    /* column3 */
    ColumnModel column3 = new ColumnModel();
    column3.setName(new GenericType(new String[] { "11", "ab", "12" }, new GenericTypeEnum[] {
        GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE }));
    column3.setValue(new GenericType("v3", GenericTypeEnum.UTF_8_TYPE));
    row.getColumns().add(column3);

    /* column4 */
    ColumnModel column4 = new ColumnModel();
    column4.setName(new GenericType(new String[] { "12", "aa", "11" }, new GenericTypeEnum[] {
        GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE }));
    column4.setValue(new GenericType("v4", GenericTypeEnum.UTF_8_TYPE));
    row.getColumns().add(column4);

    /* column5 */
    ColumnModel column5 = new ColumnModel();
    column5.setName(new GenericType(new String[] { "12", "ab", "11" }, new GenericTypeEnum[] {
        GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE }));
    column5.setValue(new GenericType("v5", GenericTypeEnum.UTF_8_TYPE));
    row.getColumns().add(column5);

    /* column6 */
    ColumnModel column6 = new ColumnModel();
    column6.setName(new GenericType(new String[] { "12", "zz", "12" }, new GenericTypeEnum[] {
        GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE }));
    column6.setValue(new GenericType("v6", GenericTypeEnum.UTF_8_TYPE));
    row.getColumns().add(column6);

    columnFamily.getRows().add(row);
    keyspace.getColumnFamilies().add(columnFamily);

    /* column family 2 with composite Type row key */
    ColumnFamilyModel columnFamily2 = new ColumnFamilyModel();
    columnFamily2.setName("columnFamilyWithRowKeyCompositeType");
    columnFamily2.setKeyType(ComparatorType.COMPOSITETYPE);
    columnFamily2.setKeyTypeAlias("(LongType,UTF8Type)");
    columnFamily2.setComparatorType(ComparatorType.UTF8TYPE);
    columnFamily2.setDefaultColumnValueType(ComparatorType.UTF8TYPE);

    /* row1 */
    RowModel row21 = new RowModel();
    row21.setKey(new GenericType(new String[] { "12", "az" }, new GenericTypeEnum[] { GenericTypeEnum.LONG_TYPE,
        GenericTypeEnum.UTF_8_TYPE }));

    /* column1 */
    ColumnModel column21 = new ColumnModel();
    column21.setName(new GenericType("a", GenericTypeEnum.UTF_8_TYPE));
    column21.setValue(new GenericType("a", GenericTypeEnum.UTF_8_TYPE));
    row21.getColumns().add(column21);
    columnFamily2.getRows().add(row21);

    keyspace.getColumnFamilies().add(columnFamily2);
    when(mockDataSet.getKeyspace()).thenReturn(keyspace);
    when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());

View Full Code Here

        KeyspaceModel keyspace = new KeyspaceModel();
        keyspace.setName("keyspaceWithNullColumnValue");
        keyspace.getColumnFamilies();

        /* column family */
        ColumnFamilyModel columnFamily = new ColumnFamilyModel();
        columnFamily.setName("columnFamilyWithNullColumnValue");
        columnFamily.setKeyType(ComparatorType.UTF8TYPE);
        columnFamily.setDefaultColumnValueType(ComparatorType.UTF8TYPE);

        /* row1 */
        RowModel row = new RowModel();
        row.setKey(new GenericType("rowWithNullColumnValue", GenericTypeEnum.UTF_8_TYPE));

        /* column1 */
        ColumnModel column1 = new ColumnModel();
        column1.setName(new GenericType("columnWithNullValue",GenericTypeEnum.UTF_8_TYPE));
        row.getColumns().add(column1);

        columnFamily.getRows().add(row);
        keyspace.getColumnFamilies().add(columnFamily);

        when(mockDataSet.getKeyspace()).thenReturn(keyspace);
        when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());

View Full Code Here

        KeyspaceModel keyspace = new KeyspaceModel();
        keyspace.setName("keyspaceWithTimestampedColumn");
        keyspace.getColumnFamilies();

        /* column family */
        ColumnFamilyModel columnFamily = new ColumnFamilyModel();
        columnFamily.setName("columnFamilyWithTimestampedColumn");
        columnFamily.setKeyType(ComparatorType.UTF8TYPE);
        columnFamily.setDefaultColumnValueType(ComparatorType.UTF8TYPE);

        /* row1 */
        RowModel row = new RowModel();
        row.setKey(new GenericType("rowWithTimestampedColumn", GenericTypeEnum.UTF_8_TYPE));

        /* column1 */
        ColumnModel column1 = new ColumnModel();
        column1.setName(new GenericType("columnWithTimestamp",GenericTypeEnum.UTF_8_TYPE));
        column1.setTimestamp(new Long(2020L));
        row.getColumns().add(column1);

        columnFamily.getRows().add(row);
        keyspace.getColumnFamilies().add(columnFamily);

        when(mockDataSet.getKeyspace()).thenReturn(keyspace);
        when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());

View Full Code Here

        KeyspaceModel keyspace = new KeyspaceModel();
        keyspace.setName("reversedKeyspace");
        keyspace.getColumnFamilies();

    /* column family */
        ColumnFamilyModel columnFamily = new ColumnFamilyModel();
        columnFamily.setName("columnFamilyWithReversedComparatorOnSimpleType");
        columnFamily.setKeyType(ComparatorType.UTF8TYPE);
        columnFamily.setComparatorType(ComparatorType.UTF8TYPE);
        columnFamily.setComparatorTypeAlias("(reversed=true)");
        columnFamily.setDefaultColumnValueType(ComparatorType.BYTESTYPE);

    /* row1 */
        RowModel row1 = new RowModel();
        row1.setKey(new GenericType("row1", GenericTypeEnum.UTF_8_TYPE));

    /* column1 */
        ColumnModel column1 = new ColumnModel();
        column1.setName(new GenericType("c", GenericTypeEnum.UTF_8_TYPE));
        column1.setValue(new GenericType("c", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column1);

    /* column2 */
        ColumnModel column2 = new ColumnModel();
        column2.setName(new GenericType("b", GenericTypeEnum.UTF_8_TYPE));
        column2.setValue(new GenericType("b", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column2);

    /* column3 */
        ColumnModel column3 = new ColumnModel();
        column3.setName(new GenericType("a", GenericTypeEnum.UTF_8_TYPE));
        column3.setValue(new GenericType("a", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column3);

        columnFamily.getRows().add(row1);
        keyspace.getColumnFamilies().add(columnFamily);
        when(mockDataSet.getKeyspace()).thenReturn(keyspace);
        when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());

        return mockDataSet;
View Full Code Here

        KeyspaceModel keyspace = new KeyspaceModel();
        keyspace.setName("reversedKeyspace");
        keyspace.getColumnFamilies();

    /* column family */
        ColumnFamilyModel columnFamily = new ColumnFamilyModel();
        columnFamily.setName("columnFamilyWithReversedCompOnCompositeTypes");
        columnFamily.setKeyType(ComparatorType.UTF8TYPE);
        columnFamily.setComparatorType(ComparatorType.COMPOSITETYPE);
        columnFamily.setComparatorTypeAlias("(LongType(reversed=true),UTF8Type,IntegerType(reversed=true))");
        columnFamily.setDefaultColumnValueType(ComparatorType.BYTESTYPE);

    /* row1 */
        RowModel row1 = new RowModel();
        row1.setKey(new GenericType("row1", GenericTypeEnum.UTF_8_TYPE));

        GenericTypeEnum[] columnNameTypes = {GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE};

    /* column1 */
        ColumnModel column1 = new ColumnModel();
        column1.setName(new GenericType(new String[] { "12", "aa", "11" }, columnNameTypes));
        column1.setValue(new GenericType("v6", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column1);

    /* column2 */
        ColumnModel column2 = new ColumnModel();
        column2.setName(new GenericType(new String[] { "12", "ab", "12" }, columnNameTypes));
        column2.setValue(new GenericType("v5", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column2);

    /* column3 */
        ColumnModel column3 = new ColumnModel();
        column3.setName(new GenericType(new String[] { "12", "ab", "11" }, columnNameTypes));
        column3.setValue(new GenericType("v4", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column3);

    /* column4 */
        ColumnModel column4 = new ColumnModel();
        column4.setName(new GenericType(new String[] { "11", "aa", "11" }, columnNameTypes));
        column4.setValue(new GenericType("v3", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column4);

    /* column5 */
        ColumnModel column5 = new ColumnModel();
        column5.setName(new GenericType(new String[] { "11", "ab", "12" }, columnNameTypes));
        column5.setValue(new GenericType("v2", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column5);

    /* column6 */
        ColumnModel column6 = new ColumnModel();
        column6.setName(new GenericType(new String[] { "11", "ab", "11" }, columnNameTypes));
        column6.setValue(new GenericType("v1", GenericTypeEnum.UTF_8_TYPE));
        row1.getColumns().add(column6);

        columnFamily.getRows().add(row1);
        keyspace.getColumnFamilies().add(columnFamily);
        when(mockDataSet.getKeyspace()).thenReturn(keyspace);
        when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());

        return mockDataSet;
View Full Code Here

        KeyspaceModel keyspace = new KeyspaceModel();
        keyspace.setName("binaryKeyspace");
        keyspace.getColumnFamilies();

        /* column family */
        ColumnFamilyModel columnFamily = new ColumnFamilyModel();
        columnFamily.setName("columnFamilyWithBinaryData");
        columnFamily.setKeyType(ComparatorType.UTF8TYPE);
        columnFamily.setDefaultColumnValueType(ComparatorType.BYTESTYPE);

        /* row1 */
        RowModel row = new RowModel();
        row.setKey(new GenericType("row1", GenericTypeEnum.UTF_8_TYPE));

        /* column1 */
        ColumnModel column1 = new ColumnModel();
        column1.setName(new GenericType("a", GenericTypeEnum.UTF_8_TYPE));
        column1.setValue(new GenericType("aGVsbG8gd29ybGQh", GenericTypeEnum.BYTES_TYPE));
        row.getColumns().add(column1);

        /* column2 */
        ColumnModel column2 = new ColumnModel();
        column2.setName(new GenericType("b", GenericTypeEnum.UTF_8_TYPE));
        String value2 = "V2VsY29tZSB0byBBcGFjaGUgQ2Fzc2FuZHJhDQoNClRoZSBBcGFjaGUgQ2Fzc2FuZHJhIGRhdGFiYXNlIGlzIHRoZSByaWdodCBjaG9pY2Ugd2hlbiB5b3UgbmVlZCBzY2FsYWJpbGl0eSBhbmQgaGln" +
                "aCBhdmFpbGFiaWxpdHkgd2l0aG91dCBjb21wcm9taXNpbmcgcGVyZm9ybWFuY2UuIExpbmVhciBzY2FsYWJpbGl0eSBhbmQgcHJvdmVuIGZhdWx0LXRvbGVyYW5jZSBvbiBjb21tb2RpdHkgaGFyZHdh" +
                "cmUgb3IgY2xvdWQgaW5mcmFzdHJ1Y3R1cmUgbWFrZSBpdCB0aGUgcGVyZmVjdCBwbGF0Zm9ybSBmb3IgbWlzc2lvbi1jcml0aWNhbCBkYXRhLiBDYXNzYW5kcmEncyBzdXBwb3J0IGZvciByZXBsaWNh" +
                "dGluZyBhY3Jvc3MgbXVsdGlwbGUgZGF0YWNlbnRlcnMgaXMgYmVzdC1pbi1jbGFzcywgcHJvdmlkaW5nIGxvd2VyIGxhdGVuY3kgZm9yIHlvdXIgdXNlcnMgYW5kIHRoZSBwZWFjZSBvZiBtaW5kIG9m" +
                "IGtub3dpbmcgdGhhdCB5b3UgY2FuIHN1cnZpdmUgcmVnaW9uYWwgb3V0YWdlcy4=";
        column2.setValue(new GenericType(value2, GenericTypeEnum.BYTES_TYPE));
        row.getColumns().add(column2);

        columnFamily.getRows().add(row);
        keyspace.getColumnFamilies().add(columnFamily);

        when(mockDataSet.getKeyspace()).thenReturn(keyspace);
        when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());

View Full Code Here

    List<Row<byte[], byte[], byte[]>> rows = result.get().getList();
    assertThat(rows.isEmpty(), is(true));
  }

  public static void assertThatKeyspaceModelWithCompositeTypeIsOk(DataSet dataSet) {
    ColumnFamilyModel columnFamilyModel = dataSet.getColumnFamilies().get(0);
    assertThat(columnFamilyModel.getName(), is("columnFamilyWithCompositeType"));
    assertThat(columnFamilyModel.getComparatorType().getTypeName(), is(ComparatorType.COMPOSITETYPE.getTypeName()));
    assertThat(columnFamilyModel.getComparatorTypeAlias(), is("(LongType,UTF8Type,IntegerType)"));

    GenericTypeEnum[] expecTedTypesBelongingCompositeType = new GenericTypeEnum[] { GenericTypeEnum.LONG_TYPE,
        GenericTypeEnum.UTF_8_TYPE, GenericTypeEnum.INTEGER_TYPE };

    List<ColumnModel> columns = columnFamilyModel.getRows().get(0).getColumns();
    assertThat(columns.get(0).getName().getType(), is(GenericTypeEnum.COMPOSITE_TYPE));
    assertThat(columns.get(0).getName().getCompositeValues(), is(new String[] { "11", "aa", "11" }));
    assertThat(columns.get(0).getName().getTypesBelongingCompositeType(), is(expecTedTypesBelongingCompositeType));

    assertThat(columns.get(1).getName().getType(), is(GenericTypeEnum.COMPOSITE_TYPE));
    assertThat(columns.get(1).getName().getCompositeValues(), is(new String[] { "11", "ab", "11" }));
    assertThat(columns.get(1).getName().getTypesBelongingCompositeType(), is(expecTedTypesBelongingCompositeType));

    assertThat(columns.get(2).getName().getType(), is(GenericTypeEnum.COMPOSITE_TYPE));
    assertThat(columns.get(2).getName().getCompositeValues(), is(new String[] { "11", "ab", "12" }));
    assertThat(columns.get(2).getName().getTypesBelongingCompositeType(), is(expecTedTypesBelongingCompositeType));

    assertThat(columns.get(3).getName().getType(), is(GenericTypeEnum.COMPOSITE_TYPE));
    assertThat(columns.get(3).getName().getCompositeValues(), is(new String[] { "12", "aa", "11" }));
    assertThat(columns.get(3).getName().getTypesBelongingCompositeType(), is(expecTedTypesBelongingCompositeType));

    assertThat(columns.get(4).getName().getType(), is(GenericTypeEnum.COMPOSITE_TYPE));
    assertThat(columns.get(4).getName().getCompositeValues(), is(new String[] { "12", "ab", "11" }));
    assertThat(columns.get(4).getName().getTypesBelongingCompositeType(), is(expecTedTypesBelongingCompositeType));

    assertThat(columns.get(5).getName().getType(), is(GenericTypeEnum.COMPOSITE_TYPE));
    assertThat(columns.get(5).getName().getCompositeValues(), is(new String[] { "12", "ab", "12" }));
    assertThat(columns.get(5).getName().getTypesBelongingCompositeType(), is(expecTedTypesBelongingCompositeType));

    ColumnFamilyModel columnFamilyModel2 = dataSet.getColumnFamilies().get(1);
    assertThat(columnFamilyModel2.getKeyType().getTypeName(), is(ComparatorType.COMPOSITETYPE.getTypeName()));
    assertThat(columnFamilyModel2.getKeyTypeAlias(), is("(LongType,UTF8Type)"));

    assertThat(columnFamilyModel2.getRows().get(0).getKey().getType(), is(GenericTypeEnum.COMPOSITE_TYPE));
    assertThat(columnFamilyModel2.getRows().get(0).getKey().getCompositeValues(), is(new String[] { "11", "a" }));
    assertThat(columnFamilyModel2.getRows().get(0).getKey().getTypesBelongingCompositeType(),
        is(new GenericTypeEnum[] { GenericTypeEnum.LONG_TYPE, GenericTypeEnum.UTF_8_TYPE }));
  }
View Full Code Here

TOP

Related Classes of org.cassandraunit.model.ColumnFamilyModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.