Skip to content

Commit 7675bfd

Browse files
Merge pull request #194 from microsoftgraph/enhance-tests
Enchanced tests
2 parents b36c005 + a77849a commit 7675bfd

File tree

2 files changed

+225
-0
lines changed

2 files changed

+225
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.microsoft.graph.functional;
2+
3+
import static org.junit.Assert.assertNotNull;
4+
5+
import java.util.ArrayList;
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.Calendar;
13+
import com.microsoft.graph.models.extensions.IGraphServiceClient;
14+
import com.microsoft.graph.options.Option;
15+
import com.microsoft.graph.options.QueryOption;
16+
import com.microsoft.graph.requests.extensions.ICalendarCollectionPage;
17+
import com.microsoft.graph.requests.extensions.IEventCollectionPage;
18+
19+
@Ignore
20+
public class CalendarTests {
21+
IGraphServiceClient graphServiceClient = null;
22+
23+
@Before
24+
public void setUp() {
25+
TestBase testBase = new TestBase();
26+
graphServiceClient = testBase.graphClient;
27+
}
28+
29+
@Test
30+
public void getMeCalendars() {
31+
//GET me/calendars
32+
ICalendarCollectionPage calendarCollectionPage = graphServiceClient.me().calendars().buildRequest().get();
33+
assertNotNull(calendarCollectionPage);
34+
}
35+
36+
@Test
37+
public void getMeCalendarsview() {
38+
//GET me/calendarview
39+
QueryOption q1 = new QueryOption("startDateTime", "2015-11-08T19:00:00.0000000");
40+
QueryOption q2 = new QueryOption("endDateTime", "2018-12-25T20:00:00.0000000");
41+
List<Option> list = new ArrayList<>();
42+
list.add(q1);
43+
list.add(q2);
44+
IEventCollectionPage collectionPage = graphServiceClient.me().calendarView().buildRequest(list).get();
45+
assertNotNull(collectionPage);
46+
}
47+
48+
@Test
49+
public void meCalendarKeyCalendarviewTest() {
50+
//GET me/calendars('<key>')/calendarview
51+
QueryOption q1 = new QueryOption("startDateTime", "2015-11-08T19:00:00.0000000");
52+
QueryOption q2 = new QueryOption("endDateTime", "2018-12-25T20:00:00.0000000");
53+
List<Option> list = new ArrayList<>();
54+
list.add(q1);
55+
list.add(q2);
56+
ICalendarCollectionPage calendarCollectionPage = graphServiceClient.me().calendars().buildRequest().get();
57+
assertNotNull(calendarCollectionPage);
58+
if(calendarCollectionPage.getCurrentPage().size() > 0)
59+
graphServiceClient.me().calendars(calendarCollectionPage.getCurrentPage().get(0).id).calendarView().buildRequest(list).get();
60+
}
61+
62+
@Test
63+
public void meCalendartest() {
64+
//GET me/calendar
65+
Calendar calendar = graphServiceClient.me().calendar().buildRequest().get();
66+
assertNotNull(calendar);
67+
}
68+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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

Comments
 (0)