Search in sources :

Example 1 with DefaultInsert

use of com.datastax.oss.driver.internal.querybuilder.insert.DefaultInsert in project java-driver by datastax.

the class RegularInsertTest method should_throw_exception_with_invalid_timestamp.

@Test
public void should_throw_exception_with_invalid_timestamp() {
    DefaultInsert defaultInsert = (DefaultInsert) insertInto("foo").value("a", bindMarker()).usingTimestamp(1);
    Throwable t = catchThrowable(() -> new DefaultInsert(defaultInsert.getKeyspace(), defaultInsert.getTable(), (Term) defaultInsert.getJson(), defaultInsert.getMissingJsonBehavior(), defaultInsert.getAssignments(), // invalid timestamp object)
    new Object(), defaultInsert.getTtlInSeconds(), defaultInsert.isIfNotExists()));
    assertThat(t).isInstanceOf(IllegalArgumentException.class).hasMessage("TIMESTAMP value must be a BindMarker or a Long");
}
Also used : Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) Term(com.datastax.oss.driver.api.querybuilder.term.Term) DefaultInsert(com.datastax.oss.driver.internal.querybuilder.insert.DefaultInsert) Test(org.junit.Test)

Example 2 with DefaultInsert

use of com.datastax.oss.driver.internal.querybuilder.insert.DefaultInsert in project java-driver by datastax.

the class RegularInsertTest method should_throw_exception_with_invalid_ttl.

@Test
public void should_throw_exception_with_invalid_ttl() {
    DefaultInsert defaultInsert = (DefaultInsert) insertInto("foo").value("a", bindMarker()).usingTtl(10);
    Throwable t = catchThrowable(() -> new DefaultInsert(defaultInsert.getKeyspace(), defaultInsert.getTable(), (Term) defaultInsert.getJson(), defaultInsert.getMissingJsonBehavior(), defaultInsert.getAssignments(), defaultInsert.getTimestamp(), // invalid TTL object
    new Object(), defaultInsert.isIfNotExists()));
    assertThat(t).isInstanceOf(IllegalArgumentException.class).hasMessage("TTL value must be a BindMarker or an Integer");
}
Also used : Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) Term(com.datastax.oss.driver.api.querybuilder.term.Term) DefaultInsert(com.datastax.oss.driver.internal.querybuilder.insert.DefaultInsert) Test(org.junit.Test)

Aggregations

Term (com.datastax.oss.driver.api.querybuilder.term.Term)2 DefaultInsert (com.datastax.oss.driver.internal.querybuilder.insert.DefaultInsert)2 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)2 Test (org.junit.Test)2