Greeting { public void save() { if (key == null) { key = getDatastore().allocateId(makeIncompleteKey()); } Builder<Key> builder = FullEntity.newBuilder(key); if (authorEmail != null) { builder.set("authorEmail", authorEmail); } if (authorId != null) { builder.set("authorId", authorId); } builder.set("content", content); builder.set("date", Timestamp.of(date)); getDatastore().put(builder.build()); } Greeting();  Greeting(String book, String content);  Greeting(String book, String content, String id, String email);  Greeting(Entity entity); void save(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); public Key key; public String authorEmail; public String authorId; public String content; public Date date; }
@Test public void testSaveGreeting() throws Exception { Greeting greeting = new Greeting(null, "Test!"); greeting.save(); Guestbook guestbook = new Guestbook(null); List<Greeting> greetings = guestbook.getGreetings(); assertTrue(greetings.size() == 1); assertEquals(greeting, greetings.get(0)); }