Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.

Commit 70f8e7d

Browse files
author
Caitlin Bales (MSFT)
committed
Merge remote-tracking branch 'refs/remotes/origin/dev' into caitbal/working
2 parents a47a1a7 + 1e95d15 commit 70f8e7d

File tree

10 files changed

+75
-5504
lines changed

10 files changed

+75
-5504
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ For a more detailed documentation see:
8787
* [Handling Open Types, PATCH support with `null` values](docs/opentypes.md)
8888
* [Collections](docs/collections.md)
8989
* [Errors](docs/errors.md)
90+
* [Making Custom Requests](docs/custom-queries.md)
91+
* [Known Issues](docs/known-issues.md)
9092
* [Contributions](docs/contributions.md)
9193

9294
## 5. Issues

docs/custom-queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Making Custom Calls to Graph
22

3-
The Graph SDK attempts to enable all available scenarios through Microsoft Graph. There are times, however, through errors or custom Graph functionality, that makes calling the desired endpoint is not possible through the provided requests and builders.
3+
The Graph SDK attempts to enable all available scenarios through Microsoft Graph. There are times, however, through errors or custom Graph functionality, that makes calling the desired endpoint not possible through the provided requests and builders.
44

55
## Creating a custom request
66
You can extend BaseRequest to create a custom request:

docs/known-issues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Known Issues
2-
Because of our close partnership with workload teams who surface API functionality through Graph, it is not always appropriate or feasible to introduce fixes to missing or broken functionality.
2+
The Graph library is a snapshot of the Microsoft Graph and may not be in sync with the current service. Because this library is generated, the generator may fail to address all potential scenarios in the Graph. Furthermore, service behavior changes may not be reflected in the library as the development of the library and the Microsoft Graph are loosely coupled.
33

44
## No Annotation Support
55
[OData](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part3-csdl/odata-v4.0-errata03-os-part3-csdl-complete.html#_Toc453752630) allows workloads to specify additional information about their API surface including both functional and non-functional stipulations. We currently do not support these annotations in the [Generator](https://github.com/microsoftgraph/MSGraph-SDK-Code-Generator), due to hierarchical inheritance issues regarding said annotations. Therefore, there may be methods that do not produce valid queries to Graph. Please refer to the [Graph Docs](https://developer.microsoft.com/en-us/graph/docs/concepts/overview) as the source of truth in these discrepancies.

graphsdk/src/androidTest/java/com/microsoft/graph/functional/OutlookTests.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010

1111
import org.junit.Test;
1212

13+
//import com.microsoft.graph.extensions.IDirectoryDeletedItemsCollectionPage;
14+
import com.microsoft.graph.extensions.*;
15+
16+
import org.junit.Assert;
17+
import org.junit.Test;
18+
19+
import javax.xml.datatype.DatatypeFactory;
20+
import javax.xml.datatype.Duration;
21+
import java.lang.reflect.Array;
22+
1323
import java.util.ArrayList;
1424

1525
@Suppress
@@ -38,4 +48,34 @@ public void testSendMail() {
3848
message.toRecipients = recipients;
3949
testBase.graphClient.getMe().getSendMail(message, true).buildRequest().post();
4050
}
51+
52+
@Test
53+
public void testGetFindMeetingTimes() {
54+
TestBase testBase = new TestBase();
55+
56+
// Get the first user in the tenant
57+
User me = testBase.graphClient.getMe().buildRequest().get();
58+
IUserCollectionPage users = testBase.graphClient.getUsers().buildRequest().get();
59+
User tenantUser = users.getCurrentPage().get(0);
60+
61+
//Ensure that the user grabbed is not the logged-in user
62+
if (tenantUser.mail.equals(me.mail)) {
63+
tenantUser = users.getCurrentPage().get(1);
64+
}
65+
66+
List<AttendeeBase> attendees = new ArrayList<>();
67+
AttendeeBase attendeeBase = new AttendeeBase();
68+
EmailAddress email = new EmailAddress();
69+
email.address = tenantUser.mail;
70+
attendeeBase.emailAddress = email;
71+
attendees.add(attendeeBase);
72+
try {
73+
Duration duration = DatatypeFactory.newInstance().newDuration("PT30M");
74+
MeetingTimeSuggestionsResult result = testBase.graphClient.getMe().getFindMeetingTimes(attendees, null, null, duration, 10, true, false, 10.0).buildRequest().post();
75+
assertNotNull(result);
76+
} catch (Exception e) {
77+
Assert.fail("Duration could not be created from String");
78+
}
79+
80+
}
4181
}

graphsdk/src/androidTest/java/com/microsoft/graph/serializer/DurationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
import android.test.AndroidTestCase;
44

5+
import javax.xml.datatype.DatatypeFactory;
56
import javax.xml.datatype.Duration;
67

78
public class DurationTests extends AndroidTestCase {
89

910
public void testDurationSerializer() throws Exception {
10-
String strDuration = org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newInstance().newDurationDayTime(true, 0, 2, 30, 0).toString();
11+
String strDuration = DatatypeFactory.newInstance().newDurationDayTime(true, 0, 2, 30, 0).toString();
1112
assertEquals("P0DT2H30M0S", strDuration);
1213
}
1314

1415
public void testDurationDeserializer() throws Exception {
15-
Duration duration = org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newInstance().newDurationDayTime(true, 0, 1, 30, 45);
16+
Duration duration = DatatypeFactory.newInstance().newDurationDayTime(true, 0, 1, 30, 45);
1617
assertEquals(0, duration.getMonths());
1718
assertEquals(0, duration.getDays());
1819
assertEquals(1, duration.getHours());

graphsdk/src/main/java/com/microsoft/graph/http/DefaultHttpProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ private <Result, Body, DeserializeType> Result sendRequestInternal(final IHttpRe
302302

303303
if (connection.getResponseCode() == HttpResponseCode.HTTP_ACCEPTED) {
304304
mLogger.logDebug("Handling accepted response");
305+
return null;
305306
}
306307

307308
in = new BufferedInputStream(connection.getInputStream());

graphsdk/src/main/java/com/microsoft/graph/serializer/GsonFactory.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
import java.util.EnumSet;
4141
import java.util.GregorianCalendar;
4242

43+
import javax.xml.datatype.DatatypeFactory;
44+
import javax.xml.datatype.Duration;
45+
4346
/**
4447
* Produce Gson instances that can parse http responses.
4548
*/
@@ -183,6 +186,28 @@ public EnumSet deserialize(final JsonElement json,
183186
}
184187
};
185188

189+
final JsonSerializer<Duration> durationJsonSerializer = new JsonSerializer<Duration>() {
190+
@Override
191+
public JsonElement serialize(final Duration src,
192+
final Type typeOfSrc,
193+
final JsonSerializationContext context) {
194+
return new JsonPrimitive(src.toString());
195+
}
196+
};
197+
198+
final JsonDeserializer<Duration> durationJsonDeserializer = new JsonDeserializer<Duration>() {
199+
@Override
200+
public Duration deserialize(final JsonElement json,
201+
final Type typeOfT,
202+
final JsonDeserializationContext context) throws JsonParseException {
203+
try {
204+
return DatatypeFactory.newInstance().newDuration(json.toString());
205+
} catch (Exception e) {
206+
return null;
207+
}
208+
}
209+
};
210+
186211
return new GsonBuilder()
187212
.excludeFieldsWithoutExposeAnnotation()
188213
.registerTypeAdapter(Calendar.class, calendarJsonSerializer)
@@ -195,6 +220,8 @@ public EnumSet deserialize(final JsonElement json,
195220
.registerTypeAdapter(DateOnly.class, dateJsonDeserializer)
196221
.registerTypeAdapter(EnumSet.class, enumSetJsonSerializer)
197222
.registerTypeAdapter(EnumSet.class, enumSetJsonDeserializer)
223+
.registerTypeAdapter(Duration.class, durationJsonSerializer)
224+
.registerTypeAdapter(Duration.class, durationJsonDeserializer)
198225
.registerTypeAdapterFactory(new FallBackEnumTypeAdapter())
199226
.create();
200227
}

0 commit comments

Comments
 (0)