Restaurant implements Model, NameProtocol, AddressProtocol { public Collection<MenuItem> menu() { ModelCollectionQuery<MenuItem> query = ModelCollectionQuery.LogicalOperators.and( MenuItem.belongsToRestaurant(this), notDeleted(MenuItemAdded.class, MenuItemAdded.ID, MenuItem::lookup)); return MenuItem.query(getRepository(), query); } protected  Restaurant(Repository repository, UUID id); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static Optional<Restaurant> lookup(Repository repository, UUID id); static ModelCollectionQuery<Restaurant> within10km(Address address); static ModelCollectionQuery<Restaurant> openAt(Date date); static Collection<Restaurant> query(Repository repository, ModelCollectionQuery<Restaurant> query); Map<Integer, List<OpeningHours>> openingHours(); Collection<MenuItem> menu();  }
@Test @SneakyThrows public void menu() { Restaurant kyzock = repository.publish(kyzockRegistration()).get(); AddMenuItem addSpicyHamachiSashimi = new AddMenuItem(kyzock, "Spicy Hamachi Sashimi", "6 small diced cut Hamachi(Fresh Yellow Tail from Japan) sashimi w/ Spicy Sauce & Mix Greens", "image/jpeg", ByteStreams.toByteArray(getClass().getResourceAsStream("spicy_hamachi_sashimi.jpg")), new BigDecimal("8.95")); AddMenuItem addUniNigiri = new AddMenuItem(kyzock, "Uni Nigiri", null, "image/jpeg", ByteStreams.toByteArray(getClass().getResourceAsStream("uni.jpg")), new BigDecimal("3.80")); repository.publish(addSpicyHamachiSashimi).get(); MenuItem uniNigiri = repository.publish(addUniNigiri).get(); Collection<MenuItem> menu = kyzock.menu(); assertEquals(menu.size(), 2); repository.publish(new RemoveMenuItem(uniNigiri)).get(); menu = kyzock.menu(); assertEquals(menu.size(), 1); assertFalse(menu.stream().anyMatch(item -> item.name().contentEquals(uniNigiri.name()))); }