@Test public void shouldUpdateExistingRequisitionGroup() { SupervisoryNode supervisoryNode = make(a(defaultSupervisoryNode)); RequisitionGroup requisitionGroup = make(a(defaultRequisitionGroup)); requisitionGroup.setId(1L); requisitionGroup.setSupervisoryNode(supervisoryNode); requisitionGroupService.save(requisitionGroup); verify(supervisoryNodeRepository).getIdForCode(supervisoryNode.getCode()); verify(requisitionGroupRepository).update(requisitionGroup); }
public void save(RequisitionGroup requisitionGroup) { Long supervisoryNodeId = supervisoryNodeRepository.getIdForCode(requisitionGroup.getSupervisoryNode().getCode()); requisitionGroup.getSupervisoryNode().setId(supervisoryNodeId); if (requisitionGroup.getId() == null) requisitionGroupRepository.insert(requisitionGroup); else requisitionGroupRepository.update(requisitionGroup); }
RequisitionGroupService { public void save(RequisitionGroup requisitionGroup) { Long supervisoryNodeId = supervisoryNodeRepository.getIdForCode(requisitionGroup.getSupervisoryNode().getCode()); requisitionGroup.getSupervisoryNode().setId(supervisoryNodeId); if (requisitionGroup.getId() == null) requisitionGroupRepository.insert(requisitionGroup); else requisitionGroupRepository.update(requisitionGroup); } }
RequisitionGroupService { public void save(RequisitionGroup requisitionGroup) { Long supervisoryNodeId = supervisoryNodeRepository.getIdForCode(requisitionGroup.getSupervisoryNode().getCode()); requisitionGroup.getSupervisoryNode().setId(supervisoryNodeId); if (requisitionGroup.getId() == null) requisitionGroupRepository.insert(requisitionGroup); else requisitionGroupRepository.update(requisitionGroup); }  }
RequisitionGroupService { public void save(RequisitionGroup requisitionGroup) { Long supervisoryNodeId = supervisoryNodeRepository.getIdForCode(requisitionGroup.getSupervisoryNode().getCode()); requisitionGroup.getSupervisoryNode().setId(supervisoryNodeId); if (requisitionGroup.getId() == null) requisitionGroupRepository.insert(requisitionGroup); else requisitionGroupRepository.update(requisitionGroup); }  @Transactional void saveWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                          List<RequisitionGroupMember> requisitionGroupMembers,
                                          List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                          Long userId); void save(RequisitionGroup requisitionGroup); void saveRequisitionGroupMembers(List<RequisitionGroupMember> requisitionGroupMembers,
                                          RequisitionGroup requisitionGroup,
                                          Long userId); List<RequisitionGroup> getRequisitionGroupsBy(List<SupervisoryNode> supervisoryNodes); RequisitionGroup getByCode(RequisitionGroup requisitionGroup); List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination); Integer getTotalRecords(String searchParam, String columnName); RequisitionGroup getBy(Long id); List<RequisitionGroupMember> getMembersBy(Long requisitionGroupId); void updateWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                            List<RequisitionGroupMember> requisitionGroupMembers,
                                            List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                            Long userId); void saveRequisitionGroupProgramSchedules(List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                                   RequisitionGroup requisitionGroup,
                                                   Long userId); }
RequisitionGroupService { public void save(RequisitionGroup requisitionGroup) { Long supervisoryNodeId = supervisoryNodeRepository.getIdForCode(requisitionGroup.getSupervisoryNode().getCode()); requisitionGroup.getSupervisoryNode().setId(supervisoryNodeId); if (requisitionGroup.getId() == null) requisitionGroupRepository.insert(requisitionGroup); else requisitionGroupRepository.update(requisitionGroup); }  @Transactional void saveWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                          List<RequisitionGroupMember> requisitionGroupMembers,
                                          List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                          Long userId); void save(RequisitionGroup requisitionGroup); void saveRequisitionGroupMembers(List<RequisitionGroupMember> requisitionGroupMembers,
                                          RequisitionGroup requisitionGroup,
                                          Long userId); List<RequisitionGroup> getRequisitionGroupsBy(List<SupervisoryNode> supervisoryNodes); RequisitionGroup getByCode(RequisitionGroup requisitionGroup); List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination); Integer getTotalRecords(String searchParam, String columnName); RequisitionGroup getBy(Long id); List<RequisitionGroupMember> getMembersBy(Long requisitionGroupId); void updateWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                            List<RequisitionGroupMember> requisitionGroupMembers,
                                            List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                            Long userId); void saveRequisitionGroupProgramSchedules(List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                                   RequisitionGroup requisitionGroup,
                                                   Long userId); static final String REQUISITION_GROUP; }