@Test public void addDoctorWithExistTCKN() throws Exception { final DoctorDaoResult daoResult = createDaoResult(false, DoctorManagerError.TCKN_HAS_EXIST); setDaoReturnForAdd(daoResult); final DoctorManagerResult result = manager.add(doctor); assertFalse(result.isSuccess()); assertTrue(result.getErrors().contains( DoctorManagerError.TCKN_HAS_EXIST)); verifyDao(); }
@Transactional @RolesAllowed(Role.ROLE_ADMIN) public DoctorManagerResult add(final Doctor doctor) { final DoctorManagerResult result = new DoctorManagerResult(); final DoctorDaoResult daoResult = doctorDao.add(doctor); if (!daoResult.isSuccess()) { LOGGER.info("The new doctor cannot be added"); result.addError(daoResult.getError()); result.setSuccess(false); } else { LOGGER.info("The new doctor {} is added", doctor.getFullname()); result.setSuccess(true); } return result; }
DoctorManagerImpl implements DoctorManager { @Transactional @RolesAllowed(Role.ROLE_ADMIN) public DoctorManagerResult add(final Doctor doctor) { final DoctorManagerResult result = new DoctorManagerResult(); final DoctorDaoResult daoResult = doctorDao.add(doctor); if (!daoResult.isSuccess()) { LOGGER.info("The new doctor cannot be added"); result.addError(daoResult.getError()); result.setSuccess(false); } else { LOGGER.info("The new doctor {} is added", doctor.getFullname()); result.setSuccess(true); } return result; } }
DoctorManagerImpl implements DoctorManager { @Transactional @RolesAllowed(Role.ROLE_ADMIN) public DoctorManagerResult add(final Doctor doctor) { final DoctorManagerResult result = new DoctorManagerResult(); final DoctorDaoResult daoResult = doctorDao.add(doctor); if (!daoResult.isSuccess()) { LOGGER.info("The new doctor cannot be added"); result.addError(daoResult.getError()); result.setSuccess(false); } else { LOGGER.info("The new doctor {} is added", doctor.getFullname()); result.setSuccess(true); } return result; }  }
DoctorManagerImpl implements DoctorManager { @Transactional @RolesAllowed(Role.ROLE_ADMIN) public DoctorManagerResult add(final Doctor doctor) { final DoctorManagerResult result = new DoctorManagerResult(); final DoctorDaoResult daoResult = doctorDao.add(doctor); if (!daoResult.isSuccess()) { LOGGER.info("The new doctor cannot be added"); result.addError(daoResult.getError()); result.setSuccess(false); } else { LOGGER.info("The new doctor {} is added", doctor.getFullname()); result.setSuccess(true); } return result; }  @Transactional @RolesAllowed(Role.ROLE_ADMIN) DoctorManagerResult add(final Doctor doctor); void setDoctorDao(final DoctorDao doctorDao); @Transactional DoctorManagerResult getByTckn(final Long tckn); @Transactional @RolesAllowed(Role.ROLE_ADMIN) DoctorManagerResult search(final DoctorBrowseModel model); @Transactional DoctorManagerResult getById(final Long id); @Transactional @RolesAllowed({ Role.ROLE_ADMIN, Role.ROLE_DOCTOR }) DoctorManagerResult update(final Doctor doctor); @Transactional @RolesAllowed(Role.ROLE_ADMIN) DoctorManagerResult delete(final Doctor doctor); @Transactional DoctorManagerResult getByApi(final String apiKey); }
DoctorManagerImpl implements DoctorManager { @Transactional @RolesAllowed(Role.ROLE_ADMIN) public DoctorManagerResult add(final Doctor doctor) { final DoctorManagerResult result = new DoctorManagerResult(); final DoctorDaoResult daoResult = doctorDao.add(doctor); if (!daoResult.isSuccess()) { LOGGER.info("The new doctor cannot be added"); result.addError(daoResult.getError()); result.setSuccess(false); } else { LOGGER.info("The new doctor {} is added", doctor.getFullname()); result.setSuccess(true); } return result; }  @Transactional @RolesAllowed(Role.ROLE_ADMIN) DoctorManagerResult add(final Doctor doctor); void setDoctorDao(final DoctorDao doctorDao); @Transactional DoctorManagerResult getByTckn(final Long tckn); @Transactional @RolesAllowed(Role.ROLE_ADMIN) DoctorManagerResult search(final DoctorBrowseModel model); @Transactional DoctorManagerResult getById(final Long id); @Transactional @RolesAllowed({ Role.ROLE_ADMIN, Role.ROLE_DOCTOR }) DoctorManagerResult update(final Doctor doctor); @Transactional @RolesAllowed(Role.ROLE_ADMIN) DoctorManagerResult delete(final Doctor doctor); @Transactional DoctorManagerResult getByApi(final String apiKey);  }