Package org.cassandraunit.model

Examples of org.cassandraunit.model.ColumnFamilyModel


        assertThat(columnModel.getValue(), nullValue());
    }
    @Test
    public void shouldGetAColumnFamilyWithTimestampedColumn() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetWithTimestamp.xml");
        ColumnFamilyModel columnFamilyModel = dataSet.getColumnFamilies().get(0);
        assertThat(columnFamilyModel.getName(), is("columnFamilyWithTimestampedColumn"));
        ColumnModel columnModel = columnFamilyModel.getRows().get(0).getColumns().get(0);
        assertThat(columnModel.getName().getValue(), is("columnWithTimestamp"));
        assertThat(columnModel.getTimestamp(), is(2020L));
    }
View Full Code Here


    return columnFamily;
  }

  private static ColumnFamilyModel constructColumnFamily4ForDefinedValueSimple() {
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName4");
    columnFamily.setDefaultColumnValueType(ComparatorType.LONGTYPE);
    List<RowModel> rows = new ArrayList<RowModel>();

    /* row 1 */
    RowModel row1 = new RowModel();
    row1.setKey(new GenericType("01", GenericTypeEnum.BYTES_TYPE));
    List<ColumnModel> columns1 = new ArrayList<ColumnModel>();
    ColumnModel columnModel11 = new ColumnModel();
    columnModel11.setName(new GenericType("01", GenericTypeEnum.BYTES_TYPE));
    columnModel11.setValue(new GenericType("1", GenericTypeEnum.LONG_TYPE));
    columns1.add(columnModel11);
    ColumnModel columnModel12 = new ColumnModel();
    columnModel12.setName(new GenericType("02", GenericTypeEnum.BYTES_TYPE));
    columnModel12.setValue(new GenericType("19652258", GenericTypeEnum.LONG_TYPE));
    columns1.add(columnModel12);
    row1.setColumns(columns1);
    rows.add(row1);

    columnFamily.setRows(rows);

    return columnFamily;
  }
View Full Code Here

    }

    @Test
    public void shouldGetAColumnFamilyWithMetadataAndFunction() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetWithMetadataAndFunctions.xml");
        ColumnFamilyModel columnFamilyModel = dataSet.getColumnFamilies().get(0);
        assertThat(columnFamilyModel.getName(), is("columnFamilyWithMetadata"));
        List<ColumnModel> columns = columnFamilyModel.getRows().get(0).getColumns();
        ColumnModel column1 = columns.get(0);
        assertThat(column1.getName().getValue(),is("column1"));
        assertThat(column1.getValue().getValue(),is("1"));
        assertThat(column1.getValue().getType(),is(GenericTypeEnum.LONG_TYPE));
View Full Code Here

    return columnFamily;
  }

  private static ColumnFamilyModel constructColumnFamily3ForDefinedValueSimple() {
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName3");
    columnFamily.setKeyType(ComparatorType.UUIDTYPE);
    columnFamily.setComparatorType(ComparatorType.LEXICALUUIDTYPE);

    List<RowModel> rows = new ArrayList<RowModel>();

    /* row 1 */
    RowModel row1 = new RowModel();
    row1.setKey(new GenericType("13816710-1dd2-11b2-879a-782bcb80ff6a", GenericTypeEnum.UUID_TYPE));
    List<ColumnModel> columns1 = new ArrayList<ColumnModel>();
    ColumnModel columnModel11 = new ColumnModel();
    columnModel11
        .setName(new GenericType("13816710-1dd2-11b2-879a-782bcb80ff6a", GenericTypeEnum.LEXICAL_UUID_TYPE));
    columnModel11.setValue(new GenericType("11", GenericTypeEnum.BYTES_TYPE));
    columns1.add(columnModel11);
    ColumnModel columnModel12 = new ColumnModel();
    columnModel12
        .setName(new GenericType("13818e20-1dd2-11b2-879a-782bcb80ff6a", GenericTypeEnum.LEXICAL_UUID_TYPE));
    columnModel12.setValue(new GenericType("12", GenericTypeEnum.BYTES_TYPE));
    columns1.add(columnModel12);
    row1.setColumns(columns1);
    rows.add(row1);

    columnFamily.setRows(rows);

    return columnFamily;
  }
View Full Code Here

    @Test
    public void shouldGetAColumnFamilyWithColumnsInReverseOrder() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetWithReversedComparatorOnSimpleType.xml");

        ColumnFamilyModel columnFamilyModel = dataSet.getColumnFamilies().get(0);
        assertThat(columnFamilyModel.getName(), is("columnFamilyWithReversedComparatorOnSimpleType"));
        assertThat(columnFamilyModel.getComparatorType().getTypeName(), is(ComparatorType.UTF8TYPE.getTypeName()));
        assertThat(columnFamilyModel.getComparatorTypeAlias(), is("(reversed=true)"));

        List<ColumnModel> columns = columnFamilyModel.getRows().get(0).getColumns();

        ColumnModel column1 = columns.get(0);
        assertThat(column1.getName().getValue(), is("c"));
        assertThat(column1.getValue().getValue(), is("c"));
View Full Code Here

    return columnFamily;
  }

  private static ColumnFamilyModel constructColumnFamily2ForDefinedValueSimple() {
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName2");
    columnFamily.setKeyType(ComparatorType.LONGTYPE);
    columnFamily.setComparatorType(ComparatorType.INTEGERTYPE);

    List<RowModel> rows = new ArrayList<RowModel>();

    /* row 1 */
    RowModel row1 = new RowModel();
    row1.setKey(new GenericType("10", GenericTypeEnum.LONG_TYPE));
    List<ColumnModel> columns1 = new ArrayList<ColumnModel>();
    ColumnModel columnModel11 = new ColumnModel();
    columnModel11.setName(new GenericType("11", GenericTypeEnum.INTEGER_TYPE));
    columnModel11.setValue(new GenericType("11", GenericTypeEnum.BYTES_TYPE));
    columns1.add(columnModel11);
    ColumnModel columnModel12 = new ColumnModel();
    columnModel12.setName(new GenericType("12", GenericTypeEnum.INTEGER_TYPE));
    columnModel12.setValue(new GenericType("12", GenericTypeEnum.BYTES_TYPE));
    columns1.add(columnModel12);
    row1.setColumns(columns1);
    rows.add(row1);

    columnFamily.setRows(rows);

    return columnFamily;
  }
View Full Code Here

    @Test
    public void shouldGetAColumnFamilyWithCompositeColumnsInReverseOrder() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetWithReversedComparatorOnCompositeTypes.xml");

        ColumnFamilyModel columnFamilyModel = dataSet.getColumnFamilies().get(0);
        assertThat(columnFamilyModel.getName(), is("columnFamilyWithReversedComparatorOnCompositeTypes"));
        assertThat(columnFamilyModel.getComparatorType().getTypeName(), is(ComparatorType.COMPOSITETYPE.getTypeName()));
        assertThat(columnFamilyModel.getComparatorTypeAlias(), is("(LongType(reversed=true),UTF8Type,IntegerType(reversed=true))"));

        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[] { "12", "aa", "11" }));
        assertThat(columns.get(0).getName().getTypesBelongingCompositeType(), is(expecTedTypesBelongingCompositeType));
        assertThat(columns.get(0).getValue().getValue(), is("v6"));
View Full Code Here

    return columnFamily;
  }

  private static ColumnFamilyModel constructColumnFamily1ForDefinedValueSimple() {
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName");
    columnFamily.setKeyType(ComparatorType.TIMEUUIDTYPE);
    columnFamily.setComparatorType(ComparatorType.UTF8TYPE);

    List<RowModel> rows = new ArrayList<RowModel>();

    /* row 1 */
    RowModel row1 = new RowModel();
    row1.setKey(new GenericType("13816710-1dd2-11b2-879a-782bcb80ff6a", GenericTypeEnum.TIME_UUID_TYPE));
    List<ColumnModel> columns1 = new ArrayList<ColumnModel>();
    ColumnModel columnModel11 = new ColumnModel();
    columnModel11.setName(new GenericType("name11", GenericTypeEnum.UTF_8_TYPE));
    columnModel11.setValue(new GenericType("11", GenericTypeEnum.BYTES_TYPE));
    columns1.add(columnModel11);
    ColumnModel columnModel12 = new ColumnModel();
    columnModel12.setName(new GenericType("name12", GenericTypeEnum.UTF_8_TYPE));
    columnModel12.setValue(new GenericType("12", GenericTypeEnum.BYTES_TYPE));
    columns1.add(columnModel12);
    row1.setColumns(columns1);
    rows.add(row1);

    /* row 2 */
    RowModel row2 = new RowModel();
    row2.setKey(new GenericType("13818e20-1dd2-11b2-879a-782bcb80ff6a", GenericTypeEnum.TIME_UUID_TYPE));
    List<ColumnModel> columns2 = new ArrayList<ColumnModel>();
    ColumnModel columnModel21 = new ColumnModel();
    columnModel21.setName(new GenericType("name21", GenericTypeEnum.UTF_8_TYPE));
    columnModel21.setValue(new GenericType("21", GenericTypeEnum.BYTES_TYPE));
    columns2.add(columnModel21);
    ColumnModel columnModel22 = new ColumnModel();
    columnModel22.setName(new GenericType("name22", GenericTypeEnum.UTF_8_TYPE));
    columnModel22.setValue(new GenericType("22", GenericTypeEnum.BYTES_TYPE));
    columns2.add(columnModel22);
    row2.setColumns(columns2);
    rows.add(row2);

    columnFamily.setRows(rows);

    return columnFamily;
  }
View Full Code Here

    }

    @Test
    public void shouldGetBinaryData() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetWithBinaryData.xml");
        ColumnFamilyModel columnFamilyModel = dataSet.getColumnFamilies().get(0);
        assertThat(columnFamilyModel.getName(), is("columnFamilyWithBinaryData"));
        List<ColumnModel> columns = columnFamilyModel.getRows().get(0).getColumns();
        ColumnModel column1 = columns.get(0);
        assertThat(column1.getName().getValue(), is("a"));
        assertThat(column1.getValue().getValue(), is("aGVsbG8gd29ybGQh"));
        assertThat(column1.getValue().getType(), is(GenericTypeEnum.BYTES_TYPE));
    }
View Full Code Here

    DataSet mockDataSet = mock(DataSet.class);
    /* keyspace */
    KeyspaceModel keyspace = new KeyspaceModel();
    keyspace.setName("beautifulKeyspaceName");
    List<ColumnFamilyModel> columnFamilies = new ArrayList<ColumnFamilyModel>();
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName");
    columnFamily.setType(ColumnType.SUPER);

    List<RowModel> rows = new ArrayList<RowModel>();

    RowModel row1 = new RowModel();
    row1.setKey(new GenericType("01", GenericTypeEnum.BYTES_TYPE));
    List<SuperColumnModel> superColumns1 = new ArrayList<SuperColumnModel>();

    SuperColumnModel superColumn11 = new SuperColumnModel();
    superColumn11.setName(new GenericType("11", GenericTypeEnum.BYTES_TYPE));
    List<ColumnModel> columns11 = new ArrayList<ColumnModel>();
    columns11.add(constructDefaultColumnForMock("1110", "1110"));
    columns11.add(constructDefaultColumnForMock("1120", "1120"));
    superColumn11.setColumns(columns11);
    superColumns1.add(superColumn11);

    SuperColumnModel superColumn12 = new SuperColumnModel();
    superColumn12.setName(new GenericType("12", GenericTypeEnum.BYTES_TYPE));
    List<ColumnModel> columns12 = new ArrayList<ColumnModel>();
    columns12.add(constructDefaultColumnForMock("1210", "1210"));
    columns12.add(constructDefaultColumnForMock("1220", "1220"));
    superColumn12.setColumns(columns12);
    superColumns1.add(superColumn12);

    row1.setSuperColumns(superColumns1);
    rows.add(row1);

    RowModel row2 = new RowModel();
    row2.setKey(new GenericType("02", GenericTypeEnum.BYTES_TYPE));
    List<SuperColumnModel> superColumns2 = new ArrayList<SuperColumnModel>();
    SuperColumnModel superColumn21 = new SuperColumnModel();
    superColumn21.setName(new GenericType("21", GenericTypeEnum.BYTES_TYPE));
    List<ColumnModel> columns21 = new ArrayList<ColumnModel>();
    columns21.add(constructDefaultColumnForMock("2110", "2110"));
    columns21.add(constructDefaultColumnForMock("2120", "2120"));
    superColumn21.setColumns(columns21);
    superColumns2.add(superColumn21);
    row2.setSuperColumns(superColumns2);

    rows.add(row2);

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

    when(mockDataSet.getKeyspace()).thenReturn(keyspace);
    when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());
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.