@Test public void shouldThrowExceptionWhenProductCodeDoesNotExistWhenTryingToFetchProgramCodeById() throws Exception { when(mockedMapper.getIdByCode("code")).thenReturn(null); expectedEx.expect(DataException.class); expectedEx.expectMessage("product.code.invalid"); repository.getIdByCode("code"); }
public Long getIdByCode(String code) { Long productId = mapper.getIdByCode(code); if (productId == null) throw new DataException("product.code.invalid"); return productId; }
ProductRepository { public Long getIdByCode(String code) { Long productId = mapper.getIdByCode(code); if (productId == null) throw new DataException("product.code.invalid"); return productId; } }
ProductRepository { public Long getIdByCode(String code) { Long productId = mapper.getIdByCode(code); if (productId == null) throw new DataException("product.code.invalid"); return productId; }  }
ProductRepository { public Long getIdByCode(String code) { Long productId = mapper.getIdByCode(code); if (productId == null) throw new DataException("product.code.invalid"); return productId; }  void insert(Product product); void update(Product product); Long getIdByCode(String code); Product getByCode(String code); DosageUnit getDosageUnitByCode(String code); boolean isActive(String code); Integer getTotalSearchResultCount(String searchParam); List<DosageUnit> getAllDosageUnits(); Product getById(Long id); }
ProductRepository { public Long getIdByCode(String code) { Long productId = mapper.getIdByCode(code); if (productId == null) throw new DataException("product.code.invalid"); return productId; }  void insert(Product product); void update(Product product); Long getIdByCode(String code); Product getByCode(String code); DosageUnit getDosageUnitByCode(String code); boolean isActive(String code); Integer getTotalSearchResultCount(String searchParam); List<DosageUnit> getAllDosageUnits(); Product getById(Long id);  }