@Test public void findByUserNameShouldBeCaseInsensitive() { String userName = "******"; allMotechUsers.add( new MotechUserCouchdbImpl(userName, "testpassword", "", "id", asList("ADMIN"), "")); assertNotNull(allMotechUsers.findByUserName("TESTUSER")); }
@Test public void findByUserName() { MotechUser motechUser = new MotechUserCouchdbImpl("testuser", "testpassword", "", "id", asList("ADMIN"), ""); allMotechUsers.add(motechUser); MotechUser testUser = allMotechUsers.findByUserName("testuser"); assertEquals("testuser", testUser.getUserName()); }
@Test public void shouldNotCreateNewAccountIfUserAlreadyExists() { String userName = "******"; allMotechUsers.add( new MotechUserCouchdbImpl(userName, "testpassword", "", "id", asList("ADMIN"), "")); allMotechUsers.add( new MotechUserCouchdbImpl(userName, "testpassword1", "", "id2", asList("ADMIN"), "")); MotechUser motechUser = allMotechUsers.findByUserName("userName"); final List<MotechUserCouchdbImpl> allWebUsers = ((AllMotechUsersCouchdbImpl) allMotechUsers).getAll(); final int numberOfUsersWithSameUserName = Lambda.select(allWebUsers, HasPropertyWithValue.hasProperty("userName", equalTo(userName))) .size(); assertEquals(1, numberOfUsersWithSameUserName); assertEquals("testpassword", motechUser.getPassword()); assertEquals("id", motechUser.getExternalId()); }
@Test public void findByUseridShouldReturnNullIfuserNameIsNull() { assertNull(null, allMotechUsers.findByUserName(null)); }