use of com.datastax.oss.protocol.internal.request.Prepare in project java-driver by datastax.
the class ReprepareOnUpTest method should_not_reprepare_already_known_statements.
@Test
public void should_not_reprepare_already_known_statements() {
MockReprepareOnUp reprepareOnUp = new MockReprepareOnUp("test", pool, ImmediateEventExecutor.INSTANCE, getMockPayloads('a', 'b', 'c', 'd', 'e', 'f'), context, whenPrepared);
reprepareOnUp.start();
MockAdminQuery adminQuery = reprepareOnUp.queries.poll();
assertThat(adminQuery).isNotNull();
assertThat(adminQuery.request).isInstanceOf(Query.class);
assertThat(((Query) adminQuery.request).query).isEqualTo("SELECT prepared_id FROM system.prepared_statements");
// server knows d, e and f already:
adminQuery.resultFuture.complete(new AdminResult(preparedIdRows('d', 'e', 'f'), null, DefaultProtocolVersion.DEFAULT));
for (char c = 'a'; c <= 'c'; c++) {
adminQuery = reprepareOnUp.queries.poll();
assertThat(adminQuery).isNotNull();
assertThat(adminQuery.request).isInstanceOf(Prepare.class);
assertThat(((Prepare) adminQuery.request).cqlQuery).isEqualTo("mock query " + c);
adminQuery.resultFuture.complete(null);
}
assertThatStage(done).isSuccess(v -> assertThat(reprepareOnUp.queries).isEmpty());
}
Aggregations