forked from microsoftgraph/msgraph-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathODataTests.java
More file actions
152 lines (129 loc) · 5.99 KB
/
Copy pathODataTests.java
File metadata and controls
152 lines (129 loc) · 5.99 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
package com.microsoft.graph.functional;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import com.google.gson.JsonPrimitive;
import com.microsoft.graph.models.extensions.Extension;
import com.microsoft.graph.models.extensions.ExtensionSchemaProperty;
import com.microsoft.graph.models.extensions.SchemaExtension;
@Ignore
public class ODataTests {
private TestBase testBase;
@Before
public void setUp() {
testBase = new TestBase();
// There's a current limitation of two extensions per user. If there's two extensions in the collection,
// delete the latest one
List<Extension> extensions = testBase.graphClient.me().extensions().buildRequest().get().getCurrentPage();
if (extensions.size() >= 2) {
testBase.graphClient.me().extensions(extensions.get(1).id).buildRequest().delete();
}
}
@Test
public void testOpenExtensions() {
Extension extension = new Extension();
extension.additionalDataManager().put("theme", new JsonPrimitive("dark"));
extension.additionalDataManager().put("extensionName", new JsonPrimitive("Extension1"));
Extension newExtension = testBase.graphClient.me().extensions().buildRequest().post(extension);
assertEquals(extension.additionalDataManager().get("theme"), newExtension.additionalDataManager().get("theme"));
testBase.graphClient.me().extensions(newExtension.id).buildRequest().delete();
}
@Test
public void testSchemaExtensions() {
SchemaExtension extension = new SchemaExtension();
extension.id = "schematest";
extension.description = "Android Graph SDK test";
List<String> targets = new ArrayList<>();
targets.add("Group");
extension.targetTypes = targets;
ExtensionSchemaProperty prop = new ExtensionSchemaProperty();
prop.name = "courseId";
prop.type = "Integer";
ExtensionSchemaProperty prop2 = new ExtensionSchemaProperty();
prop2.name = "courseName";
prop2.type = "String";
List<ExtensionSchemaProperty> properties = new ArrayList<>();
properties.add(prop);
properties.add(prop2);
extension.properties = properties;
SchemaExtension newExtension = testBase.graphClient.schemaExtensions().buildRequest().post(extension);
assertEquals(extension.description, newExtension.description);
try {
SchemaExtension patchExtension = new SchemaExtension();
List<ExtensionSchemaProperty> patchProperties = new ArrayList<>();
ExtensionSchemaProperty patchProperty = new ExtensionSchemaProperty();
patchProperty.name = "newItem";
patchProperty.type = "String";
patchProperties.add(prop);
patchProperties.add(prop2);
patchProperties.add(patchProperty);
patchExtension.properties = patchProperties;
testBase.graphClient.schemaExtensions(newExtension.id).buildRequest().patch(patchExtension);
SchemaExtension updatedExtension = testBase.graphClient.schemaExtensions(newExtension.id).buildRequest().get();
boolean foundUpdatedProperty = false;
for (ExtensionSchemaProperty updatedProperty : updatedExtension.properties) {
if (updatedProperty.name.equals(patchProperty.name)) {
assertEquals(patchProperty.type, updatedProperty.type);
foundUpdatedProperty = true;
break;
}
}
if (!foundUpdatedProperty) {
Assert.fail("Patch failed on Schema Extension");
}
} catch (Exception e) {
Assert.fail("Patch failed on Schema Extension");
} finally {
testBase.graphClient.schemaExtensions(newExtension.id).buildRequest().delete();
}
}
@Test
public void testEnumFlags() {
// EnumSet<MailTipsType> mailTips = EnumSet.noneOf(MailTipsType.class);
// mailTips.add(MailTipsType.automaticReplies);
// mailTips.add(MailTipsType.customMailTip);
// mailTips.add(MailTipsType.recipientScope);
// List<String> emailAddresses = new ArrayList<String>();
// emailAddresses.add("katiej@mod810997.onmicrosoft.com");
// emailAddresses.add("garthf@mod810997.onmicrosoft.com");
// emailAddresses.add("admin@mod810997.onmicrosoft.com");
//
// IUserGetMailTipsCollectionPage mailTipsCollection = testBase.graphClient.getMe().getGetMailTips(emailAddresses, mailTips).buildRequest().post();
//
// assertNotNull(mailTipsCollection);
//
// List<MailTips> mailTipsPage = mailTipsCollection.getCurrentPage();
// EnumSet<RecipientScopeType> recipientScopeTypes = EnumSet.allOf(RecipientScopeType.class);
// for (int i = 0; i< mailTipsPage.size(); i++) {
// if (mailTipsPage.get(i).recipientScope != null) {
// assertTrue(mailTipsPage.get(i).recipientScope.getClass().isInstance(mailTips));
// }
// }
}
@Test
public void testDeltaQuery() {
// testBase.graphClient.setServiceRoot("https://graph.microsoft.com/beta");
// IGroupDeltaCollectionPage deltas = testBase.graphClient.getGroups().getDelta().buildRequest().get();
//
// assertNotNull(deltas.getCurrentPage());
// for (int i = 0; i < deltas.getCurrentPage().size(); i++) {
// Group group = deltas.getCurrentPage().get(i);
// String s = group.description;
// }
//
// while(deltas.getNextPage() != null) {
// deltas = deltas.getNextPage().buildRequest().get();
// assertNotNull(deltas.getCurrentPage());
// }
//
// IGroupDeltaCollectionPage deltas2 = testBase.graphClient.getGroups().getDelta(deltas.getDeltaLink()).buildRequest().get();
// assertNotNull(deltas2);
}
@Test
public void testDeletedItem() {
}
}