@Test public void findByUserNameShouldBeCaseInsensitive() { when(usersDataService.findByUserName("testuser")).thenReturn(null); motechUsersDao.findByUserName("TeStUsEr"); verify(usersDataService).findByUserName("testuser"); }
@Transactional public MotechUser findByUserName(String userName) { MotechUser retrievedUser = null; if (userName != null) { retrievedUser = dataService.findByUserName(userName.toLowerCase()); if (retrievedUser != null && retrievedUser.getRoles() == null) { retrievedUser.setRoles((List<String>) dataService.getDetachedField(retrievedUser, "roles")); } } return retrievedUser; }
MotechUsersDao { @Transactional public MotechUser findByUserName(String userName) { MotechUser retrievedUser = null; if (userName != null) { retrievedUser = dataService.findByUserName(userName.toLowerCase()); if (retrievedUser != null && retrievedUser.getRoles() == null) { retrievedUser.setRoles((List<String>) dataService.getDetachedField(retrievedUser, "roles")); } } return retrievedUser; } }
MotechUsersDao { @Transactional public MotechUser findByUserName(String userName) { MotechUser retrievedUser = null; if (userName != null) { retrievedUser = dataService.findByUserName(userName.toLowerCase()); if (retrievedUser != null && retrievedUser.getRoles() == null) { retrievedUser.setRoles((List<String>) dataService.getDetachedField(retrievedUser, "roles")); } } return retrievedUser; }  }
MotechUsersDao { @Transactional public MotechUser findByUserName(String userName) { MotechUser retrievedUser = null; if (userName != null) { retrievedUser = dataService.findByUserName(userName.toLowerCase()); if (retrievedUser != null && retrievedUser.getRoles() == null) { retrievedUser.setRoles((List<String>) dataService.getDetachedField(retrievedUser, "roles")); } } return retrievedUser; }  @Transactional MotechUser findByUserName(String userName); @Transactional MotechUser findUserByOpenId(String openId); @Transactional MotechUser findUserByEmail(String email); @Transactional List<MotechUser> findByRole(String role); @Transactional void add(MotechUser user); @Transactional void addOpenIdUser(MotechUser user); @Transactional void update(MotechUser motechUser); @Transactional void remove(MotechUser motechUser); @Transactional List<MotechUser> getUsers(); @Transactional List<MotechUser> getOpenIdUsers(); @Autowired void setDataService(MotechUsersDataService dataService); }
MotechUsersDao { @Transactional public MotechUser findByUserName(String userName) { MotechUser retrievedUser = null; if (userName != null) { retrievedUser = dataService.findByUserName(userName.toLowerCase()); if (retrievedUser != null && retrievedUser.getRoles() == null) { retrievedUser.setRoles((List<String>) dataService.getDetachedField(retrievedUser, "roles")); } } return retrievedUser; }  @Transactional MotechUser findByUserName(String userName); @Transactional MotechUser findUserByOpenId(String openId); @Transactional MotechUser findUserByEmail(String email); @Transactional List<MotechUser> findByRole(String role); @Transactional void add(MotechUser user); @Transactional void addOpenIdUser(MotechUser user); @Transactional void update(MotechUser motechUser); @Transactional void remove(MotechUser motechUser); @Transactional List<MotechUser> getUsers(); @Transactional List<MotechUser> getOpenIdUsers(); @Autowired void setDataService(MotechUsersDataService dataService);  }