@Test public void testCassandraBatchIngest() throws Exception { List<Book> books = getBookList(5); List<List<?>> ingestBooks = new ArrayList<>(); for (Book b : books) { List<Object> l = new ArrayList<>(); l.add(b.getIsbn()); l.add(b.getTitle()); l.add(b.getAuthor()); l.add(b.getPages()); l.add(b.getSaleDate()); l.add(b.isInStock()); ingestBooks.add(l); } Message<List<List<?>>> message = MessageBuilder.withPayload(ingestBooks).build(); this.cassandraMessageHandler3.handleMessage(message); Select select = QueryBuilder.select().all().from("book"); books = this.template.select(select, Book.class); assertEquals(5, books.size()); this.template.delete(books); }
private List<Book> getBookList(int numBooks) { List<Book> books = new ArrayList<>(); Book b; for (int i = 0; i < numBooks; i++) { b = new Book(); b.setIsbn(UUID.randomUUID().toString()); b.setTitle("Spring Data Cassandra Guide"); b.setAuthor("Cassandra Guru"); b.setPages(i * 10 + 5); b.setInStock(true); b.setSaleDate(new Date()); books.add(b); } return books; }
@Test public void testBasicCassandraInsert() throws Exception { Book b1 = new Book(); b1.setIsbn("123456-1"); b1.setTitle("Spring Integration Cassandra"); b1.setAuthor("Cassandra Guru"); b1.setPages(521); b1.setSaleDate(new Date()); b1.setInStock(true); Message<Book> message = MessageBuilder.withPayload(b1).build(); this.cassandraMessageHandler1.handleMessage(message); Select select = QueryBuilder.select().all().from("book"); List<Book> books = this.template.select(select, Book.class); assertEquals(1, books.size()); this.template.delete(b1); }