@Test
public void should_batch_native_statement_with_CAS_result_listener() throws Exception {
//Given
CompleteBean entity = CompleteBeanTestBuilder.builder().randomId().name("name1000").buid();
manager.insert(entity);
final Batch batch = manager.createBatch();
final Insert statement = insertInto("CompleteBean").value("id", bindMarker("id")).value("name", bindMarker("name")).ifNotExists();
final AtomicBoolean error = new AtomicBoolean(false);
final AtomicReference<CASResultListener.CASResult> result = new AtomicReference<>(null);
CASResultListener listener = new CASResultListener() {
@Override
public void onCASSuccess() {
}
@Override
public void onCASError(CASResult casResult) {
error.getAndSet(true);
result.getAndSet(casResult);
}
};
//When
batch.batchNativeStatementWithCASListener(statement,listener, entity.getId(),"name");
batch.endBatch();
//Then
assertThat(error.get()).isTrue();
assertThat(result.get()).isNotNull();