use of com.microsoft.graph.requests.DirectoryObjectCollectionWithReferencesPage in project msgraph-sdk-java by microsoftgraph.
the class UserTests method meMemberof.
@Test
public void meMemberof() {
final DirectoryObjectCollectionWithReferencesPage page = graphServiceClient.me().memberOf().buildRequest().get();
assertNotNull(page);
}
use of com.microsoft.graph.requests.DirectoryObjectCollectionWithReferencesPage in project msgraph-beta-sdk-java by microsoftgraph.
the class UserTests method meMemberof.
@Test
public void meMemberof() {
final DirectoryObjectCollectionWithReferencesPage page = graphServiceClient.me().memberOf().buildRequest().get();
assertNotNull(page);
}
use of com.microsoft.graph.requests.DirectoryObjectCollectionWithReferencesPage in project msgraph-beta-sdk-java by microsoftgraph.
the class UserTests method castTest.
@Test
public void castTest() {
final GroupCollectionPage groups = graphServiceClient.groups().buildRequest().top(1).get();
final Group group = groups.getCurrentPage().get(0);
final UserCollectionPage usersPage = graphServiceClient.groups(group.id).membersAsUser().buildRequest().get();
assertNotNull(usersPage);
final DirectoryObjectCollectionWithReferencesPage testUserCollection = graphServiceClient.groups(group.id).members().buildRequest().top(1).get();
final DirectoryObject testUser = testUserCollection.getCurrentPage().get(0);
final User user = graphServiceClient.groups(group.id).membersAsUser(testUser.id).buildRequest().get();
assertNotNull(user);
}
use of com.microsoft.graph.requests.DirectoryObjectCollectionWithReferencesPage in project azure-ad-plugin by jenkinsci.
the class AzureCachePool method getBelongingGroupsByOid.
public List<AzureAdGroup> getBelongingGroupsByOid(final String oid) {
List<AzureAdGroup> result = belongingGroupsByOid.get(oid, (cacheKey) -> {
try {
DirectoryObjectCollectionWithReferencesPage collection = azure.users(oid).transitiveMemberOf().buildRequest().get();
List<AzureAdGroup> groups = new ArrayList<>();
while (collection != null) {
final List<DirectoryObject> directoryObjects = collection.getCurrentPage();
List<AzureAdGroup> groupsFromPage = directoryObjects.stream().map(group -> {
if (group instanceof Group) {
return new AzureAdGroup(group.id, ((Group) group).displayName);
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
groups.addAll(groupsFromPage);
DirectoryObjectCollectionWithReferencesRequestBuilder nextPage = collection.getNextPage();
if (nextPage == null) {
break;
} else {
collection = nextPage.buildRequest().get();
}
}
return groups;
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Do not have sufficient privileges to " + "fetch your belonging groups' authorities.", e);
return Collections.emptyList();
}
});
if (Constants.DEBUG) {
belongingGroupsByOid.invalidate(oid);
}
return result;
}
use of com.microsoft.graph.requests.DirectoryObjectCollectionWithReferencesPage in project msgraph-sdk-java by microsoftgraph.
the class UserTests method castTest.
@Test
public void castTest() {
final GroupCollectionPage groups = graphServiceClient.groups().buildRequest().top(1).get();
final Group group = groups.getCurrentPage().get(0);
final UserCollectionPage usersPage = graphServiceClient.groups(group.id).membersAsUser().buildRequest().get();
assertNotNull(usersPage);
final DirectoryObjectCollectionWithReferencesPage testUserCollection = graphServiceClient.groups(group.id).members().buildRequest().top(1).get();
final DirectoryObject testUser = testUserCollection.getCurrentPage().get(0);
final User user = graphServiceClient.groups(group.id).membersAsUser(testUser.id).buildRequest().get();
assertNotNull(user);
}
Aggregations