use of com.thoughtworks.go.plugin.domain.authorization.User in project gocd by gocd.
the class UserSearchServiceTest method shouldSearchUserUsingPlugins.
@Test
public void shouldSearchUserUsingPlugins() throws Exception {
final String searchTerm = "foo";
List<String> pluginIds = asList("plugin-id-1", "plugin-id-2", "plugin-id-3", "plugin-id-4");
addPluginSupportingUserSearch(pluginIds.get(0));
addPluginSupportingUserSearch(pluginIds.get(1));
addPluginSupportingUserSearch(pluginIds.get(2));
addPluginSupportingUserSearch(pluginIds.get(3));
when(authorizationExtension.canHandlePlugin(anyString())).thenReturn(true);
when(goConfigService.security()).thenReturn(new SecurityConfig());
when(authorizationExtension.searchUsers("plugin-id-1", searchTerm, Collections.emptyList())).thenReturn(asList(getPluginUser(1)));
when(authorizationExtension.searchUsers("plugin-id-2", searchTerm, Collections.emptyList())).thenReturn(asList(getPluginUser(2), getPluginUser(3)));
when(authorizationExtension.searchUsers("plugin-id-3", searchTerm, Collections.emptyList())).thenReturn(new ArrayList<>());
when(authorizationExtension.searchUsers("plugin-id-4", searchTerm, Collections.emptyList())).thenReturn(asList(new User("username-" + 4, null, null)));
List<UserSearchModel> models = userSearchService.search(searchTerm, new HttpLocalizedOperationResult());
assertThat(models, Matchers.containsInAnyOrder(new UserSearchModel(getUser(1), UserSourceType.PLUGIN), new UserSearchModel(getUser(2), UserSourceType.PLUGIN), new UserSearchModel(getUser(3), UserSourceType.PLUGIN), new UserSearchModel(new com.thoughtworks.go.domain.User("username-" + 4, "", ""), UserSourceType.PLUGIN)));
}
Aggregations