use of org.sonar.db.user.UserGroupDto in project sonarqube by SonarSource.
the class SearchActionTest method search_json_example.
@Test
public void search_json_example() throws Exception {
UserDto fmallet = db.users().insertUser(newUserDto("fmallet", "Freddy Mallet", "f@m.com").setActive(true).setLocal(true).setScmAccounts(emptyList()));
UserDto simon = db.users().insertUser(newUserDto("sbrandhof", "Simon", "s.brandhof@company.tld").setActive(true).setLocal(false).setExternalIdentity("sbrandhof@ldap.com").setExternalIdentityProvider("LDAP").setScmAccounts(newArrayList("simon.brandhof", "s.brandhof@company.tld")));
GroupDto sonarUsers = db.users().insertGroup(newGroupDto().setName("sonar-users"));
GroupDto sonarAdministrators = db.users().insertGroup(newGroupDto().setName("sonar-administrators"));
dbClient.userGroupDao().insert(dbSession, new UserGroupDto().setUserId(simon.getId()).setGroupId(sonarUsers.getId()));
dbClient.userGroupDao().insert(dbSession, new UserGroupDto().setUserId(fmallet.getId()).setGroupId(sonarUsers.getId()));
dbClient.userGroupDao().insert(dbSession, new UserGroupDto().setUserId(fmallet.getId()).setGroupId(sonarAdministrators.getId()));
for (int i = 0; i < 3; i++) {
dbClient.userTokenDao().insert(dbSession, newUserToken().setLogin(simon.getLogin()));
}
dbClient.userTokenDao().insert(dbSession, newUserToken().setLogin(fmallet.getLogin()));
db.commit();
userIndexer.indexOnStartup(null);
loginAsSystemAdministrator();
String response = ws.newGetRequest("api/users", "search").execute().outputAsString();
assertJson(response).isSimilarTo(getClass().getResource("search-example.json"));
}
Aggregations