Search in sources :

Example 1 with DefaultUpdate

use of com.datastax.oss.driver.internal.querybuilder.update.DefaultUpdate in project java-driver by datastax.

the class UpdateUsingTest method should_throw_exception_with_invalid_timestamp.

@Test
public void should_throw_exception_with_invalid_timestamp() {
    DefaultUpdate defaultUpdate = (DefaultUpdate) update("foo").usingTtl(10).setColumn("v", bindMarker()).whereColumn("k").isEqualTo(bindMarker());
    Throwable t = catchThrowable(() -> new DefaultUpdate(defaultUpdate.getKeyspace(), defaultUpdate.getTable(), // invalid timestamp object
    new Object(), defaultUpdate.getTtl(), defaultUpdate.getAssignments(), defaultUpdate.getRelations(), defaultUpdate.isIfExists(), defaultUpdate.getConditions()));
    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) DefaultUpdate(com.datastax.oss.driver.internal.querybuilder.update.DefaultUpdate) Test(org.junit.Test)

Example 2 with DefaultUpdate

use of com.datastax.oss.driver.internal.querybuilder.update.DefaultUpdate in project java-driver by datastax.

the class UpdateUsingTest method should_throw_exception_with_invalid_ttl.

@Test
public void should_throw_exception_with_invalid_ttl() {
    DefaultUpdate defaultUpdate = (DefaultUpdate) update("foo").usingTtl(10).setColumn("v", bindMarker()).whereColumn("k").isEqualTo(bindMarker());
    Throwable t = catchThrowable(() -> new DefaultUpdate(defaultUpdate.getKeyspace(), defaultUpdate.getTable(), defaultUpdate.getTimestamp(), // invalid TTL object
    new Object(), defaultUpdate.getAssignments(), defaultUpdate.getRelations(), defaultUpdate.isIfExists(), defaultUpdate.getConditions()));
    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) DefaultUpdate(com.datastax.oss.driver.internal.querybuilder.update.DefaultUpdate) Test(org.junit.Test)

Aggregations

DefaultUpdate (com.datastax.oss.driver.internal.querybuilder.update.DefaultUpdate)2 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)2 Test (org.junit.Test)2