|
| 1 | +package com.microsoft.graph.functional; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertNotNull; |
| 4 | + |
| 5 | +import java.io.InputStream; |
| 6 | +import java.util.List; |
| 7 | + |
| 8 | +import org.junit.Before; |
| 9 | +import org.junit.Ignore; |
| 10 | +import org.junit.Test; |
| 11 | + |
| 12 | +import com.microsoft.graph.models.extensions.Drive; |
| 13 | +import com.microsoft.graph.models.extensions.DriveItem; |
| 14 | +import com.microsoft.graph.models.extensions.IGraphServiceClient; |
| 15 | +import com.microsoft.graph.models.extensions.User; |
| 16 | +import com.microsoft.graph.requests.extensions.IContactCollectionPage; |
| 17 | +import com.microsoft.graph.requests.extensions.IDirectoryObjectCollectionWithReferencesPage; |
| 18 | +import com.microsoft.graph.requests.extensions.IDriveItemCollectionPage; |
| 19 | +import com.microsoft.graph.requests.extensions.IMailFolderCollectionPage; |
| 20 | +import com.microsoft.graph.requests.extensions.IMessageCollectionPage; |
| 21 | +import com.microsoft.graph.requests.extensions.IOrganizationCollectionPage; |
| 22 | +import com.microsoft.graph.requests.extensions.IUsedInsightCollectionPage; |
| 23 | +import com.microsoft.graph.requests.extensions.IUserCollectionPage; |
| 24 | + |
| 25 | +@Ignore |
| 26 | +public class UserTests { |
| 27 | + IGraphServiceClient graphServiceClient = null; |
| 28 | + |
| 29 | + @Before |
| 30 | + public void setUp() { |
| 31 | + TestBase testBase = new TestBase(); |
| 32 | + graphServiceClient = testBase.graphClient; |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void getMeTest() { |
| 37 | + //GET me |
| 38 | + User user = graphServiceClient.me().buildRequest().get(); |
| 39 | + assertNotNull(user); |
| 40 | + assertNotNull(user.displayName); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void getMePhoto() { |
| 45 | + //GET me/photo/$value |
| 46 | + User user = graphServiceClient.me().buildRequest().get(); |
| 47 | + assertNotNull(user); |
| 48 | + if(user.photo != null) { |
| 49 | + InputStream stream = graphServiceClient.me().photo().content().buildRequest().get(); |
| 50 | + assertNotNull(stream); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void meDriveTest() { |
| 56 | + //GET me/drive/root/children |
| 57 | + IDriveItemCollectionPage driveItemCollectionPage = graphServiceClient.me().drive().root().children().buildRequest().get(); |
| 58 | + assertNotNull(driveItemCollectionPage); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + public void userKeyTest() { |
| 63 | + //GET users('<<key>>') |
| 64 | + IUserCollectionPage userCollectionPage = graphServiceClient.users().buildRequest().get(); |
| 65 | + assertNotNull(userCollectionPage); |
| 66 | + List<User> list = userCollectionPage.getCurrentPage(); |
| 67 | + if(list.size() > 0) { |
| 68 | + User user = graphServiceClient.users(list.get(0).id).buildRequest().get(); |
| 69 | + assertNotNull(user); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + @Test |
| 74 | + public void meDriveRoot() { |
| 75 | + //GET me/drive/root |
| 76 | + DriveItem driveItem = graphServiceClient.me().drive().root().buildRequest().get(); |
| 77 | + assertNotNull(driveItem); |
| 78 | + } |
| 79 | + |
| 80 | + @Test |
| 81 | + public void meDrive() { |
| 82 | + //GET me/drive |
| 83 | + Drive drive = graphServiceClient.me().drive().buildRequest().get(); |
| 84 | + assertNotNull(drive); |
| 85 | + } |
| 86 | + |
| 87 | + @Test |
| 88 | + public void meDriveItems() { |
| 89 | + //GET me/drive/items('<key>') |
| 90 | + IDriveItemCollectionPage driveItemCollectionPage = graphServiceClient.me().drive().items().buildRequest().get(); |
| 91 | + assertNotNull(driveItemCollectionPage); |
| 92 | + if(driveItemCollectionPage.getCurrentPage().size() > 0) { |
| 93 | + DriveItem item = graphServiceClient.me().drive().items(driveItemCollectionPage.getCurrentPage().get(0).id).buildRequest().get(); |
| 94 | + assertNotNull(item); |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | + @Test |
| 99 | + public void meMessagesTest() { |
| 100 | + //GET me/messages |
| 101 | + IMessageCollectionPage messageCollectionPage = graphServiceClient.me().messages().buildRequest().get(); |
| 102 | + assertNotNull(messageCollectionPage); |
| 103 | + } |
| 104 | + |
| 105 | + @Test |
| 106 | + public void meContactsTest() { |
| 107 | + //GET me/contacts |
| 108 | + IContactCollectionPage contactCollectionPage = graphServiceClient.me().contacts().buildRequest().get(); |
| 109 | + assertNotNull(contactCollectionPage); |
| 110 | + } |
| 111 | + |
| 112 | + @Test |
| 113 | + public void usersKeyPhotoValueTest() { |
| 114 | + //GET users('<<key>>')/photo/$value |
| 115 | + IUserCollectionPage userCollectionPage = graphServiceClient.users().buildRequest().get(); |
| 116 | + for(User user:userCollectionPage.getCurrentPage()) { |
| 117 | + if(user.photo!=null) { |
| 118 | + InputStream stream = graphServiceClient.users(userCollectionPage.getCurrentPage().get(0).id).photo().content().buildRequest().get(); |
| 119 | + assertNotNull(stream); |
| 120 | + break; |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + @Test |
| 126 | + public void getOrganization() { |
| 127 | + //GET organization |
| 128 | + IOrganizationCollectionPage organizationCollectionPage = graphServiceClient.organization().buildRequest().get(); |
| 129 | + assertNotNull(organizationCollectionPage); |
| 130 | + } |
| 131 | + |
| 132 | + @Test |
| 133 | + public void meInsightsUsed() { |
| 134 | + //GET me/insights/used |
| 135 | + IUsedInsightCollectionPage usedInsightCollectionPage = graphServiceClient.me().insights().used().buildRequest().get(); |
| 136 | + assertNotNull(usedInsightCollectionPage); |
| 137 | + } |
| 138 | + |
| 139 | + @Test |
| 140 | + public void mailFoldertest() { |
| 141 | + //GET me/mailFolders |
| 142 | + IMailFolderCollectionPage mailFolderCollectionPage = graphServiceClient.me().mailFolders().buildRequest().get(); |
| 143 | + assertNotNull(mailFolderCollectionPage); |
| 144 | + if(mailFolderCollectionPage.getCurrentPage().size() > 0) { |
| 145 | + String mailFolderId = mailFolderCollectionPage.getCurrentPage().get(0).id; |
| 146 | + IMessageCollectionPage messageCollectionPage = graphServiceClient.me().mailFolders(mailFolderId).messages().buildRequest().get(); |
| 147 | + assertNotNull(messageCollectionPage); |
| 148 | + } |
| 149 | + } |
| 150 | + |
| 151 | + @Test |
| 152 | + public void meMemberof() { |
| 153 | + IDirectoryObjectCollectionWithReferencesPage page = graphServiceClient.me().memberOf().buildRequest().get(); |
| 154 | + assertNotNull(page); |
| 155 | + } |
| 156 | + |
| 157 | +} |
0 commit comments