|
20 | 20 | import okhttp3.Request; |
21 | 21 |
|
22 | 22 | import com.microsoft.graph.http.HttpMethod; |
| 23 | +import com.microsoft.graph.models.extensions.DirectoryObject; |
23 | 24 | import com.microsoft.graph.models.extensions.Drive; |
24 | 25 | import com.microsoft.graph.models.extensions.DriveItem; |
| 26 | +import com.microsoft.graph.models.extensions.Group; |
25 | 27 | import com.microsoft.graph.models.extensions.IGraphServiceClient; |
26 | 28 | import com.microsoft.graph.models.extensions.ProfilePhoto; |
27 | 29 | import com.microsoft.graph.models.extensions.User; |
|
30 | 32 | import com.microsoft.graph.requests.extensions.IContactCollectionPage; |
31 | 33 | import com.microsoft.graph.requests.extensions.IDirectoryObjectCollectionWithReferencesPage; |
32 | 34 | import com.microsoft.graph.requests.extensions.IDriveItemCollectionPage; |
| 35 | +import com.microsoft.graph.requests.extensions.IGroupCollectionPage; |
33 | 36 | import com.microsoft.graph.requests.extensions.IMailFolderCollectionPage; |
34 | 37 | import com.microsoft.graph.requests.extensions.IMessageCollectionPage; |
35 | 38 | import com.microsoft.graph.requests.extensions.IOrganizationCollectionPage; |
@@ -209,5 +212,32 @@ public void emptyPostContentType() { |
209 | 212 | .getHttpRequest(); |
210 | 213 | assertEquals(contentTypeValue, request.body().contentType().toString()); |
211 | 214 | } |
212 | | - |
| 215 | + @Test |
| 216 | + public void castTest() { |
| 217 | + final IGroupCollectionPage groups = graphServiceClient.groups().buildRequest().top(1).get(); |
| 218 | + final Group group = groups.getCurrentPage().get(0); |
| 219 | + final IUserCollectionPage usersPage = graphServiceClient |
| 220 | + .groups(group.id) |
| 221 | + .members() |
| 222 | + .castToUsers() |
| 223 | + .buildRequest() |
| 224 | + .get(); |
| 225 | + assertNotNull(usersPage); |
| 226 | + |
| 227 | + final IDirectoryObjectCollectionWithReferencesPage testUserCollection = graphServiceClient |
| 228 | + .groups(group.id) |
| 229 | + .members() |
| 230 | + .buildRequest() |
| 231 | + .top(1) |
| 232 | + .get(); |
| 233 | + final DirectoryObject testUser = testUserCollection.getCurrentPage().get(0); |
| 234 | + |
| 235 | + final User user = graphServiceClient |
| 236 | + .groups(group.id) |
| 237 | + .members(testUser.id) |
| 238 | + .castToUser() |
| 239 | + .buildRequest() |
| 240 | + .get(); |
| 241 | + assertNotNull(user); |
| 242 | + } |
213 | 243 | } |
0 commit comments