From 687e497455b368de05bae820d4656e38b65c3f6d Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Sun, 10 Aug 2014 11:36:02 -0400 Subject: [PATCH] test searchForUserByAttributes --- .../testsuite/model/UserModelTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java index 0af4d93045..d01dc7f610 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java @@ -9,6 +9,9 @@ import org.keycloak.models.UserModel; import org.keycloak.models.UserModel.RequiredAction; import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Stian Thorgersen @@ -35,6 +38,25 @@ public class UserModelTest extends AbstractModelTest { searchRealm = realmManager.getRealm(realm.getId()); UserModel persisted2 = session.users().getUserById(user.getId(), searchRealm); assertEquals(user, persisted2); + + Map attributes = new HashMap(); + attributes.put(UserModel.LAST_NAME, "last-name"); + List search = session.users().searchForUserByAttributes(attributes, realm); + Assert.assertEquals(search.size(), 1); + Assert.assertEquals(search.get(0).getUsername(), "user"); + + attributes.clear(); + attributes.put(UserModel.EMAIL, "email"); + search = session.users().searchForUserByAttributes(attributes, realm); + Assert.assertEquals(search.size(), 1); + Assert.assertEquals(search.get(0).getUsername(), "user"); + + attributes.clear(); + attributes.put(UserModel.LAST_NAME, "last-name"); + attributes.put(UserModel.EMAIL, "email"); + search = session.users().searchForUserByAttributes(attributes, realm); + Assert.assertEquals(search.size(), 1); + Assert.assertEquals(search.get(0).getUsername(), "user"); } @Test