示例#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();
 }
示例#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));
 }
示例#3
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));
 }
示例#4
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();
 }
示例#5
0
 /** @throws Exception */
 @Test
 public void getAsMapAsync() throws Exception {
   Key key = ds.put(new Entity("Hoge")).get();
   Key key2 = ds.put(new Entity("Hoge", key)).get();
   Transaction tx = ds.beginTransaction().get();
   Map<Key, Entity> map = DatastoreUtil.getAsMapAsync(ds, tx, Arrays.asList(key, key2)).get();
   assertThat(map, is(notNullValue()));
   assertThat(map.size(), is(2));
 }
示例#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));
 }
示例#7
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"));
 }
示例#8
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()));
 }
示例#9
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()));
 }