@Test public void shouldGetAll() { List<ProductCategory> categories = asList(new ProductCategory()); when(repository.getAll()).thenReturn(categories); List<ProductCategory> returnedCategories = service.getAll(); verify(repository).getAll(); assertThat(returnedCategories, is(categories)); }
public List<ProductCategory> getAll() { return repository.getAll(); }
ProductCategoryService { public List<ProductCategory> getAll() { return repository.getAll(); } }
ProductCategoryService { public List<ProductCategory> getAll() { return repository.getAll(); } @Autowired  ProductCategoryService(ProductCategoryRepository repository); }
ProductCategoryService { public List<ProductCategory> getAll() { return repository.getAll(); } @Autowired  ProductCategoryService(ProductCategoryRepository repository); Long getProductCategoryIdByCode(String code); ProductCategory getByCode(String code); void save(ProductCategory productCategory); ProductCategory getExisting(ProductCategory productCategory); ProductCategory getById(Long id); List<ProductCategory> getAll(); }
ProductCategoryService { public List<ProductCategory> getAll() { return repository.getAll(); } @Autowired  ProductCategoryService(ProductCategoryRepository repository); Long getProductCategoryIdByCode(String code); ProductCategory getByCode(String code); void save(ProductCategory productCategory); ProductCategory getExisting(ProductCategory productCategory); ProductCategory getById(Long id); List<ProductCategory> getAll();  }