use of com.google.cloud.datastore.Key in project google-cloud-java by GoogleCloudPlatform.
the class ITDatastoreSnippets method addEntity.
private void addEntity(String keyName, String keyClass, String property, String value) {
Key key = datastore.newKeyFactory().setKind(keyClass).newKey(keyName);
Entity.Builder entityBuilder = Entity.newBuilder(key);
entityBuilder.set(property, value);
Entity entity = entityBuilder.build();
datastore.put(entity);
}
use of com.google.cloud.datastore.Key in project google-cloud-java by GoogleCloudPlatform.
the class ITDatastoreSnippets method registerKey.
private String registerKey(String keyName, String kind) {
Key key = datastore.newKeyFactory().setKind(kind).newKey(keyName);
registeredKeys.add(key);
return key.getName();
}
use of com.google.cloud.datastore.Key in project google-cloud-java by GoogleCloudPlatform.
the class ITTransactionSnippets method testIsActive.
@Test
public void testIsActive() {
Transaction transaction = datastore.newTransaction();
TransactionSnippets transactionSnippets = new TransactionSnippets(transaction);
Key key = transactionSnippets.isActive();
Entity result = datastore.get(key);
assertNotNull(result);
datastore.delete(key);
}
use of com.google.cloud.datastore.Key in project google-cloud-java by GoogleCloudPlatform.
the class ITTransactionSnippets method testCommit.
@Test
public void testCommit() {
Transaction transaction = datastore.newTransaction();
TransactionSnippets transactionSnippets = new TransactionSnippets(transaction);
Key key = transactionSnippets.commit();
Entity result = datastore.get(key);
assertNotNull(result);
datastore.delete(key);
}
use of com.google.cloud.datastore.Key in project google-cloud-java by GoogleCloudPlatform.
the class ITTransactionSnippets method testActive.
@Test
public void testActive() {
Transaction transaction = datastore.newTransaction();
TransactionSnippets transactionSnippets = new TransactionSnippets(transaction);
Key key = transactionSnippets.active();
Entity result = datastore.get(key);
assertNotNull(result);
datastore.delete(key);
}
Aggregations