|
1 | 1 | package com.microsoft.graph.functional; |
2 | 2 |
|
| 3 | +import static org.junit.Assert.assertNotEquals; |
3 | 4 | import static org.junit.Assert.assertNotNull; |
4 | 5 |
|
5 | 6 | import java.io.File; |
6 | 7 | import java.io.FileInputStream; |
7 | 8 | import java.io.InputStream; |
8 | 9 | import java.util.List; |
| 10 | +import java.util.concurrent.ExecutorService; |
| 11 | +import java.util.concurrent.Executors; |
| 12 | +import java.util.concurrent.TimeUnit; |
9 | 13 |
|
10 | 14 | import org.junit.Before; |
11 | 15 | import org.junit.Ignore; |
|
24 | 28 | import com.microsoft.graph.requests.extensions.IOrganizationCollectionPage; |
25 | 29 | import com.microsoft.graph.requests.extensions.IUsedInsightCollectionPage; |
26 | 30 | import com.microsoft.graph.requests.extensions.IUserCollectionPage; |
27 | | - |
28 | 31 | @Ignore |
29 | 32 | public class UserTests { |
30 | 33 | IGraphServiceClient graphServiceClient = null; |
@@ -163,5 +166,26 @@ public void meMemberof() { |
163 | 166 | IDirectoryObjectCollectionWithReferencesPage page = graphServiceClient.me().memberOf().buildRequest().get(); |
164 | 167 | assertNotNull(page); |
165 | 168 | } |
| 169 | + @Test |
| 170 | + public void getMeAndRetryOnThrottling() throws Exception { |
| 171 | + ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); |
| 172 | + try { |
| 173 | + for(Integer i = 0; i < 2000; i++) { |
| 174 | + exec.submit(new Runnable() { |
| 175 | + @Override |
| 176 | + public void run() { |
| 177 | + final IUserCollectionPage users = graphServiceClient.users().buildRequest().get(); |
| 178 | + assertNotNull(users); |
| 179 | + final List<User> currentPage = users.getCurrentPage(); |
| 180 | + assertNotNull(currentPage); |
| 181 | + assertNotEquals(0, currentPage.size()); |
| 182 | + } |
| 183 | + }); |
| 184 | + } |
| 185 | + exec.awaitTermination(5L, TimeUnit.MINUTES); |
| 186 | + } finally { |
| 187 | + exec.shutdown(); |
| 188 | + } |
| 189 | + } |
166 | 190 |
|
167 | 191 | } |
0 commit comments