Package org.cassandraunit.dataset

Examples of org.cassandraunit.dataset.DataSet


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

  public static DataSet getMockDataSetWithSchemaAndDefaultColumnValueValidator() {
    DataSet mockDataSet = mock(DataSet.class);
    /* keyspace */
    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);
    when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());
    return mockDataSet;
  }
View Full Code Here


    }

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

        dataSet.getKeyspace();
    }

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

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

  public static DataSet getMockDataSetWithDefaultValuesAndReplicationFactor2() {
    DataSet mockDataSet = mock(DataSet.class);
    KeyspaceModel keyspace = contructDefaultValuesKeyspace();
    keyspace.setReplicationFactor(2);

    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 shouldNotGetAJsonDataSetStructureBecauseOfMissingKeyspaceName() {
        DataSet dataSet = new ClassPathJsonDataSet("json/dataSetBadMissingKeyspaceName.json");
        dataSet.getKeyspace();
    }
View Full Code Here

        dataSet.getKeyspace();
    }

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

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

  public static DataSet getMockDataSetWithDefaultValuesAndNetworkTopologyStrategy() {
    DataSet mockDataSet = mock(DataSet.class);
    KeyspaceModel keyspace = contructDefaultValuesKeyspace();
    keyspace.setStrategy(StrategyModel.NETWORK_TOPOLOGY_STRATEGY);
    when(mockDataSet.getKeyspace()).thenReturn(keyspace);
    when(mockDataSet.getColumnFamilies()).thenReturn(keyspace.getColumnFamilies());
    return mockDataSet;
  }
View Full Code Here

                is(ComparatorType.UTF8TYPE.getClassName()));
    }

    @Test
    public void shouldGetOneStandardColumnFamilyDataWithDefaultValues() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetDefaultValues.xml");
        List<RowModel> rows = dataSet.getColumnFamilies().get(0).getRows();
        assertThat(rows, notNullValue());
        assertThat(rows.size(), is(3));
        verifyStandardRow(rows.get(0), "10", 2, "11", "11", "12", "12");
        verifyStandardRow(rows.get(1), "20", 3, "21", "21", "22", "22");
        verifyStandardRow(rows.get(2), "30", 2, "31", "31", "32", "32");
View Full Code Here

        dataSet.getKeyspace();
    }

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

        assertThat(row.getColumns().get(1).getValue().toString(), is(expectedSecondColumnValue));
    }

    @Test
    public void shouldGetOneSuperColumnFamilyData() {
        DataSet dataSet = new ClassPathXmlDataSet("xml/dataSetDefinedValues.xml");
        assertThat(dataSet.getColumnFamilies().get(0).getRows(), notNullValue());
        assertThat(dataSet.getColumnFamilies().get(0).getRows().size(), is(2));
        RowModel actualrow0 = dataSet.getColumnFamilies().get(0).getRows().get(0);
        assertThat(actualrow0, notNullValue());
        assertThat(actualrow0.getKey().toString(), is("13816710-1dd2-11b2-879a-782bcb80ff6a"));
        assertThat(actualrow0.getColumns(), notNullValue());
        assertThat(actualrow0.getColumns().isEmpty(), is(true));
        assertThat(actualrow0.getSuperColumns(), notNullValue());
        assertThat(actualrow0.getSuperColumns().size(), is(2));

        SuperColumnModel actualSuperColumn = actualrow0.getSuperColumns().get(0);
        assertThat(actualSuperColumn, notNullValue());
        assertThat(actualSuperColumn.getName().toString(), is("name11"));
        assertThat(actualSuperColumn.getColumns(), notNullValue());
        assertThat(actualSuperColumn.getColumns().size(), is(2));

        ColumnModel actualColumn0OfRow0 = actualSuperColumn.getColumns().get(0);
        assertThat(actualColumn0OfRow0, notNullValue());
        assertThat(actualColumn0OfRow0.getName().toString(), is("111"));
        assertThat(actualColumn0OfRow0.getValue().toString(), is("value111"));

        ColumnModel actualColumn1OfRow0 = actualSuperColumn.getColumns().get(1);
        assertThat(actualColumn1OfRow0, notNullValue());
        assertThat(actualColumn1OfRow0.getName().toString(), is("112"));
        assertThat(actualColumn1OfRow0.getValue().toString(), is("value112"));

        SuperColumnModel actualSuperColumn1OfRow0 = actualrow0.getSuperColumns().get(1);
        assertThat(actualSuperColumn1OfRow0.getName().toString(), is("name12"));
        assertThat(actualSuperColumn1OfRow0.getColumns(), notNullValue());
        assertThat(actualSuperColumn1OfRow0.getColumns().size(), is(2));

        ColumnModel actualColumn0OfSuperColumn1OofRow0 = actualSuperColumn1OfRow0.getColumns().get(0);
        assertThat(actualColumn0OfSuperColumn1OofRow0, notNullValue());
        assertThat(actualColumn0OfSuperColumn1OofRow0.getName().toString(), is("121"));
        assertThat(actualColumn0OfSuperColumn1OofRow0.getValue().toString(), is("value121"));

        ColumnModel actualColumn1OfSuperColumn1ofRow0 = actualSuperColumn1OfRow0.getColumns().get(1);
        assertThat(actualColumn1OfSuperColumn1ofRow0, notNullValue());
        assertThat(actualColumn1OfSuperColumn1ofRow0.getName().toString(), is("122"));
        assertThat(actualColumn1OfSuperColumn1ofRow0.getValue().toString(), is("value122"));

        RowModel row1 = dataSet.getColumnFamilies().get(0).getRows().get(1);
        assertThat(row1, notNullValue());
        assertThat(row1.getKey().toString(), is("13818e20-1dd2-11b2-879a-782bcb80ff6a"));
        assertThat(row1.getColumns(), notNullValue());
        assertThat(row1.getColumns().isEmpty(), is(true));
        assertThat(row1.getSuperColumns(), notNullValue());
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.