Example #1
0
 /** @throws Exception */
 @Test
 public void refereceToKeyForName() throws Exception {
   Key key = KeyFactory.createKey("Hoge", "aaa");
   Reference reference = new Reference();
   Path path = new Path();
   reference.setPath(path);
   Element element = path.addElement();
   element.setType("Hoge");
   element.setName("aaa");
   assertThat(DatastoreUtil.referenceToKey(reference), is(key));
 }
Example #2
0
 /** @throws Exception */
 @Test
 public void refereceToKeyForParent() throws Exception {
   Key parentKey = KeyFactory.createKey("Parent", 1);
   Key childKey = KeyFactory.createKey(parentKey, "Child", 1);
   Reference reference = new Reference();
   Path path = new Path();
   reference.setPath(path);
   Element element = path.addElement();
   element.setType("Parent");
   element.setId(1);
   element = path.addElement();
   element.setType("Child");
   element.setId(1);
   assertThat(DatastoreUtil.referenceToKey(reference), is(childKey));
 }