@Test public void shouldGetCategoryIdByCode() { String categoryCode = "category code"; Long categoryId = 1L; when(mapper.getIdByCode(categoryCode)).thenReturn(categoryId); Long returnedCategoryId = repository.getIdByCode(categoryCode); verify(mapper).getIdByCode(categoryCode); assertThat(returnedCategoryId, is(categoryId)); }
public Long getIdByCode(String categoryCode) { return mapper.getIdByCode(categoryCode); }
ProductCategoryRepository { public Long getIdByCode(String categoryCode) { return mapper.getIdByCode(categoryCode); } }
ProductCategoryRepository { public Long getIdByCode(String categoryCode) { return mapper.getIdByCode(categoryCode); } @Autowired  ProductCategoryRepository(ProductCategoryMapper mapper); }
ProductCategoryRepository { public Long getIdByCode(String categoryCode) { return mapper.getIdByCode(categoryCode); } @Autowired  ProductCategoryRepository(ProductCategoryMapper mapper); void insert(ProductCategory productCategory); void update(ProductCategory productCategory); ProductCategory getExisting(ProductCategory productCategory); Long getIdByCode(String categoryCode); ProductCategory getByCode(String code); List<ProductCategory> getAll(); ProductCategory getById(Long id); }
ProductCategoryRepository { public Long getIdByCode(String categoryCode) { return mapper.getIdByCode(categoryCode); } @Autowired  ProductCategoryRepository(ProductCategoryMapper mapper); void insert(ProductCategory productCategory); void update(ProductCategory productCategory); ProductCategory getExisting(ProductCategory productCategory); Long getIdByCode(String categoryCode); ProductCategory getByCode(String code); List<ProductCategory> getAll(); ProductCategory getById(Long id);  }