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

Commit 1e95d15

Browse files
author
Caitlin Bales (MSFT)
authored
Merge pull request #56 from microsoftgraph/bugfix
Bug fixes
2 parents d1bee8b + 1031549 commit 1e95d15

File tree

10 files changed

+71
-5512
lines changed

10 files changed

+71
-5512
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: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
import android.test.suitebuilder.annotation.Suppress;
55

66
//import com.microsoft.graph.extensions.IDirectoryDeletedItemsCollectionPage;
7-
import com.microsoft.graph.extensions.EmailAddress;
8-
import com.microsoft.graph.extensions.IDirectoryObjectCollectionPage;
9-
import com.microsoft.graph.extensions.IDriveItemCollectionPage;
10-
import com.microsoft.graph.extensions.IDriveItemCollectionRequestBuilder;
11-
import com.microsoft.graph.extensions.IGraphServiceClient;
12-
import com.microsoft.graph.extensions.Message;
13-
import com.microsoft.graph.extensions.Recipient;
14-
import com.microsoft.graph.extensions.User;
7+
import com.microsoft.graph.extensions.*;
158

9+
import org.junit.Assert;
10+
import org.junit.Test;
11+
12+
import javax.xml.datatype.DatatypeFactory;
13+
import javax.xml.datatype.Duration;
1614
import java.lang.reflect.Array;
1715
import java.util.ArrayList;
1816
import java.util.List;
@@ -41,4 +39,34 @@ public void testSendMail() {
4139
message.toRecipients = recipients;
4240
testBase.graphClient.getMe().getSendMail(message, true).buildRequest().post();
4341
}
42+
43+
@Test
44+
public void testGetFindMeetingTimes() {
45+
TestBase testBase = new TestBase();
46+
47+
// Get the first user in the tenant
48+
User me = testBase.graphClient.getMe().buildRequest().get();
49+
IUserCollectionPage users = testBase.graphClient.getUsers().buildRequest().get();
50+
User tenantUser = users.getCurrentPage().get(0);
51+
52+
//Ensure that the user grabbed is not the logged-in user
53+
if (tenantUser.mail.equals(me.mail)) {
54+
tenantUser = users.getCurrentPage().get(1);
55+
}
56+
57+
List<AttendeeBase> attendees = new ArrayList<>();
58+
AttendeeBase attendeeBase = new AttendeeBase();
59+
EmailAddress email = new EmailAddress();
60+
email.address = tenantUser.mail;
61+
attendeeBase.emailAddress = email;
62+
attendees.add(attendeeBase);
63+
try {
64+
Duration duration = DatatypeFactory.newInstance().newDuration("PT30M");
65+
MeetingTimeSuggestionsResult result = testBase.graphClient.getMe().getFindMeetingTimes(attendees, null, null, duration, 10, true, false, 10.0).buildRequest().post();
66+
assertNotNull(result);
67+
} catch (Exception e) {
68+
Assert.fail("Duration could not be created from String");
69+
}
70+
71+
}
4472
}

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)