Package org.cassandraunit.dataset

Examples of org.cassandraunit.dataset.DataSet


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

  public static DataSet getMockDataSetWithCompositeType() {
    DataSet mockDataSet = mock(DataSet.class);
    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());

    return mockDataSet;
  }
View Full Code Here


        dataSet.getKeyspace();
    }

    @Test(expected = ParseException.class)
    public void shouldNotGetAJsonDataSetStructureBecauseOfInvalidColumnFamilyType() {
        DataSet dataSet = new ClassPathJsonDataSet("json/dataSetBadInvalidColumnFamilyType.json");
        dataSet.getKeyspace();
    }
View Full Code Here

        assertThat(actualColumn0OfSuperColumn2OfRow1.getValue().toString(), is("value231"));
    }

    @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);
View Full Code Here

        dataSet.getKeyspace();
    }

    @Test(expected = ParseException.class)
    public void shouldNotGetAJsonDataSetStructureBecauseOfInvalidRowKeyType() {
        DataSet dataSet = new ClassPathJsonDataSet("json/dataSetBadInvalidKeyType.json");
        dataSet.getKeyspace();
    }
View Full Code Here

    return mockDataSet;
  }

    public static DataSet getMockDataSetWithNullColumnValue() {
        DataSet mockDataSet = mock(DataSet.class);
        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());

        return mockDataSet;
    }
View Full Code Here

        assertThat(actualColumn.getValue().getType(), is(GenericTypeEnum.BYTES_TYPE));
    }

    @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());
View Full Code Here

        assertThat(actualColumn.getValue().getType(), is(GenericTypeEnum.UTF_8_TYPE));
    }

    @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);
View Full Code Here

        dataSet.getKeyspace();
    }

    @Test(expected = ParseException.class)
    public void shouldNotGetAJsonDataSetStructureBecauseOfInvalidComparatorType() {
        DataSet dataSet = new ClassPathJsonDataSet("json/dataSetBadInvalidComparatorType.json");
        dataSet.getKeyspace();
    }
View Full Code Here

        return mockDataSet;
    }

    public static DataSet getMockDataSetWithTimestampedColumn() {
        DataSet mockDataSet = mock(DataSet.class);
        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());

        return mockDataSet;
    }
View Full Code Here

TOP

Related Classes of org.cassandraunit.dataset.DataSet

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.