Esempio 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();
 }
Esempio 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));
 }
Esempio 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));
 }
Esempio 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));
 }
Esempio 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();
 }
Esempio 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));
 }
Esempio 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));
 }
Esempio 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"));
 }
Esempio 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()));
 }
Esempio 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()));
 }