Example #1
0
 /** @throws Exception */
 @Test
 public void assignKeyIfNecessaryWhenParentExists() throws Exception {
   DatastoreUtil.allocateId(ds, "Child");
   Key dummyKey2 = DatastoreUtil.allocateId(ds, "Child");
   Key parentKey = DatastoreUtil.allocateId(ds, "Parent");
   Entity entity = new Entity("Child", parentKey);
   DatastoreUtil.assignKeyIfNecessary(ds, entity);
   assertThat(entity.getKey().getId(), is(not(dummyKey2.getId() + 1)));
 }
Example #2
0
 /** @throws Exception */
 @Test
 public void assignKeyIfNecessaryForEntities() throws Exception {
   Entity entity = new Entity("Hoge");
   DatastoreUtil.assignKeyIfNecessary(ds, Arrays.asList(entity));
   assertThat(entity.getKey().getId(), is(not(0L)));
 }