@ Then ( "^a Cassandra keyspace '(.+?)' contains a table '(.+?)' with values:$" ) public void assertValuesOfTable ( String keyspace , String tableName , DataTable data ) throws InterruptedException { // USE of Keyspace commonspec . getCassandraClient ( ) . useKeyspace ( keyspace ) ; // Obtain the types and column names of the datatable // to return in a hashmap, Map < String , String > dataTableColumns = extractColumnNamesAndTypes ( data . raw ( ) . get ( 0 ) ) ; // check if the table has columns String query = "SELECT * FROM " + tableName + " LIMIT 1;" ; com . datastax . driver . core . ResultSet res = commonspec . getCassandraClient ( ) . executeQuery ( query ) ; equalsColumns ( res . getColumnDefinitions ( ) , dataTableColumns ) ; //receiving the string from the select with the columns // that belong to the dataTable List < String > selectQueries = giveQueriesList ( data , tableName , columnNames ( data . raw ( ) . get ( 0 ) ) ) ; //Check the data of cassandra with different queries int index = 1 ; for ( String execQuery : selectQueries ) { res = commonspec . getCassandraClient ( ) . executeQuery ( execQuery ) ; List < Row > resAsList = res . all ( ) ; assertThat ( resAsList . size ( ) ) . as ( "The query " + execQuery + " not return any result on Cassandra" ) . isGreaterThan ( 0 ) ; assertThat ( resAsList . get ( 0 ) . toString ( ) . substring ( VALUE_SUBSTRING ) ) . as ( "The resultSet is not as expected" ) . isEqualTo ( data . raw ( ) . get ( index ) . toString ( ) . replace ( "'" , "" ) ) ; index ++ ; } }
Checks if a cassandra table contains the values of a DataTable .