@@ -57,8 +57,8 @@ public static void startCassandraEmbedded() throws InterruptedException, TTransp
5757 Session session = cluster .connect ();
5858 session .execute (KEYSPACE_CREATION_QUERY );
5959 session .execute (KEYSPACE_ACTIVATE_QUERY );
60- Thread .sleep (2000 );
6160 LOGGER .info ("KeySpace created and activated." );
61+ Thread .sleep (5000 );
6262 }
6363
6464 @ Before
@@ -69,7 +69,7 @@ public void createTable() throws InterruptedException, TTransportException, Conf
6969 @ Test
7070 public void whenSavingBook_thenAvailableOnRetrieval_usingQueryBuilder () {
7171 UUID uuid = UUIDs .timeBased ();
72- Insert insert = QueryBuilder .insertInto (DATA_TABLE_NAME ).value ("isbn " , uuid ).value ("title" , "Head First Java" ).value ("publisher" , "OReilly Media" ).value ("tags" , ImmutableSet .of ("Software" ));
72+ Insert insert = QueryBuilder .insertInto (DATA_TABLE_NAME ).value ("id " , uuid ).value ("title" , "Head First Java" ).value ("publisher" , "OReilly Media" ).value ("tags" , ImmutableSet .of ("Software" ));
7373 cassandraTemplate .execute (insert );
7474 Select select = QueryBuilder .select ().from ("book" ).limit (10 );
7575 Book retrievedBook = cassandraTemplate .selectOne (select , Book .class );
@@ -79,7 +79,7 @@ public void whenSavingBook_thenAvailableOnRetrieval_usingQueryBuilder() {
7979 @ Test
8080 public void whenSavingBook_thenAvailableOnRetrieval_usingCQLStatements () {
8181 UUID uuid = UUIDs .timeBased ();
82- String insertCql = "insert into book (isbn , title, publisher, tags) values " + "(" + uuid + ", 'Head First Java', 'OReilly Media', {'Software'})" ;
82+ String insertCql = "insert into book (id , title, publisher, tags) values " + "(" + uuid + ", 'Head First Java', 'OReilly Media', {'Software'})" ;
8383 cassandraTemplate .execute (insertCql );
8484 Select select = QueryBuilder .select ().from ("book" ).limit (10 );
8585 Book retrievedBook = cassandraTemplate .selectOne (select , Book .class );
@@ -89,16 +89,16 @@ public void whenSavingBook_thenAvailableOnRetrieval_usingCQLStatements() {
8989 @ Test
9090 public void whenSavingBook_thenAvailableOnRetrieval_usingPreparedStatements () {
9191 UUID uuid = UUIDs .timeBased ();
92- String insertPreparedCql = "insert into book (isbn , title, publisher, tags) values (?, ?, ?, ?)" ;
93- List <Object > bookList = new ArrayList <>();
94- List <List <?>> bookListOfList = new ArrayList <>();
95- bookList .add (uuid );
96- bookList .add ("Head First Java" );
97- bookList .add ("OReilly Media" );
98- bookList .add (ImmutableSet .of ("Software" ));
99- bookListOfList .add (bookList );
100- cassandraTemplate .ingest (insertPreparedCql , bookListOfList );
101- Select select = QueryBuilder .select ().from ("book" ). limit ( 10 ) ;
92+ String insertPreparedCql = "insert into book (id , title, publisher, tags) values (?, ?, ?, ?)" ;
93+ List <Object > singleBookArgsList = new ArrayList <>();
94+ List <List <?>> bookList = new ArrayList <>();
95+ singleBookArgsList .add (uuid );
96+ singleBookArgsList .add ("Head First Java" );
97+ singleBookArgsList .add ("OReilly Media" );
98+ singleBookArgsList .add (ImmutableSet .of ("Software" ));
99+ bookList .add (singleBookArgsList );
100+ cassandraTemplate .ingest (insertPreparedCql , bookList );
101+ Select select = QueryBuilder .select ().from ("book" );
102102 Book retrievedBook = cassandraTemplate .selectOne (select , Book .class );
103103 assertEquals (uuid , retrievedBook .getId ());
104104 }
0 commit comments