/** @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(); }
/** @throws Exception */ @Test public void putAsyncNoTx() throws Exception { Entity entity = new Entity(KeyFactory.createKey("Hoge", 1)); Entity entity2 = new Entity(KeyFactory.createKey(entity.getKey(), "Hoge", 1)); List<Key> keys = DatastoreUtil.putAsync(ds, null, Arrays.asList(entity, entity2)).get(); assertThat(keys, is(notNullValue())); assertThat(keys.size(), is(2)); assertThat(tester.count("Hoge"), is(2)); }
/** @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)); }