Search in sources :

Example 1 with PrimingRequest

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));
}
Also used : PortabilityJob(org.dataportabilityproject.spi.cloud.types.PortabilityJob) Map(java.util.Map) PreparedStatementExecution(org.scassandra.http.client.PreparedStatementExecution) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PrimingRequest(org.scassandra.http.client.PrimingRequest) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with PrimingRequest

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();
}
Also used : PrimingRequest(org.scassandra.http.client.PrimingRequest)

Aggregations

PrimingRequest (org.scassandra.http.client.PrimingRequest)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Map (java.util.Map)1 PortabilityJob (org.dataportabilityproject.spi.cloud.types.PortabilityJob)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 PreparedStatementExecution (org.scassandra.http.client.PreparedStatementExecution)1