use of org.scassandra.http.client.PrimingRequest in project data-transfer-project by google.
the class CosmosStoreTest method verifyCreateAndFind.
@Test
@Ignore
public void verifyCreateAndFind() throws Exception {
PrimingRequest.Then.ThenBuilder thenInsert = PrimingRequest.then();
thenInsert.withVariableTypes(UUID, VARCHAR);
PrimingRequest createRequest = PrimingRequest.preparedStatementBuilder().withQuery(JOB_INSERT).withThen(thenInsert).build();
cassandra.primingClient().prime(createRequest);
PortabilityJob primeJob = PortabilityJob.builder().build();
java.util.UUID jobId = java.util.UUID.randomUUID();
Map row = Collections.singletonMap("job_data", new ObjectMapper().writeValueAsString(primeJob));
PrimingRequest.Then.ThenBuilder thenQuery = PrimingRequest.then();
PrimingRequest findRequest = PrimingRequest.preparedStatementBuilder().withQuery(JOB_QUERY).withThen(thenQuery.withVariableTypes(UUID).withColumnTypes(ColumnMetadata.column("job_id", UUID)).withRows(row)).build();
cassandra.primingClient().prime(findRequest);
PrimingRequest.Then.ThenBuilder thenUpdate = PrimingRequest.then();
thenUpdate.withVariableTypes(VARCHAR, UUID).withColumnTypes(ColumnMetadata.column("job_data", VARCHAR), ColumnMetadata.column("job_id", UUID));
PrimingRequest updateRequest = PrimingRequest.preparedStatementBuilder().withQuery(JOB_UPDATE).withThen(thenUpdate).build();
cassandra.primingClient().prime(updateRequest);
PrimingRequest.Then.ThenBuilder thenRemove = PrimingRequest.then();
thenRemove.withVariableTypes(UUID);
PrimingRequest removeRequest = PrimingRequest.preparedStatementBuilder().withQuery(JOB_DELETE).withThen(thenRemove).build();
cassandra.primingClient().prime(removeRequest);
PortabilityJob createJob = PortabilityJob.builder().build();
cosmosStore.createJob(jobId, createJob);
PortabilityJob copy = cosmosStore.findJob(jobId).toBuilder().setState(PortabilityJob.State.COMPLETE).build();
cosmosStore.updateJob(jobId, copy);
cosmosStore.remove(jobId);
PreparedStatementExecution expectedStatement = PreparedStatementExecution.builder().withPreparedStatementText(JOB_DELETE).withConsistency("LOCAL_ONE").build();
Assert.assertThat(cassandra.activityClient().retrievePreparedStatementExecutions(), preparedStatementRecorded(expectedStatement));
}
use of org.scassandra.http.client.PrimingRequest in project java-driver by datastax.
the class HostConnectionPoolTest method generateJava349InsertStatement.
private String generateJava349InsertStatement() {
StringBuilder sb = new StringBuilder("INSERT INTO Java349 (mykey");
for (int i = 0; i < 1000; i++) {
sb.append(", column").append(i);
}
sb.append(") VALUES (?");
for (int i = 0; i < 1000; i++) {
sb.append(", ").append(i);
}
sb.append(");");
PrimingRequest preparedStatementPrime = PrimingRequest.preparedStatementBuilder().withQuery(sb.toString()).withThen(then().withVariableTypes(PrimitiveType.INT)).build();
primingClient.prime(preparedStatementPrime);
return sb.toString();
}
Aggregations