use of com.google.appengine.api.datastore.DatastoreService in project google-oauth-java-client by googleapis.
the class AppEngineCredentialStore method migrateTo.
/**
* Migrates to the new format using {@link DataStore} of {@link StoredCredential}.
*
* @param credentialDataStore credential data store
* @since 1.16
*/
public final void migrateTo(DataStore<StoredCredential> credentialDataStore) throws IOException {
DatastoreService service = DatastoreServiceFactory.getDatastoreService();
PreparedQuery queryResult = service.prepare(new Query(KIND));
for (Entity entity : queryResult.asIterable()) {
StoredCredential storedCredential = new StoredCredential().setAccessToken((String) entity.getProperty("accessToken")).setRefreshToken((String) entity.getProperty("refreshToken")).setExpirationTimeMilliseconds((Long) entity.getProperty("expirationTimeMillis"));
credentialDataStore.set(entity.getKey().getName(), storedCredential);
}
}
use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class TaskQueueTest method testBulkAddImplicitTransactionEnlistment_TaskOptions.
@Test
public void testBulkAddImplicitTransactionEnlistment_TaskOptions() {
MockQueueBulkAddApiHelper helper = newBasicAddRequest();
com.google.apphosting.datastore.proto2api.DatastoreV3Pb.Transaction pbTxn = com.google.apphosting.datastore.proto2api.DatastoreV3Pb.Transaction.newBuilder().setHandle(44).setApp(APP).build();
helper.expectedRequest.getAddRequestBuilder(0).setTransaction(pbTxn);
Transaction txn = mock(Transaction.class);
when(txn.getId()).thenReturn("44");
when(txn.getApp()).thenReturn(APP);
DatastoreService ds = mock(DatastoreService.class);
when(ds.getCurrentTransaction(null)).thenReturn(txn);
Queue q = helper.getQueue(ds);
q.add(TaskOptions.Builder.withDefaults());
}
use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class TaskQueueTest method testBulkAddImplicitTransactionEnlistment_TaskOptions_ExplicitNullTxn.
@Test
public void testBulkAddImplicitTransactionEnlistment_TaskOptions_ExplicitNullTxn() {
MockQueueBulkAddApiHelper helper = newBasicAddRequest();
Transaction txn = mock(Transaction.class);
when(txn.getId()).thenReturn("44");
when(txn.getApp()).thenReturn(APP);
DatastoreService ds = mock(DatastoreService.class);
when(ds.getCurrentTransaction(null)).thenReturn(txn);
Queue q = helper.getQueue(ds);
q.add(null, TaskOptions.Builder.withDefaults());
}
use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class TaskQueueIntegrationTest method testBulkAddTransactionalVarArguments.
@Test
public void testBulkAddTransactionalVarArguments() throws Exception {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Transaction txn = datastore.beginTransaction();
List<TaskHandle> tasks = defaultQueue.add(txn, Arrays.asList(withTaskName(""), withTaskName(""), withTaskName("")));
txn.commit();
for (TaskHandle task : tasks) {
assertThat(task.getName()).startsWith("task");
assertThat(task.getQueueName()).isEqualTo(defaultQueue.getQueueName());
}
}
use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class TaskQueueIntegrationTest method testBulkAddTransactionalTaskNullTaskName.
@Test
public void testBulkAddTransactionalTaskNullTaskName() throws Exception {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Transaction txn = datastore.beginTransaction();
TaskHandle task = defaultQueue.add(txn, withDefaults());
txn.commit();
assertThat(task.getName()).startsWith("task");
assertThat(task.getQueueName()).isEqualTo(defaultQueue.getQueueName());
}
Aggregations