@Test public void shouldThrowIfDuplicateCodeInserted(){ SupervisoryNode supervisoryNode = new SupervisoryNode(); doThrow(new DuplicateKeyException("error_message")).when(supervisoryNodeMapper).insert(supervisoryNode); expectedEx.expect(DataException.class); expectedEx.expectMessage("error.duplicate.code.supervisory.node"); repository.insert(supervisoryNode); }
public void insert(SupervisoryNode supervisoryNode) { try { supervisoryNodeMapper.insert(supervisoryNode); } catch (DuplicateKeyException ex) { throw new DataException("error.duplicate.code.supervisory.node"); } }
SupervisoryNodeRepository { public void insert(SupervisoryNode supervisoryNode) { try { supervisoryNodeMapper.insert(supervisoryNode); } catch (DuplicateKeyException ex) { throw new DataException("error.duplicate.code.supervisory.node"); } } }
SupervisoryNodeRepository { public void insert(SupervisoryNode supervisoryNode) { try { supervisoryNodeMapper.insert(supervisoryNode); } catch (DuplicateKeyException ex) { throw new DataException("error.duplicate.code.supervisory.node"); } } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); }
SupervisoryNodeRepository { public void insert(SupervisoryNode supervisoryNode) { try { supervisoryNodeMapper.insert(supervisoryNode); } catch (DuplicateKeyException ex) { throw new DataException("error.duplicate.code.supervisory.node"); } } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); void insert(SupervisoryNode supervisoryNode); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); Long getIdForCode(String code); Long getSupervisoryNodeParentId(Long supervisoryNodeId); SupervisoryNode getFor(Facility facility, Program program); SupervisoryNode getParent(Long id); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode node); List<SupervisoryNode> getAllChildSupervisoryNodesInHierarchy(SupervisoryNode node); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); void update(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesByParent(Pagination pagination, String nameSearchCriteria); List<SupervisoryNode> getSupervisoryNodesBy(Pagination pagination, String nameSearchCriteria); Integer getTotalSearchResultCount(String param); Integer getTotalParentSearchResultCount(String param); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId); }
SupervisoryNodeRepository { public void insert(SupervisoryNode supervisoryNode) { try { supervisoryNodeMapper.insert(supervisoryNode); } catch (DuplicateKeyException ex) { throw new DataException("error.duplicate.code.supervisory.node"); } } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); void insert(SupervisoryNode supervisoryNode); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); Long getIdForCode(String code); Long getSupervisoryNodeParentId(Long supervisoryNodeId); SupervisoryNode getFor(Facility facility, Program program); SupervisoryNode getParent(Long id); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode node); List<SupervisoryNode> getAllChildSupervisoryNodesInHierarchy(SupervisoryNode node); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); void update(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesByParent(Pagination pagination, String nameSearchCriteria); List<SupervisoryNode> getSupervisoryNodesBy(Pagination pagination, String nameSearchCriteria); Integer getTotalSearchResultCount(String param); Integer getTotalParentSearchResultCount(String param); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId);  }