Ejemplo n.º 1
0
 /** @throws Exception */
 @Test(expected = IllegalStateException.class)
 public void deleteAsyncIllegalTx() throws Exception {
   Key key = ds.put(new Entity("Hoge")).get();
   Transaction tx = ds.beginTransaction().get();
   tx.rollback();
   DatastoreUtil.deleteAsync(ds, tx, Arrays.asList(key)).get();
 }
Ejemplo n.º 2
0
 /** @throws Exception */
 @Test
 public void deleteAsync() throws Exception {
   Key key = ds.put(new Entity("Hoge")).get();
   Transaction tx = ds.beginTransaction().get();
   DatastoreUtil.deleteAsync(ds, tx, Arrays.asList(key)).get();
   tx.rollback();
   assertThat(tester.count("Hoge"), is(1));
 }
Ejemplo n.º 3
0
 /** @throws Exception */
 @Test
 public void getAsMapAsyncNoTx() throws Exception {
   Key key = ds.put(new Entity("Hoge")).get();
   Key key2 = ds.put(new Entity("Hoge", key)).get();
   Map<Key, Entity> map = DatastoreUtil.getAsMapAsync(ds, null, Arrays.asList(key, key2)).get();
   assertThat(map, is(notNullValue()));
   assertThat(map.size(), is(2));
 }
Ejemplo n.º 4
0
 /** @throws Exception */
 @Test(expected = IllegalStateException.class)
 public void getAsMapAsyncTxIsIllegal() throws Exception {
   Key key = ds.put(new Entity("Hoge")).get();
   Key key2 = ds.put(new Entity("Hoge", key)).get();
   Transaction tx = ds.beginTransaction().get();
   tx.rollback();
   DatastoreUtil.getAsMapAsync(ds, tx, Arrays.asList(key, key2));
 }
Ejemplo n.º 5
0
 /** @throws Exception */
 @Test(expected = IllegalStateException.class)
 public void putAsyncIllegalTx() throws Exception {
   Entity entity = new Entity(KeyFactory.createKey("Hoge", 1));
   Entity entity2 = new Entity(KeyFactory.createKey(entity.getKey(), "Hoge", 1));
   Transaction tx = ds.beginTransaction().get();
   tx.rollback();
   DatastoreUtil.putAsync(ds, tx, Arrays.asList(entity, entity2)).get();
 }
Ejemplo n.º 6
0
 /** @throws Exception */
 @Test
 public void putAsync() throws Exception {
   Entity entity = new Entity(KeyFactory.createKey("Hoge", 1));
   Entity entity2 = new Entity(KeyFactory.createKey(entity.getKey(), "Hoge", 1));
   Transaction tx = ds.beginTransaction().get();
   List<Key> keys = DatastoreUtil.putAsync(ds, tx, Arrays.asList(entity, entity2)).get();
   tx.rollback();
   assertThat(keys, is(notNullValue()));
   assertThat(keys.size(), is(2));
   assertThat(tester.count("Hoge"), is(0));
 }
Ejemplo n.º 7
0
 /** @throws Exception */
 @Test
 public void deleteAsyncNoTx() throws Exception {
   Key key = ds.put(new Entity("Hoge")).get();
   DatastoreUtil.deleteAsync(ds, null, Arrays.asList(key)).get();
   assertThat(tester.count("Hoge"), is(0));
 }
Ejemplo n.º 8
0
 /** @throws Exception */
 @Test(expected = EntityNotFoundRuntimeException.class)
 public void getNoEntityIsFound() throws Exception {
   Transaction tx = ds.beginTransaction().get();
   DatastoreUtil.get(ds, tx, KeyFactory.createKey("Hoge", "xxx"));
 }
Ejemplo n.º 9
0
 /** @throws Exception */
 @Test
 public void get() throws Exception {
   Key key = ds.put(new Entity("Hoge")).get();
   Transaction tx = ds.beginTransaction().get();
   assertThat(DatastoreUtil.get(ds, tx, key), is(notNullValue()));
 }
Ejemplo n.º 10
0
 /** @throws Exception */
 @Test
 public void getOrNullNoEntityIsFound() throws Exception {
   Transaction tx = ds.beginTransaction().get();
   assertThat(
       DatastoreUtil.getOrNull(ds, tx, KeyFactory.createKey("Hoge", "xxx")), is(nullValue()));
 }