@Test public void shouldSaveSupervisoryNode() throws Exception { SupervisoryNode supervisoryNode = make(a(SupervisoryNodeBuilder.defaultSupervisoryNode)); supervisoryNodeService.save(supervisoryNode); verify(supervisoryNodeRepository).insert(supervisoryNode); }
public void save(SupervisoryNode supervisoryNode) { supervisoryNode.getFacility().setId(facilityRepository.getIdForCode(supervisoryNode.getFacility().getCode())); validateParentNode(supervisoryNode); if (supervisoryNode.getId() == null) supervisoryNodeRepository.insert(supervisoryNode); else supervisoryNodeRepository.update(supervisoryNode); }
SupervisoryNodeService { public void save(SupervisoryNode supervisoryNode) { supervisoryNode.getFacility().setId(facilityRepository.getIdForCode(supervisoryNode.getFacility().getCode())); validateParentNode(supervisoryNode); if (supervisoryNode.getId() == null) supervisoryNodeRepository.insert(supervisoryNode); else supervisoryNodeRepository.update(supervisoryNode); } }
SupervisoryNodeService { public void save(SupervisoryNode supervisoryNode) { supervisoryNode.getFacility().setId(facilityRepository.getIdForCode(supervisoryNode.getFacility().getCode())); validateParentNode(supervisoryNode); if (supervisoryNode.getId() == null) supervisoryNodeRepository.insert(supervisoryNode); else supervisoryNodeRepository.update(supervisoryNode); }  }
SupervisoryNodeService { public void save(SupervisoryNode supervisoryNode) { supervisoryNode.getFacility().setId(facilityRepository.getIdForCode(supervisoryNode.getFacility().getCode())); validateParentNode(supervisoryNode); if (supervisoryNode.getId() == null) supervisoryNodeRepository.insert(supervisoryNode); else supervisoryNodeRepository.update(supervisoryNode); }  @Autowired void setPageSize(@Value("${search.page.size}") String pageSize); void save(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); SupervisoryNode getFor(Facility facility, Program program); User getApproverFor(Facility facility, Program program); SupervisoryNode getParent(Long id); User getApproverForGivenSupervisoryNodeAndProgram(SupervisoryNode supervisoryNode, Program program); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode supervisoryNode); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); Pagination getPagination(Integer page); Integer getTotalSearchResultCount(String param, Boolean parent); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId); }
SupervisoryNodeService { public void save(SupervisoryNode supervisoryNode) { supervisoryNode.getFacility().setId(facilityRepository.getIdForCode(supervisoryNode.getFacility().getCode())); validateParentNode(supervisoryNode); if (supervisoryNode.getId() == null) supervisoryNodeRepository.insert(supervisoryNode); else supervisoryNodeRepository.update(supervisoryNode); }  @Autowired void setPageSize(@Value("${search.page.size}") String pageSize); void save(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); SupervisoryNode getFor(Facility facility, Program program); User getApproverFor(Facility facility, Program program); SupervisoryNode getParent(Long id); User getApproverForGivenSupervisoryNodeAndProgram(SupervisoryNode supervisoryNode, Program program); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode supervisoryNode); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); Pagination getPagination(Integer page); Integer getTotalSearchResultCount(String param, Boolean parent); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId);  }