Package org.cassandraunit.model

Examples of org.cassandraunit.model.ColumnFamilyModel


    public void shouldGetColumnFamiliesWithDefinedValues() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetDefinedValues.xml");
        assertThat(dataSet.getColumnFamilies(), notNullValue());
        assertThat(dataSet.getColumnFamilies().isEmpty(), is(false));

        ColumnFamilyModel beautifulColumnFamily = dataSet.getColumnFamilies().get(0);
        assertThat(beautifulColumnFamily, notNullValue());
        assertThat(beautifulColumnFamily.getName(), is("beautifulColumnFamilyName"));
        assertThat(beautifulColumnFamily.getType(), is(ColumnType.SUPER));
        assertThat(beautifulColumnFamily.getKeyType().getClassName(),is(ComparatorType.TIMEUUIDTYPE.getClassName()));
        assertThat(beautifulColumnFamily.getComparatorType().getClassName(),is(ComparatorType.UTF8TYPE.getClassName()));
        assertThat(beautifulColumnFamily.getSubComparatorType().getClassName(),is(ComparatorType.LONGTYPE.getClassName()));
        assertThat(beautifulColumnFamily.getDefaultColumnValueType().getClassName(),is(ComparatorType.UTF8TYPE.getClassName()));
        assertThat(beautifulColumnFamily.getComment(), is("amazing comment"));
        assertThat(beautifulColumnFamily.getCompactionStrategy(), is("LeveledCompactionStrategy"));
        assertThat(beautifulColumnFamily.getCompactionStrategyOptions().get(0).getName(), is("sstable_size_in_mb"));
        assertThat(beautifulColumnFamily.getCompactionStrategyOptions().get(0).getValue(), is("10"));
        assertThat(beautifulColumnFamily.getGcGraceSeconds(), is(9999));
        assertThat(beautifulColumnFamily.getMaxCompactionThreshold(), is(31));
        assertThat(beautifulColumnFamily.getMinCompactionThreshold(), is(3));
        assertThat(beautifulColumnFamily.getReadRepairChance(), is(0.1d));
        assertThat(beautifulColumnFamily.getReplicationOnWrite(), is(Boolean.FALSE));

        ColumnFamilyModel amazingColumnFamily = dataSet.getColumnFamilies().get(1);
        assertThat(amazingColumnFamily.getName(), is("amazingColumnFamilyName"));
        assertThat(amazingColumnFamily.getType(), is(ColumnType.STANDARD));
        assertThat(amazingColumnFamily.getKeyType().getClassName(),
                is(ComparatorType.UTF8TYPE.getClassName()));
        assertThat(amazingColumnFamily.getComparatorType().getClassName(),
                is(ComparatorType.UTF8TYPE.getClassName()));
    }
View Full Code Here


    @Test
    public void shouldGetDefaultBytesTypeForColumnValue() throws Exception {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetColumnValueTest.xml");

        ColumnFamilyModel actualColumnFamily = dataSet.getColumnFamilies().get(0);
        assertThat(actualColumnFamily, notNullValue());
        assertThat(actualColumnFamily.getName(), is("beautifulColumnFamilyName"));
        assertThat(actualColumnFamily.getRows(), notNullValue());

        RowModel actualRow = actualColumnFamily.getRows().get(0);
        assertThat(actualRow, notNullValue());
        assertThat(actualRow.getColumns(), notNullValue());

        ColumnModel actualColumn = actualRow.getColumns().get(0);
        assertThat(actualColumn, notNullValue());
View Full Code Here

    }

    @Test
    public void shouldGetDefaultUTF8TypeForColumnValue() throws Exception {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetColumnValueTest.xml");
        ColumnFamilyModel actualColumnFamily = dataSet.getColumnFamilies().get(1);
        assertThat(actualColumnFamily, notNullValue());
        assertThat(actualColumnFamily.getName(), is("beautifulColumnFamilyName2"));
        assertThat(actualColumnFamily.getRows(), notNullValue());
        RowModel actualRow = actualColumnFamily.getRows().get(0);
        assertThat(actualRow, notNullValue());
        assertThat(actualRow.getColumns(), notNullValue());

        ColumnModel actualColumn = actualRow.getColumns().get(0);
        assertThat(actualColumn, notNullValue());
View Full Code Here

    }

    @Test
    public void shouldGetDefaultUTF8TypeAndDefinedLongTypeForColumnValue() throws Exception {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetColumnValueTest.xml");
        ColumnFamilyModel actualColumnFamily = dataSet.getColumnFamilies().get(2);
        assertThat(actualColumnFamily, notNullValue());
        assertThat(actualColumnFamily.getName(), is("beautifulColumnFamilyName3"));
        assertThat(actualColumnFamily.getRows(), notNullValue());

        RowModel actualRowOfColumnFamily = actualColumnFamily.getRows().get(0);
        assertThat(actualRowOfColumnFamily, notNullValue());
        assertThat(actualRowOfColumnFamily.getColumns(), notNullValue());
        ColumnModel actualColumn0OfColumnFamily = actualRowOfColumnFamily.getColumns().get(0);
        assertThat(actualColumn0OfColumnFamily, notNullValue());
        assertThat(actualColumn0OfColumnFamily.getValue().toString(), is("1"));
View Full Code Here

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

        ColumnFamilyModel actualColumnFamilyModel2 = dataSet.getColumnFamilies().get(2);
        assertThat(actualColumnFamilyModel2.getName(), is("counterStandardColumnFamilyName"));
        assertThat(actualColumnFamilyModel2.getType(), is(ColumnType.STANDARD));
        assertThat(actualColumnFamilyModel2.getKeyType().getClassName(), is(ComparatorType.LONGTYPE.getClassName()));
        assertThat(actualColumnFamilyModel2.getKeyType().getClassName(), is(ComparatorType.LONGTYPE.getClassName()));
        assertThat(actualColumnFamilyModel2.getComparatorType().getClassName(), is(ComparatorType.UTF8TYPE.getClassName()));
        assertThat(actualColumnFamilyModel2.getDefaultColumnValueType().getClassName(), is(ComparatorType.COUNTERTYPE.getClassName()));
        assertThat(actualColumnFamilyModel2.getRows(), notNullValue());
        assertThat(actualColumnFamilyModel2.getRows().size(), is(1));

        RowModel actualRowOfColumnFamily2 = actualColumnFamilyModel2.getRows().get(0);
        assertThat(actualRowOfColumnFamily2, notNullValue());
        assertThat(actualRowOfColumnFamily2.getColumns(), notNullValue());
        assertThat(actualRowOfColumnFamily2.getColumns().size(), is(2));

        ColumnModel actualColumn0OfRowOfColumnFamily2 = actualRowOfColumnFamily2.getColumns().get(0);
View Full Code Here

    when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());
    return mockDataSet;
  }

  private static ColumnFamilyModel constructColumnFamily7ForDefinedValueSimple() {
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName7");
    columnFamily.setType(ColumnType.SUPER);
    columnFamily.setKeyType(ComparatorType.LONGTYPE);
    columnFamily.setComparatorType(ComparatorType.UTF8TYPE);
    columnFamily.setSubComparatorType(ComparatorType.UTF8TYPE);
    columnFamily.setDefaultColumnValueType(ComparatorType.COUNTERTYPE);
    List<RowModel> rows = new ArrayList<RowModel>();

    /* row 1 */
    RowModel row1 = new RowModel();
    row1.setKey(new GenericType("10", GenericTypeEnum.LONG_TYPE));
    List<SuperColumnModel> superColumns = new ArrayList<SuperColumnModel>();
    row1.setSuperColumns(superColumns);
    SuperColumnModel superColumn = new SuperColumnModel();
    superColumn.setName(new GenericType("superColumnName11", GenericTypeEnum.UTF_8_TYPE));
    superColumns.add(superColumn);

    List<ColumnModel> columns = new ArrayList<ColumnModel>();
    superColumn.setColumns(columns);

    ColumnModel columnModel111 = new ColumnModel();
    columnModel111.setName(new GenericType("counter111", GenericTypeEnum.UTF_8_TYPE));
    columnModel111.setValue(new GenericType("111", GenericTypeEnum.COUNTER_TYPE));
    columns.add(columnModel111);
    ColumnModel columnModel112 = new ColumnModel();
    columnModel112.setName(new GenericType("counter112", GenericTypeEnum.UTF_8_TYPE));
    columnModel112.setValue(new GenericType("112", GenericTypeEnum.COUNTER_TYPE));
    columns.add(columnModel112);

    rows.add(row1);

    columnFamily.setRows(rows);

    return columnFamily;
  }
View Full Code Here

    }

    @Test
    public void shouldGetCounterSuperColumnFamily() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetDefinedValues.xml");
        ColumnFamilyModel actualCounterSupercolumnFamilyModel = dataSet.getColumnFamilies().get(3);
        assertThat(actualCounterSupercolumnFamilyModel.getName(), is("counterSuperColumnFamilyName"));
        assertThat(actualCounterSupercolumnFamilyModel.getType(), is(ColumnType.SUPER));
        assertThat(actualCounterSupercolumnFamilyModel.getKeyType().getClassName(), is(ComparatorType.LONGTYPE.getClassName()));
        assertThat(actualCounterSupercolumnFamilyModel.getComparatorType().getClassName(), is(ComparatorType.UTF8TYPE.getClassName()));
        assertThat(actualCounterSupercolumnFamilyModel.getDefaultColumnValueType().getClassName(), is(ComparatorType.COUNTERTYPE.getClassName()));

        assertThat(actualCounterSupercolumnFamilyModel.getRows(), notNullValue());
        assertThat(actualCounterSupercolumnFamilyModel.getRows().size(), is(1));
        assertThat(actualCounterSupercolumnFamilyModel.getRows().get(0), notNullValue());
        assertThat(actualCounterSupercolumnFamilyModel.getRows().get(0).getSuperColumns(), notNullValue());
        assertThat(actualCounterSupercolumnFamilyModel.getRows().get(0).getSuperColumns().size(), is(1));

        SuperColumnModel actualSuperColumnModel = actualCounterSupercolumnFamilyModel.getRows().get(0).getSuperColumns().get(0);
        assertThat(actualSuperColumnModel, notNullValue());
        assertThat(actualSuperColumnModel.getName().getValue(), is("counter11"));
        assertThat(actualSuperColumnModel.getColumns(), notNullValue());
        assertThat(actualSuperColumnModel.getColumns().size(), is(2));
View Full Code Here

    return columnFamily;
  }

  private static ColumnFamilyModel constructColumnFamily6ForDefinedValueSimple() {
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName6");
    columnFamily.setKeyType(ComparatorType.LONGTYPE);
    columnFamily.setComparatorType(ComparatorType.UTF8TYPE);
    columnFamily.setDefaultColumnValueType(ComparatorType.COUNTERTYPE);
    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("counter11", GenericTypeEnum.UTF_8_TYPE));
    columnModel11.setValue(new GenericType("11", GenericTypeEnum.COUNTER_TYPE));
    columns1.add(columnModel11);
    ColumnModel columnModel12 = new ColumnModel();
    columnModel12.setName(new GenericType("counter12", GenericTypeEnum.UTF_8_TYPE));
    columnModel12.setValue(new GenericType("12", GenericTypeEnum.COUNTER_TYPE));
    columns1.add(columnModel12);
    row1.setColumns(columns1);
    rows.add(row1);

    columnFamily.setRows(rows);

    return columnFamily;
  }
View Full Code Here

    }

    @Test
    public void shouldGetAColumnFamilyWithNullColumnValue() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetWithNullColumnValue.xml");
        ColumnFamilyModel columnFamilyModel = dataSet.getColumnFamilies().get(0);
        assertThat(columnFamilyModel.getName(), is("columnFamilyWithNullColumnValue"));
        ColumnModel columnModel = columnFamilyModel.getRows().get(0).getColumns().get(0);
        assertThat(columnModel.getName().getValue(), is("columnWithNullColumnValue"));
        assertThat(columnModel.getValue(), nullValue());
    }
View Full Code Here

    return columnFamily;
  }

  private static ColumnFamilyModel constructColumnFamily5ForDefinedValueSimple() {
    ColumnFamilyModel columnFamily = new ColumnFamilyModel();
    columnFamily.setName("beautifulColumnFamilyName5");
    columnFamily.setDefaultColumnValueType(ComparatorType.UTF8TYPE);
    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

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.