@Test public void fetchShouldFindInDatabase() { UUID id = UUID.randomUUID(); TestItem item = new TestItem(); when(db.find(TestItem.class, id)).thenReturn(item); assertThat(service.fetchById(id)).isEqualTo(item); }
public T fetchById(UUID id) { T item = db.find(type, id); if (item == null) { throw new NotFoundException(id); } return item; }
CrudService { public T fetchById(UUID id) { T item = db.find(type, id); if (item == null) { throw new NotFoundException(id); } return item; } }
CrudService { public T fetchById(UUID id) { T item = db.find(type, id); if (item == null) { throw new NotFoundException(id); } return item; } @Inject  CrudService(Class<T> type, EbeanServer db); }
CrudService { public T fetchById(UUID id) { T item = db.find(type, id); if (item == null) { throw new NotFoundException(id); } return item; } @Inject  CrudService(Class<T> type, EbeanServer db); T fetchById(UUID id); List<T> fetchByFilter(ListFiltering filter); T create(T item); T update(UUID id, T item); void delete(UUID id); }
CrudService { public T fetchById(UUID id) { T item = db.find(type, id); if (item == null) { throw new NotFoundException(id); } return item; } @Inject  CrudService(Class<T> type, EbeanServer db); T fetchById(UUID id); List<T> fetchByFilter(ListFiltering filter); T create(T item); T update(UUID id, T item); void delete(UUID id);  }