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