DATACASS-148: fixed
This commit is contained in:
@@ -68,8 +68,7 @@ public class CassandraTemplate extends CqlTemplate implements CassandraOperation
|
||||
/**
|
||||
* Default Constructor for wiring in the required components later
|
||||
*/
|
||||
public CassandraTemplate() {
|
||||
}
|
||||
public CassandraTemplate() {}
|
||||
|
||||
public CassandraTemplate(Session session) {
|
||||
this(session, new MappingCassandraConverter());
|
||||
@@ -536,7 +535,12 @@ public class CassandraTemplate extends CqlTemplate implements CassandraOperation
|
||||
|
||||
protected <T> List<T> batchInsert(List<T> entities, WriteOptions options, boolean asychronously) {
|
||||
|
||||
Assert.notEmpty(entities);
|
||||
if (entities == null || entities.size() == 0) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("no-op due to given null or empty list");
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
Batch b = createInsertBatchQuery(getTableName(entities.get(0).getClass()).toCql(), entities, options,
|
||||
cassandraConverter);
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.test.integration.template;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -42,7 +46,6 @@ import com.datastax.driver.core.querybuilder.Select;
|
||||
* Unit Tests for CqlTemplate
|
||||
*
|
||||
* @author David Webb
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@@ -163,6 +166,19 @@ public class CassandraDataOperationsTest extends AbstractSpringDataEmbeddedCassa
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertEmptyList() {
|
||||
List<Book> list = template.insert(new ArrayList<Book>());
|
||||
assertNotNull(list);
|
||||
assertEquals(0, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertNullList() {
|
||||
List<Book> list = template.insert((List<Book>) null);
|
||||
assertNull(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertBatchTest() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user