diff --git a/common/azure-spring-boot-starter-parent/pom.xml b/common/azure-spring-boot-starter-parent/pom.xml index 71b9eb3c8..99ddf3cfc 100644 --- a/common/azure-spring-boot-starter-parent/pom.xml +++ b/common/azure-spring-boot-starter-parent/pom.xml @@ -128,7 +128,9 @@ private false - com/microsoft/azure/spring/data/documentdb/core/mapping/BasicDocumentDbPersistentProperty.java + + com/microsoft/azure/spring/data/documentdb/core/mapping/BasicDocumentDbPersistentProperty.java + diff --git a/common/config/findbugs-exclude.xml b/common/config/findbugs-exclude.xml index 5a48d6930..4436a900e 100644 --- a/common/config/findbugs-exclude.xml +++ b/common/config/findbugs-exclude.xml @@ -5,4 +5,5 @@ + \ No newline at end of file diff --git a/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/pom.xml b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/pom.xml index 8d2ee4aa5..a2bc30691 100644 --- a/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/pom.xml +++ b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/pom.xml @@ -54,11 +54,6 @@ org.springframework.social spring-social-config - - org.springframework.boot - spring-boot-starter-test - test - org.springframework.boot spring-boot-starter-validation @@ -67,5 +62,15 @@ com.microsoft.azure spring-social-microsoft-graph + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-web + test + \ No newline at end of file diff --git a/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/Constants.java b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/Constants.java new file mode 100644 index 000000000..615f6e384 --- /dev/null +++ b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/Constants.java @@ -0,0 +1,13 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ +package com.microsoft.azure.autoconfigure.msgraph; + +public class Constants { + public static final String APP_ID_PROPERTY = "spring.social.microsoft.app-id"; + public static final String APP_ID = "123456789-acb1-4d0b-a13b-1a70ac85d8bf"; + public static final String APP_SECRET_PROPERTY = "spring.social.microsoft.app-secret"; + public static final String APP_SECRET = "1234mAocWmbvawgg4hyRTZ8"; +} diff --git a/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/MicrosoftAutoConfigurationTest.java b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/MicrosoftAutoConfigurationTest.java new file mode 100644 index 000000000..67bfea80b --- /dev/null +++ b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/MicrosoftAutoConfigurationTest.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.autoconfigure.msgraph; + +import com.microsoft.azure.msgraph.api.Microsoft; +import org.assertj.core.api.Assertions; +import org.junit.Test; +import org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +import static org.assertj.core.api.Java6Assertions.assertThat; + +public class MicrosoftAutoConfigurationTest { + @Test + public void canAutowire() { + System.setProperty(Constants.APP_ID_PROPERTY, Constants.APP_ID); + System.setProperty(Constants.APP_SECRET_PROPERTY, Constants.APP_SECRET); + + try (AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext()) { + context.register(MicrosoftAutoConfiguration.class); + context.register(SocialWebAutoConfiguration.class); + context.refresh(); + Assertions.assertThat(context.getBean(Microsoft.class)).isNotNull(); + } + + System.clearProperty(Constants.APP_ID_PROPERTY); + System.clearProperty(Constants.APP_SECRET_PROPERTY); + } + + @Test + public void cannotAutowire() { + try (AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext()) { + context.register(MicrosoftAutoConfiguration.class); + context.register(SocialWebAutoConfiguration.class); + context.refresh(); + + Microsoft microsoft = null; + try { + microsoft = context.getBean(Microsoft.class); + } catch (Exception e) { + assertThat(e.getMessage()).contains("No qualifying bean of type 'com.microsoft.azure." + + "msgraph.api.Microsoft' available"); + } + assertThat(microsoft).isNull(); + } + } +} diff --git a/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/MicrosoftPropertiesTest.java b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/MicrosoftPropertiesTest.java new file mode 100644 index 000000000..085da0394 --- /dev/null +++ b/microsoft-graph/microsoft-graph-spring-boot-autoconfigure/src/test/java/com/microsoft/azure/autoconfigure/msgraph/MicrosoftPropertiesTest.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.autoconfigure.msgraph; + +import org.junit.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Configuration; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MicrosoftPropertiesTest { + @Test + public void canSetProperties() { + System.setProperty(Constants.APP_ID_PROPERTY, Constants.APP_ID); + System.setProperty(Constants.APP_SECRET_PROPERTY, Constants.APP_SECRET); + + try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { + context.register(Config.class); + context.refresh(); + final MicrosoftProperties properties = context.getBean(MicrosoftProperties.class); + + assertThat(properties.getAppId()).isEqualTo(Constants.APP_ID); + assertThat(properties.getAppSecret()).isEqualTo(Constants.APP_SECRET); + } + + System.clearProperty(Constants.APP_ID_PROPERTY); + System.clearProperty(Constants.APP_SECRET_PROPERTY); + } + + @Configuration + @EnableConfigurationProperties(MicrosoftProperties.class) + static class Config { + } +} diff --git a/microsoft-graph/microsoft-graph-spring-social-starter-sample/README.md b/microsoft-graph/microsoft-graph-spring-social-starter-sample/README.md index f78e6cfa5..941b97f3c 100644 --- a/microsoft-graph/microsoft-graph-spring-social-starter-sample/README.md +++ b/microsoft-graph/microsoft-graph-spring-social-starter-sample/README.md @@ -34,4 +34,9 @@ Go to [Application Registration Portal](https://apps.dev.microsoft.com/#/appList ``` mvn package java -jar target/microsoft-graph-spring-social-starter-sample-0.0.1-SNAPSHOT.jar -``` \ No newline at end of file +``` + +### Make your own REST API call + +This starter implements a small subset of Objects/APIs available via Microsoft Graph (GET /me, POST /me/sendMail, GET /me/messages). In addition, it demonstrates how to make custom REST API calls (see function `getContacts` in `HelloController.java` as an example). Please check the detailed [document](https://developer.microsoft.com/en-us/graph/docs/concepts/overview) for more details about Microsoft Graph. +After reading the document, you should be aware of the exact REST API and what objects you should prepare or expect from the REST API call. diff --git a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/HelloController.java b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/HelloController.java index dd2633688..14f3e3db8 100644 --- a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/HelloController.java +++ b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/HelloController.java @@ -10,13 +10,14 @@ import org.springframework.social.connect.ConnectionRepository; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.client.RestTemplate; +import sample.microsoft.graph.custom.Contacts; + +import java.net.URI; @Controller -@RequestMapping("/") public class HelloController { - private Microsoft microsoft; private ConnectionRepository connectionRepository; @@ -25,8 +26,8 @@ public HelloController(Microsoft microsoft, ConnectionRepository connectionRepos this.connectionRepository = connectionRepository; } - @GetMapping - public String helloFacebook(Model model) { + @RequestMapping("/") + public String helloMicrosoft(Model model) { if (connectionRepository.findPrimaryConnection(Microsoft.class) == null) { return "redirect:/connect/microsoft"; } @@ -36,4 +37,17 @@ public String helloFacebook(Model model) { return "hello"; } + @RequestMapping("/contacts") + public String getContacts(Model model) { + if (connectionRepository.findPrimaryConnection(Microsoft.class) == null) { + return "redirect:/connect/microsoft"; + } + + final RestTemplate restTemplate = microsoft.customOperations().getRestTemplate(); + final URI uri = microsoft.customOperations().getGraphAPIURI("me/contacts"); + final Contacts contacts = restTemplate.getForObject(uri, Contacts.class); + model.addAttribute("contacts", contacts.getContacts()); + + return "contacts"; + } } diff --git a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/custom/Contact.java b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/custom/Contact.java new file mode 100644 index 000000000..3ee043c76 --- /dev/null +++ b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/custom/Contact.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package sample.microsoft.graph.custom; + +// Please be noted this is not a complete representation of the JSON object returned by Microsoft Graph. +public class Contact { + + private String displayName; + private String mobilePhone; + + /** + * The Display Name. + */ + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * The Mobile Phone. + */ + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } +} diff --git a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/custom/Contacts.java b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/custom/Contacts.java new file mode 100644 index 000000000..5e83db04d --- /dev/null +++ b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/java/sample/microsoft/graph/custom/Contacts.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package sample.microsoft.graph.custom; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Contacts { + @JsonProperty("value") + private java.util.List contacts; + + @JsonProperty("@odata.nextLink") + private String nextLink; + + public java.util.List getContacts() { + return contacts; + } + + public void setContacts(java.util.List contacts) { + this.contacts = contacts; + } + + /** + * The url to the next page of this collection, or null + */ + public String getNextLink() { + return nextLink; + } + + public void setNextLink(String nextLink) { + this.nextLink = nextLink; + } +} diff --git a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/connect/microsoftConnect.html b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/connect/microsoftConnect.html index ee863d4ec..27fce0f4a 100644 --- a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/connect/microsoftConnect.html +++ b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/connect/microsoftConnect.html @@ -6,7 +6,7 @@

Connect to Microsoft Graph

- +

You aren't connected to Microsoft yet. Click the button to connect this application with your Microsoft account.

diff --git a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/contacts.html b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/contacts.html new file mode 100644 index 000000000..2e8767d28 --- /dev/null +++ b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/contacts.html @@ -0,0 +1,17 @@ + + + Hello Microsoft Graph + + + + + + + + + +
NamePhone
+ +
+ + \ No newline at end of file diff --git a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/hello.html b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/hello.html index c38603b65..a95963c2a 100644 --- a/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/hello.html +++ b/microsoft-graph/microsoft-graph-spring-social-starter-sample/src/main/resources/templates/hello.html @@ -48,6 +48,10 @@ User Principal Name + + Contacts + click here + \ No newline at end of file diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/BodyType.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/BodyType.java new file mode 100644 index 000000000..715bd5477 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/BodyType.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +/** + * The Enum Body Type. + */ +public enum BodyType { + /** + * text + */ + text, + /** + * html + */ + html, + /** + * For BodyType values that were not expected from the service + */ + unexpectedValue +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/CustomOperations.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/CustomOperations.java new file mode 100644 index 000000000..d439937f4 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/CustomOperations.java @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +import org.springframework.web.client.RestTemplate; + +import java.net.URI; + +public interface CustomOperations { + public RestTemplate getRestTemplate(); + + public URI getGraphAPIURI(String relativePath); +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/EmailAddress.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/EmailAddress.java new file mode 100644 index 000000000..f6071f5e0 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/EmailAddress.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +public class EmailAddress { + private String name; + + private String address; + + /** + * The Name. + */ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * The Address. + */ + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Importance.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Importance.java new file mode 100644 index 000000000..5e44d9363 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Importance.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +/** + * The Enum Importance. + */ +public enum Importance { + /** + * low + */ + low, + /** + * normal + */ + normal, + /** + * high + */ + high, + /** + * For Importance values that were not expected from the service + */ + unexpectedValue +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/InferenceClassificationType.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/InferenceClassificationType.java new file mode 100644 index 000000000..2b2916ce9 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/InferenceClassificationType.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +/** + * The Enum Inference Classification Type. + */ +public enum InferenceClassificationType { + /** + * focused + */ + focused, + /** + * other + */ + other, + /** + * For InferenceClassificationType values that were not expected from the service + */ + unexpectedValue +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/ItemBody.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/ItemBody.java new file mode 100644 index 000000000..c4bf099b7 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/ItemBody.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +public class ItemBody { + private BodyType contentType; + + private String content; + + /** + * The Content Type. + */ + public BodyType getContentType() { + return contentType; + } + + public void setContentType(BodyType contentType) { + this.contentType = contentType; + } + + /** + * The Content. + */ + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/MailOperations.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/MailOperations.java new file mode 100644 index 000000000..159a3cad7 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/MailOperations.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +import org.springframework.util.MultiValueMap; + +public interface MailOperations { + Messages listMessages(); + + Messages listMessages(String mailFolder); + + Messages listMessages(MultiValueMap params); + + Messages listMessages(String mailFolder, MultiValueMap params); + + Messages listMessagesWithNextLink(String nextLink); + + void sendMail(Message message, Boolean saveToSentItems); +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Message.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Message.java new file mode 100644 index 000000000..572366adc --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Message.java @@ -0,0 +1,376 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Message { + private java.util.Calendar lastModifiedDateTime; + + private java.util.Calendar createdDateTime; + + private java.util.Calendar receivedDateTime; + + private java.util.Calendar sentDateTime; + + private Boolean hasAttachments; + + private String internetMessageId; + + private String id; + + private String subject; + + private ItemBody body; + + private String bodyPreview; + + private Importance importance; + + private String parentFolderId; + + private Recipient sender; + + private Recipient from; + + private java.util.List toRecipients; + + private java.util.List ccRecipients; + + private java.util.List categories; + + private java.util.List bccRecipients; + + private java.util.List replyTo; + + private String changeKey; + + private String conversationId; + + private Boolean isDeliveryReceiptRequested; + + private Boolean isReadReceiptRequested; + + private Boolean isRead; + + private Boolean isDraft; + + private String webLink; + + private InferenceClassificationType inferenceClassification; + + private ItemBody uniqueBody; + + /** + * The date and time the message was last changed. + */ + public java.util.Calendar getLastModifiedDateTime() { + return lastModifiedDateTime; + } + + public void setLastModifiedDateTime(java.util.Calendar lastModifiedDateTime) { + this.lastModifiedDateTime = lastModifiedDateTime; + } + + /** + * The date and time the message was created. + */ + public java.util.Calendar getCreatedDateTime() { + return createdDateTime; + } + + public void setCreatedDateTime(java.util.Calendar createdDateTime) { + this.createdDateTime = createdDateTime; + } + + /** + * The Received Date Time. + */ + public java.util.Calendar getReceivedDateTime() { + return receivedDateTime; + } + + public void setReceivedDateTime(java.util.Calendar receivedDateTime) { + this.receivedDateTime = receivedDateTime; + } + + /** + * The Sent Date Time. + */ + public java.util.Calendar getSentDateTime() { + return sentDateTime; + } + + public void setSentDateTime(java.util.Calendar sentDateTime) { + this.sentDateTime = sentDateTime; + } + + /** + * The Has Attachments. + */ + public Boolean getHasAttachments() { + return hasAttachments; + } + + public void setHasAttachments(Boolean hasAttachments) { + this.hasAttachments = hasAttachments; + } + + /** + * The Internet Message Id. + */ + public String getInternetMessageId() { + return internetMessageId; + } + + public void setInternetMessageId(String internetMessageId) { + this.internetMessageId = internetMessageId; + } + + /** + * Unique identifier for the message. + */ + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * The Subject. + */ + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + /** + * The Body. + */ + public ItemBody getBody() { + return body; + } + + public void setBody(ItemBody body) { + this.body = body; + } + + /** + * The Body Preview. + */ + public String getBodyPreview() { + return bodyPreview; + } + + public void setBodyPreview(String bodyPreview) { + this.bodyPreview = bodyPreview; + } + + /** + * The Importance. + */ + public Importance getImportance() { + return importance; + } + + public void setImportance(Importance importance) { + this.importance = importance; + } + + /** + * The Parent Folder Id. + */ + public String getParentFolderId() { + return parentFolderId; + } + + public void setParentFolderId(String parentFolderId) { + this.parentFolderId = parentFolderId; + } + + /** + * The Sender. + */ + public Recipient getSender() { + return sender; + } + + public void setSender(Recipient sender) { + this.sender = sender; + } + + /** + * The From. + */ + public Recipient getFrom() { + return from; + } + + public void setFrom(Recipient from) { + this.from = from; + } + + /** + * The To Recipients. + */ + public java.util.List getToRecipients() { + return toRecipients; + } + + public void setToRecipients(java.util.List toRecipients) { + this.toRecipients = toRecipients; + } + + /** + * The Cc Recipients. + */ + public java.util.List getCcRecipients() { + return ccRecipients; + } + + public void setCcRecipients(java.util.List ccRecipients) { + this.ccRecipients = ccRecipients; + } + + /** + * The categories associated with the message. + */ + public java.util.List getCategories() { + return categories; + } + + public void setCategories(java.util.List categories) { + this.categories = categories; + } + + /** + * The Bcc Recipients. + */ + public java.util.List getBccRecipients() { + return bccRecipients; + } + + public void setBccRecipients(java.util.List bccRecipients) { + this.bccRecipients = bccRecipients; + } + + /** + * The Reply To. + */ + public java.util.List getReplyTo() { + return replyTo; + } + + public void setReplyTo(java.util.List replyTo) { + this.replyTo = replyTo; + } + + /** + * The version of the message. + */ + public String getChangeKey() { + return changeKey; + } + + public void setChangeKey(String changeKey) { + this.changeKey = changeKey; + } + + /** + * The Conversation Id. + */ + public String getConversationId() { + return conversationId; + } + + public void setConversationId(String conversationId) { + this.conversationId = conversationId; + } + + /** + * The Is Delivery Receipt Requested. + */ + public Boolean getIsDeliveryReceiptRequested() { + return isDeliveryReceiptRequested; + } + + public void setIsDeliveryReceiptRequested(Boolean deliveryReceiptRequested) { + isDeliveryReceiptRequested = deliveryReceiptRequested; + } + + /** + * The Is Read Receipt Requested. + */ + public Boolean getIsReadReceiptRequested() { + return isReadReceiptRequested; + } + + public void setIsReadReceiptRequested(Boolean readReceiptRequested) { + isReadReceiptRequested = readReceiptRequested; + } + + /** + * The Is Read. + */ + public Boolean getIsRead() { + return isRead; + } + + public void setIsRead(Boolean read) { + isRead = read; + } + + /** + * The Is Draft. + */ + public Boolean getIsDraft() { + return isDraft; + } + + public void setIsDraft(Boolean draft) { + isDraft = draft; + } + + /** + * The Web Link. + */ + public String getWebLink() { + return webLink; + } + + public void setWebLink(String webLink) { + this.webLink = webLink; + } + + /** + * The Inference Classification. + */ + public InferenceClassificationType getInferenceClassification() { + return inferenceClassification; + } + + public void setInferenceClassification(InferenceClassificationType inferenceClassification) { + this.inferenceClassification = inferenceClassification; + } + + /** + * The Unique Body. + */ + public ItemBody getUniqueBody() { + return uniqueBody; + } + + public void setUniqueBody(ItemBody uniqueBody) { + this.uniqueBody = uniqueBody; + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Messages.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Messages.java new file mode 100644 index 000000000..764c58935 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Messages.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Messages { + @JsonProperty("@odata.nextLink") + private String nextLink; + + private java.util.List value; + + public java.util.List getValue() { + return value; + } + + public void setValue(java.util.List value) { + this.value = value; + } + + public String getNextLink() { + return nextLink; + } + + public void setNextLink(String nextLink) { + this.nextLink = nextLink; + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Microsoft.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Microsoft.java index c0304b9dd..e2f0d8f9f 100644 --- a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Microsoft.java +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Microsoft.java @@ -7,6 +7,9 @@ package com.microsoft.azure.msgraph.api; public interface Microsoft { - UserOperations userOperations(); + + MailOperations mailOperations(); + + CustomOperations customOperations(); } diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Recipient.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Recipient.java new file mode 100644 index 000000000..13ccf7f9c --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/Recipient.java @@ -0,0 +1,22 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api; + +public class Recipient { + private EmailAddress emailAddress; + + /** + * The Email Address. + */ + public EmailAddress getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(EmailAddress emailAddress) { + this.emailAddress = emailAddress; + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/User.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/User.java index 00c07d982..9d8d07f38 100644 --- a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/User.java +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/User.java @@ -29,30 +29,6 @@ public void setId(String id) { this.id = id; } - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public String getJobTitle() { - return jobTitle; - } - - public void setJobTitle(String jobTitle) { - this.jobTitle = jobTitle; - } - - public String getMail() { - return mail; - } - - public void setMail(String mail) { - this.mail = mail; - } - public List getBusinessPhones() { return businessPhones; } @@ -61,12 +37,20 @@ public void setBusinessPhones(List businessPhones) { this.businessPhones = businessPhones; } + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + public String getSurname() { return surname; } - public void setSurname(String surName) { - this.surname = surName; + public void setSurname(String surname) { + this.surname = surname; } public String getGivenName() { @@ -77,6 +61,14 @@ public void setGivenName(String givenName) { this.givenName = givenName; } + public String getJobTitle() { + return jobTitle; + } + + public void setJobTitle(String jobTitle) { + this.jobTitle = jobTitle; + } + public String getMobilePhone() { return mobilePhone; } @@ -101,6 +93,14 @@ public void setPreferredLanguage(String preferredLanguage) { this.preferredLanguage = preferredLanguage; } + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + public String getUserPrincipalName() { return userPrincipalName; } diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/CustomTemplate.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/CustomTemplate.java new file mode 100644 index 000000000..8696d67d6 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/CustomTemplate.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api.impl; + +import com.microsoft.azure.msgraph.api.CustomOperations; +import org.springframework.web.client.RestTemplate; + +import java.net.URI; + +public class CustomTemplate extends AbstractMicrosoftOperations implements CustomOperations { + private final MicrosoftTemplate microsoft; + + public CustomTemplate(MicrosoftTemplate microsoft, boolean authorized) { + super(authorized); + this.microsoft = microsoft; + } + + @Override + public RestTemplate getRestTemplate() { + return microsoft.getRestTemplate(); + } + + @Override + public URI getGraphAPIURI(String relativePath) { + return microsoft.getGraphAPIURI(relativePath); + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/MailTemplate.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/MailTemplate.java new file mode 100644 index 000000000..f292792ab --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/MailTemplate.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api.impl; + +import com.microsoft.azure.msgraph.api.MailOperations; +import com.microsoft.azure.msgraph.api.Message; +import com.microsoft.azure.msgraph.api.Messages; +import org.springframework.util.MultiValueMap; + +import java.util.HashMap; +import java.util.Map; + +public class MailTemplate extends AbstractMicrosoftOperations implements MailOperations { + private final MicrosoftTemplate microsoft; + + public MailTemplate(MicrosoftTemplate microsoft, boolean authorized) { + super(authorized); + this.microsoft = microsoft; + } + + @Override + public Messages listMessages() { + return listMessages(null, null); + } + + @Override + public Messages listMessages(String mailFolder) { + return listMessages(mailFolder, null); + } + + @Override + public Messages listMessages(MultiValueMap params) { + return listMessages(null, params); + } + + @Override + public Messages listMessages(String mailFolder, MultiValueMap params) { + String uri = null; + if (mailFolder == null) { + uri = "me/messages"; + } else { + uri = "me/mailFolders/" + mailFolder + "/messages"; + } + + if (params != null) { + return microsoft.fetchObject(uri, params, Messages.class); + } else { + return microsoft.fetchObject(uri, Messages.class); + } + } + + @Override + public Messages listMessagesWithNextLink(String nextLink) { + return microsoft.fetchObjectWithAbsolutePath(nextLink, Messages.class); + } + + @Override + public void sendMail(Message message, Boolean saveToSentItems) { + final Map data = new HashMap<>(); + data.put("message", message); + data.put("saveToSentItems", saveToSentItems); + + microsoft.postForObject("me/sendMail", data); + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/MicrosoftTemplate.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/MicrosoftTemplate.java index e67f5e9e8..100dabb17 100644 --- a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/MicrosoftTemplate.java +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/MicrosoftTemplate.java @@ -6,17 +6,24 @@ package com.microsoft.azure.msgraph.api.impl; +import com.microsoft.azure.msgraph.api.CustomOperations; +import com.microsoft.azure.msgraph.api.MailOperations; import com.microsoft.azure.msgraph.api.Microsoft; import com.microsoft.azure.msgraph.api.UserOperations; import org.springframework.social.oauth2.AbstractOAuth2ApiBinding; import org.springframework.social.support.ClientHttpRequestFactorySelector; import org.springframework.social.support.URIBuilder; +import org.springframework.util.MultiValueMap; import java.net.URI; +import java.util.Map; public class MicrosoftTemplate extends AbstractOAuth2ApiBinding implements Microsoft { - private static final String MS_GRAPH_BASE_API = "https://graph.microsoft.com/v1.0/"; + private static final String MS_GRAPH_BASE_API = "https://graph.microsoft.com/"; + private String apiVersion = "v1.0"; private UserOperations userOperations; + private MailOperations mailOperations; + private CustomOperations customOperations; public MicrosoftTemplate() { initialize(); @@ -27,13 +34,36 @@ public MicrosoftTemplate(String accessToken) { initialize(); } - public String getGraphAPI(String path) { - return MS_GRAPH_BASE_API + path; + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + public String getGraphAPI(String relativePath) { + return MS_GRAPH_BASE_API + apiVersion + "/" + relativePath; + } + + public URI getGraphAPIURI(String relativePath) { + return URIBuilder.fromUri(getGraphAPI(relativePath)).build(); + } + + public URI getGraphAPIURI(String relativePath, MultiValueMap params) { + return URIBuilder.fromUri(getGraphAPI(relativePath)).queryParams(params).build(); + } + + public T fetchObjectWithAbsolutePath(String absolutePath, Class type) { + return getRestTemplate().getForObject(URIBuilder.fromUri(absolutePath).build(), type); } public T fetchObject(String objectId, Class type) { - final URI uri = URIBuilder.fromUri(getGraphAPI(objectId)).build(); - return getRestTemplate().getForObject(uri, type); + return getRestTemplate().getForObject(getGraphAPIURI(objectId), type); + } + + public T fetchObject(String objectId, MultiValueMap params, Class type) { + return getRestTemplate().getForObject(getGraphAPIURI(objectId, params), type); + } + + public String postForObject(String objectId, Map data) { + return getRestTemplate().postForObject(getGraphAPIURI(objectId), data, String.class); } @Override @@ -41,6 +71,16 @@ public UserOperations userOperations() { return userOperations; } + @Override + public MailOperations mailOperations() { + return mailOperations; + } + + @Override + public CustomOperations customOperations() { + return customOperations; + } + private void initialize() { super.setRequestFactory(ClientHttpRequestFactorySelector.bufferRequests(getRestTemplate().getRequestFactory())); initSubApis(); @@ -48,5 +88,7 @@ private void initialize() { private void initSubApis() { userOperations = new UserTemplate(this, isAuthorized()); + mailOperations = new MailTemplate(this, isAuthorized()); + customOperations = new CustomTemplate(this, isAuthorized()); } } diff --git a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/UserTemplate.java b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/UserTemplate.java index 53faf6ae8..18cd9f23a 100644 --- a/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/UserTemplate.java +++ b/microsoft-graph/spring-social-microsoft-graph/src/main/java/com/microsoft/azure/msgraph/api/impl/UserTemplate.java @@ -9,9 +9,6 @@ import com.microsoft.azure.msgraph.api.User; import com.microsoft.azure.msgraph.api.UserOperations; -import java.util.List; -import java.util.Map; - public class UserTemplate extends AbstractMicrosoftOperations implements UserOperations { private final MicrosoftTemplate microsoft; @@ -22,46 +19,6 @@ public UserTemplate(MicrosoftTemplate microsoft, boolean authorized) { @Override public User getUserProfile() { - final Map me = microsoft.fetchObject("me", Map.class); - - final User user = new User(); - - if (me.get("id") != null) { - user.setId(String.valueOf(me.get("id"))); - } - if (me.get("displayName") != null) { - user.setDisplayName(String.valueOf(me.get("displayName"))); - } - if (me.get("jobTitle") != null) { - user.setJobTitle(String.valueOf(me.get("jobTitle"))); - } - if (me.get("mail") != null) { - user.setMail(String.valueOf(me.get("mail"))); - } - if (me.get("surname") != null) { - user.setSurname(String.valueOf(me.get("surname"))); - } - if (me.get("givenName") != null) { - user.setGivenName(String.valueOf(me.get("givenName"))); - } - if (me.get("mobilePhone") != null) { - user.setMobilePhone(String.valueOf(me.get("mobilePhone"))); - } - if (me.get("officeLocation") != null) { - user.setOfficeLocation(String.valueOf(me.get("officeLocation"))); - } - if (me.get("preferredLanguage") != null) { - user.setPreferredLanguage(String.valueOf(me.get("preferredLanguage"))); - } - if (me.get("userPrincipalName") != null) { - user.setUserPrincipalName(String.valueOf(me.get("userPrincipalName"))); - } - - final List businessPhones = (List) me.get("businessPhones"); - if (businessPhones != null) { - user.setBusinessPhones(businessPhones); - } - - return user; + return microsoft.fetchObject("me", User.class); } } diff --git a/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/CustomTemplateTest.java b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/CustomTemplateTest.java new file mode 100644 index 000000000..f65e3dfb4 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/CustomTemplateTest.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api.impl; + +import com.microsoft.azure.msgraph.api.impl.custom.Contact; +import com.microsoft.azure.msgraph.api.impl.custom.Contacts; +import org.junit.Test; +import org.springframework.http.MediaType; +import org.springframework.web.client.RestTemplate; + +import java.net.URI; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.http.HttpMethod.GET; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; + +public class CustomTemplateTest extends AbstractMicrosoftApiTest { + @Test + public void getContactsSuccessfully() { + mockServer + .expect(requestTo(microsoft.getGraphAPI("me/contacts"))) + .andExpect(method(GET)) + .andExpect(header("Authorization", "Bearer access token")) + .andRespond(withSuccess(jsonResource("contacts"), MediaType.APPLICATION_JSON)); + + final RestTemplate restTemplate = microsoft.customOperations().getRestTemplate(); + final URI uri = microsoft.customOperations().getGraphAPIURI("me/contacts"); + final Contacts contacts = restTemplate.getForObject(uri, Contacts.class); + + assertThat(contacts.getContacts()).size().isEqualTo(10); + assertThat(contacts.getNextLink()).isEqualTo("https://graph.microsoft.com/v1.0/me/contacts?$skip=10"); + + final Contact contact = contacts.getContacts().get(0); + assertThat(contact.getDisplayName()).isEqualTo("John Doe"); + assertThat(contact.getMobilePhone()).isNull(); + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/MailTemplateTest.java b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/MailTemplateTest.java new file mode 100644 index 000000000..b41cc9614 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/MailTemplateTest.java @@ -0,0 +1,199 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api.impl; + +import com.fasterxml.jackson.databind.util.StdDateFormat; +import com.microsoft.azure.msgraph.api.*; +import org.junit.Test; +import org.springframework.http.MediaType; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.http.HttpMethod.GET; +import static org.springframework.http.HttpMethod.POST; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; + +public class MailTemplateTest extends AbstractMicrosoftApiTest { + + @Test + public void listMessagesSuccessfully() throws ParseException { + mockServer + .expect(requestTo(microsoft.getGraphAPI("me/messages"))) + .andExpect(method(GET)) + .andExpect(header("Authorization", "Bearer access token")) + .andRespond(withSuccess(jsonResource("messages"), MediaType.APPLICATION_JSON)); + + final Messages messages = microsoft.mailOperations().listMessages(); + verifyMessages(messages); + } + + @Test + public void listMessagesWithMailBoxSuccessfully() throws ParseException { + final String folderID = "Inbox"; + + mockServer + .expect(requestTo(microsoft.getGraphAPI("me/mailFolders/" + folderID + "/messages"))) + .andExpect(method(GET)) + .andExpect(header("Authorization", "Bearer access token")) + .andRespond(withSuccess(jsonResource("messages"), MediaType.APPLICATION_JSON)); + + final Messages messages = microsoft.mailOperations().listMessages(folderID); + verifyMessages(messages); + } + + @Test + public void listMessagesWithParamsSuccessfully() throws ParseException { + final MultiValueMap params = new LinkedMultiValueMap(); + final List values = new ArrayList<>(); + values.add("10"); + params.put("$skip", values); + + mockServer + .expect(requestTo(microsoft.getGraphAPI("me/messages?%24skip=10"))) + .andExpect(method(GET)) + .andExpect(header("Authorization", "Bearer access token")) + .andRespond(withSuccess(jsonResource("messages"), MediaType.APPLICATION_JSON)); + + final Messages messages = microsoft.mailOperations().listMessages(params); + verifyMessages(messages); + } + + @Test + public void listMessagesWithMailBoxAndParamsSuccessfully() throws ParseException { + final String folderID = "Inbox"; + + final MultiValueMap params = new LinkedMultiValueMap(); + final List values = new ArrayList<>(); + values.add("10"); + params.put("$skip", values); + + mockServer + .expect(requestTo(microsoft.getGraphAPI("me/mailFolders/Inbox/messages?%24skip=10"))) + .andExpect(method(GET)) + .andExpect(header("Authorization", "Bearer access token")) + .andRespond(withSuccess(jsonResource("messages"), MediaType.APPLICATION_JSON)); + + final Messages messages = microsoft.mailOperations().listMessages(folderID, params); + verifyMessages(messages); + } + + @Test + public void listMessagesWithNextLinkSuccessfully() throws ParseException { + final String nextLink = "https://dummy.com/test"; + + mockServer + .expect(requestTo(nextLink)) + .andExpect(method(GET)) + .andExpect(header("Authorization", "Bearer access token")) + .andRespond(withSuccess(jsonResource("messages"), MediaType.APPLICATION_JSON)); + + final Messages messages = microsoft.mailOperations().listMessagesWithNextLink(nextLink); + verifyMessages(messages); + } + + @Test + public void sendMailSuccessfully() throws ParseException { + final String content = "{\"saveToSentItems\":true,\"message\":{\"subject\":\"Meet for lunch?\"," + + "\"body\":{\"contentType\":\"text\",\"content\":\"The new cafeteria is open.\"},\"" + + "toRecipients\":[{\"emailAddress\":{\"name\":null,\"address\":\"" + + "fannyd@contoso.onmicrosoft.com\"}}]}}"; + mockServer.expect(requestTo(microsoft.getGraphAPI("me/sendMail"))) + .andExpect(method(POST)) + .andExpect(header("Authorization", "Bearer access token")) + .andExpect(content().string(content)) + .andRespond(withSuccess("", MediaType.APPLICATION_JSON)); + + final Message message = new Message(); + message.setSubject("Meet for lunch?"); + + final ItemBody body = new ItemBody(); + body.setContentType(BodyType.text); + body.setContent("The new cafeteria is open."); + message.setBody(body); + + final List recipients = new ArrayList<>(); + final Recipient recipient = new Recipient(); + final EmailAddress emailAddress = new EmailAddress(); + emailAddress.setAddress("fannyd@contoso.onmicrosoft.com"); + recipient.setEmailAddress(emailAddress); + recipients.add(recipient); + message.setToRecipients(recipients); + + microsoft.mailOperations().sendMail(message, true); + } + + private void verifyMessages(Messages messages) throws ParseException { + assertThat(messages.getValue().size()).isEqualTo(2); + + final Message message = messages.getValue().get(0); + assertThat(message.getCreatedDateTime().getTime()). + isEqualTo(new StdDateFormat().parse("2017-07-31T16:20:47Z")); + assertThat(message.getLastModifiedDateTime().getTime()). + isEqualTo(new StdDateFormat().parse("2017-08-08T19:40:47Z")); + assertThat(message.getChangeKey()).isEqualTo("CQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AABh8vwG"); + assertThat(message.getCategories()).isEmpty(); + assertThat(message.getReceivedDateTime().getTime()). + isEqualTo(new StdDateFormat().parse("2017-07-31T16:20:47Z")); + assertThat(message.getSentDateTime().getTime()). + isEqualTo(new StdDateFormat().parse("2017-07-31T11:17:11Z")); + assertThat(message.getHasAttachments()).isFalse(); + assertThat(message.getInternetMessageId()). + isEqualTo(""); + assertThat(message.getSubject()).isEqualTo("Weekly digest: Office 365 changes"); + assertThat(message.getBodyPreview()). + isEqualTo("You have 3 new Office 365 Message center announcements from last week\r\n\r\n\r\n" + + "Organization: MICROSOFT API SANDBOX\r\n Is this digest useful to you? Yes" + + " No Tell us more...\r\nOffice 365 announcements from last week" + + " Edit Message cente"); + assertThat(message.getImportance()).isEqualTo(Importance.normal); + assertThat(message.getParentFolderId()). + isEqualTo("AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI" + + "4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDAAAAA=="); + assertThat(message.getConversationId()).isEqualTo("AAQkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgz" + + "OQAQANhHWVZXoHtImHvs-m5jEbU="); + assertThat(message.getIsDeliveryReceiptRequested()).isNull(); + assertThat(message.getIsReadReceiptRequested()).isFalse(); + assertThat(message.getIsRead()).isFalse(); + assertThat(message.getIsDraft()).isFalse(); + assertThat(message.getWebLink()).isEqualTo("https://outlook.office365.com/owa/?ItemID=AAMkADRmZWM1O" + + "DE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBGAAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez" + + "5BWQCxI9AAAAAAEMAABuW0RzxJhUT4ez5BWQCxI9AABdGgEMAAA%3D&exvsurl=1&viewmodel=ReadMessageItem"); + assertThat(message.getInferenceClassification()).isEqualTo(InferenceClassificationType.focused); + + final ItemBody itemBody = message.getBody(); + assertThat(itemBody.getContentType()).isEqualTo(BodyType.html); + assertThat(itemBody.getContent()).isEqualTo("\r\n\r\n\r\n\r\n"); + + assertThat(message.getSender().getEmailAddress().getAddress()).isEqualTo("o365mc6@microsoft.com"); + assertThat(message.getSender().getEmailAddress().getName()).isEqualTo("Office365 Message Center"); + + assertThat(message.getFrom().getEmailAddress().getAddress()).isEqualTo("o365mc6@microsoft.com"); + assertThat(message.getFrom().getEmailAddress().getName()).isEqualTo("Office365 Message Center"); + + assertThat(message.getToRecipients().get(0).getEmailAddress().getAddress()). + isEqualTo("annew@CIE493742.onmicrosoft.com"); + assertThat(message.getToRecipients().get(0).getEmailAddress().getName()).isEqualTo("Anne Weiler"); + assertThat(message.getToRecipients().get(1).getEmailAddress().getAddress()). + isEqualTo("kepatel@microsoft.com"); + assertThat(message.getToRecipients().get(1).getEmailAddress().getName()).isEqualTo("Keyur Patel"); + + assertThat(message.getCcRecipients()).size().isEqualTo(0); + assertThat(message.getBccRecipients()).size().isEqualTo(0); + assertThat(message.getReplyTo()).size().isEqualTo(0); + + assertThat(message.getId()).isEqualTo("AAMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBG" + + "AAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez5BWQCxI9AAAAAAEMAABuW0RzxJhUT4ez5BWQCxI" + + "9AABdGgEMAAA="); + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/custom/Contact.java b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/custom/Contact.java new file mode 100644 index 000000000..4185f4da9 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/custom/Contact.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ + +package com.microsoft.azure.msgraph.api.impl.custom; + +public class Contact { + + private String displayName; + private String mobilePhone; + + /** + * The Display Name. + */ + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * The Mobile Phone. + */ + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/custom/Contacts.java b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/custom/Contacts.java new file mode 100644 index 000000000..92454ab09 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/test/java/com/microsoft/azure/msgraph/api/impl/custom/Contacts.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for + * license information. + */ +package com.microsoft.azure.msgraph.api.impl.custom; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Contacts { + @JsonProperty("value") + private java.util.List contacts; + + @JsonProperty("@odata.nextLink") + private String nextLink; + + public java.util.List getContacts() { + return contacts; + } + + public void setContacts(java.util.List contacts) { + this.contacts = contacts; + } + + /** + * The url to the next page of this collection, or null + */ + public String getNextLink() { + return nextLink; + } + + public void setNextLink(String nextLink) { + this.nextLink = nextLink; + } +} diff --git a/microsoft-graph/spring-social-microsoft-graph/src/test/resources/contacts.json b/microsoft-graph/spring-social-microsoft-graph/src/test/resources/contacts.json new file mode 100644 index 000000000..cb68c9189 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/test/resources/contacts.json @@ -0,0 +1,500 @@ +{ + "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('16f5a7b6-5a15-4568-aa5a-31bb117e9967')/contacts", + "@odata.nextLink": "https://graph.microsoft.com/v1.0/me/contacts?$skip=10", + "value": [ + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AABHMkiX\"", + "id": "AAMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBGAAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez5BWQCxI9AAAAAAEOAABuW0RzxJhUT4ez5BWQCxI9AABHJG_BAAA=", + "createdDateTime": "2017-06-27T20:28:43Z", + "lastModifiedDateTime": "2017-06-27T20:28:43Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AABHMkiX", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Doe, John", + "displayName": "John Doe", + "givenName": "John", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Doe", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [], + "jobTitle": null, + "companyName": null, + "department": null, + "officeLocation": null, + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "john.doe@contoso.microsoft.com", + "address": "john.doe@contoso.microsoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAgyyBC\"", + "id": "AAMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBGAAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez5BWQCxI9AAAAAAEOAABuW0RzxJhUT4ez5BWQCxI9AAAgw6ajAAA=", + "createdDateTime": "2017-05-01T03:50:09Z", + "lastModifiedDateTime": "2017-05-01T03:50:09Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAgyyBC", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "", + "displayName": "Pavel Bansky", + "givenName": "Pavel", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Bansky", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [], + "jobTitle": null, + "companyName": null, + "department": null, + "officeLocation": null, + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "+1 732 555 0102" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Pavel Bansky", + "address": "pavelb@fabrikam.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAgyyBD\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhNQAAAA==", + "createdDateTime": "2017-03-15T07:48:55Z", + "lastModifiedDateTime": "2017-05-01T20:09:39Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAgyyBD", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Steiner, Alan", + "displayName": "Alan Steiner", + "givenName": "Alan", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Steiner", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:AlanS@CIE493742.onmicrosoft.com" + ], + "jobTitle": "VP Corporate Affairs", + "companyName": null, + "department": "Corporate Affairs", + "officeLocation": "4187", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550129" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Alan Steiner", + "address": "AlanS@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBl\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhNAAAAA==", + "createdDateTime": "2017-03-15T07:48:54Z", + "lastModifiedDateTime": "2017-04-25T22:17:15Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBl", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Thomber, Alicia", + "displayName": "Alicia Thomber", + "givenName": "Alicia", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Thomber", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:AliciaT@CIE493742.onmicrosoft.com" + ], + "jobTitle": "CFO", + "companyName": null, + "department": "Executive", + "officeLocation": "4129", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550060" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Alicia Thomber", + "address": "AliciaT@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBm\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhMwAAAA==", + "createdDateTime": "2017-03-15T07:48:54Z", + "lastModifiedDateTime": "2017-04-25T22:17:15Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBm", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Bellew, Allie", + "displayName": "Allie Bellew", + "givenName": "Allie", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Bellew", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:AllieB@CIE493742.onmicrosoft.com" + ], + "jobTitle": "Marketing Manager", + "companyName": null, + "department": "Marketing", + "officeLocation": "4083", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550134" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Allie Bellew", + "address": "AllieB@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBn\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhMgAAAA==", + "createdDateTime": "2017-03-15T07:48:53Z", + "lastModifiedDateTime": "2017-04-25T22:17:15Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBn", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Alberts, Amy", + "displayName": "Amy Alberts", + "givenName": "Amy", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Alberts", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:AmyA@CIE493742.onmicrosoft.com" + ], + "jobTitle": "VP Human Resources", + "companyName": null, + "department": "Human Resources", + "officeLocation": "4127", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550070" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Amy Alberts", + "address": "AmyA@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEB6\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhMQAAAA==", + "createdDateTime": "2017-03-15T07:48:53Z", + "lastModifiedDateTime": "2017-04-25T22:17:23Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEB6", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Weiler, Anne", + "displayName": "Anne Weiler", + "givenName": "Anne", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Weiler", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:AnneW@CIE493742.onmicrosoft.com" + ], + "jobTitle": "Manufacturing Lead", + "companyName": null, + "department": "Manufacturing", + "officeLocation": "4005", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550105" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Anne Weiler", + "address": "AnneW@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBo\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhMAAAAA==", + "createdDateTime": "2017-03-15T07:48:52Z", + "lastModifiedDateTime": "2017-04-25T22:17:16Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBo", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Grilo, Carlos", + "displayName": "Carlos Grilo", + "givenName": "Carlos", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Grilo", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:CarlosG@CIE493742.onmicrosoft.com" + ], + "jobTitle": "Customer Call Center Manager", + "companyName": null, + "department": "Sales Operations", + "officeLocation": "4011", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550169" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Carlos Grilo", + "address": "CarlosG@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBp\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhLwAAAA==", + "createdDateTime": "2017-03-15T07:48:51Z", + "lastModifiedDateTime": "2017-04-25T22:17:16Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBp", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Geller, Christa", + "displayName": "Christa Geller", + "givenName": "Christa", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Geller", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:ChristaG@CIE493742.onmicrosoft.com" + ], + "jobTitle": "Recruiting Coordinator", + "companyName": null, + "department": "Human Resources", + "officeLocation": "4259", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550074" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Christa Geller", + "address": "ChristaG@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + }, + { + "@odata.etag": "W/\"EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBq\"", + "id": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkARgAAAwuZXteXVEJLqYcO_ELlrI4HAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAG5bRHPEmFRPh7PkFZALEj0AAAJhLgAAAA==", + "createdDateTime": "2017-03-15T07:48:51Z", + "lastModifiedDateTime": "2017-04-25T22:17:16Z", + "changeKey": "EQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AAAcsEBq", + "categories": [], + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDgAAAA==", + "birthday": null, + "fileAs": "Jump, Dan", + "displayName": "Dan Jump", + "givenName": "Dan", + "initials": null, + "middleName": null, + "nickName": null, + "surname": "Jump", + "title": null, + "yomiGivenName": null, + "yomiSurname": null, + "yomiCompanyName": null, + "generation": null, + "imAddresses": [ + "sip:DanJ@CIE493742.onmicrosoft.com" + ], + "jobTitle": "CEO", + "companyName": null, + "department": "Executive", + "officeLocation": "4251", + "profession": null, + "businessHomePage": null, + "assistantName": null, + "manager": null, + "homePhones": [], + "mobilePhone": null, + "businessPhones": [ + "14255550059" + ], + "spouseName": null, + "personalNotes": "", + "children": [], + "emailAddresses": [ + { + "name": "Dan Jump", + "address": "DanJ@CIE493742.onmicrosoft.com" + } + ], + "homeAddress": {}, + "businessAddress": {}, + "otherAddress": {} + } + ] +} \ No newline at end of file diff --git a/microsoft-graph/spring-social-microsoft-graph/src/test/resources/messages.json b/microsoft-graph/spring-social-microsoft-graph/src/test/resources/messages.json new file mode 100644 index 000000000..e306fcec0 --- /dev/null +++ b/microsoft-graph/spring-social-microsoft-graph/src/test/resources/messages.json @@ -0,0 +1,120 @@ +{ + "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(message)", + "@odata.nextLink": "https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/delta?$skiptoken=LztZwWjo5IivWBhyxw5rAA1S4MGf0pD-PKJXi-S8N__-XgkPq5AwVIFbnKz0SLIm2VgskmyW0SNZqDfpsEby3yjICvW2KUkgNiUYRyIbDdo.rj63TyjlH4qCtEN7ZqUFoVZzvxBvrVS4DqrTU32slVw", + "value": [ + { + "@odata.type": "#microsoft.graph.message", + "@odata.etag": "W/\"CQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AABh8vwG\"", + "createdDateTime": "2017-07-31T16:20:47Z", + "lastModifiedDateTime": "2017-08-08T19:40:47Z", + "changeKey": "CQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AABh8vwG", + "categories": [], + "receivedDateTime": "2017-07-31T16:20:47Z", + "sentDateTime": "2017-07-31T11:17:11Z", + "hasAttachments": false, + "internetMessageId": "", + "subject": "Weekly digest: Office 365 changes", + "bodyPreview": "You have 3 new Office 365 Message center announcements from last week\r\n\r\n\r\nOrganization: MICROSOFT API SANDBOX\r\n Is this digest useful to you? Yes No Tell us more...\r\nOffice 365 announcements from last week Edit Message cente", + "importance": "normal", + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDAAAAA==", + "conversationId": "AAQkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQAQANhHWVZXoHtImHvs-m5jEbU=", + "isDeliveryReceiptRequested": null, + "isReadReceiptRequested": false, + "isRead": false, + "isDraft": false, + "webLink": "https://outlook.office365.com/owa/?ItemID=AAMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBGAAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez5BWQCxI9AAAAAAEMAABuW0RzxJhUT4ez5BWQCxI9AABdGgEMAAA%3D&exvsurl=1&viewmodel=ReadMessageItem", + "inferenceClassification": "focused", + "body": { + "contentType": "html", + "content": "\r\n\r\n\r\n\r\n" + }, + "sender": { + "emailAddress": { + "name": "Office365 Message Center", + "address": "o365mc6@microsoft.com" + } + }, + "from": { + "emailAddress": { + "name": "Office365 Message Center", + "address": "o365mc6@microsoft.com" + } + }, + "toRecipients": [ + { + "emailAddress": { + "name": "Anne Weiler", + "address": "annew@CIE493742.onmicrosoft.com" + } + }, + { + "emailAddress": { + "name": "Keyur Patel", + "address": "kepatel@microsoft.com" + } + } + ], + "ccRecipients": [], + "bccRecipients": [], + "replyTo": [], + "id": "AAMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBGAAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez5BWQCxI9AAAAAAEMAABuW0RzxJhUT4ez5BWQCxI9AABdGgEMAAA=" + }, + { + "@odata.type": "#microsoft.graph.message", + "@odata.etag": "W/\"CQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AABeqACG\"", + "createdDateTime": "2017-07-24T16:36:01Z", + "lastModifiedDateTime": "2017-08-02T13:10:48Z", + "changeKey": "CQAAABYAAABuW0RzxJhUT4ez5BWQCxI9AABeqACG", + "categories": [], + "receivedDateTime": "2017-07-24T16:36:01Z", + "sentDateTime": "2017-07-24T11:31:28Z", + "hasAttachments": false, + "internetMessageId": "", + "subject": "Weekly digest: Office 365 changes", + "bodyPreview": "You have 4 new Office 365 Message center announcements from last week\r\n\r\n\r\nOrganization: MICROSOFT API SANDBOX\r\n Is this digest useful to you? Yes No Tell us more...\r\nOffice 365 announcements from last week Edit Message cente", + "importance": "normal", + "parentFolderId": "AQMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgAMzkALgAAAwuZXteXVEJLqYcO_ELlrI4BAG5bRHPEmFRPh7PkFZALEj0AAAIBDAAAAA==", + "conversationId": "AAQkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQAQADvrpBLtvvhMl7_QM-bbaJ4=", + "isDeliveryReceiptRequested": null, + "isReadReceiptRequested": false, + "isRead": false, + "isDraft": false, + "webLink": "https://outlook.office365.com/owa/?ItemID=AAMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBGAAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez5BWQCxI9AAAAAAEMAABuW0RzxJhUT4ez5BWQCxI9AABYT96wAAA%3D&exvsurl=1&viewmodel=ReadMessageItem", + "inferenceClassification": "focused", + "body": { + "contentType": "html", + "content": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n

\r\n

\r\nYou have 4 new Office 365 Message center announcements from last week

\r\n

\r\nOrganization: MICROSOFT API SANDBOX\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
Is this digest useful to you?\r\nYes\r\nNo\r\nTell us more...\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\nOffice 365 announcements from last week Edit Message center preferences\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
Jul 20Planned Maintenance: Yammer databases
\r\nWe're making some changes to Yammer databases. Yammer will perform an online migration of certain master/leader databases from Yammer operated data centers to Azure. This maintenance will upgrade the databases' software and will enable similar upgrades\r\n in the future without downtime. We're promoting replica on a number of databases in Azure to be a master on the following date: Starting 2017-07-29 17:00 (UTC) Ending 2017-07-29 19:00 (UTC)More\r\n ...
\r\nMC110397 Like | Dislike
Jul 19New feature: Skype for Business Call Analytics Preview
\r\nCall Analytics in Skype for Business is a new Office 365 feature that is now available for preview. This message is associated with Office 365 Roadmap ID 16253.More\r\n ...
\r\nMC109709 Like | Dislike
Jul 18Updated feature: Office 365 Groups Owners
\r\nWe’re increasing the number of owners that can exist on an Office 365 Group. You’ll begin seeing this updated feature in the coming days. This message is associated with Office 365 Roadmap ID 20326. While our goal is to ensure that we notify you in advance\r\n of upcoming changes, we acknowledge that we did not provide timely notice for this change. We will continue to look for ways to improve our notifications.More\r\n ...
\r\nMC110106 Like | Dislike
Jul 18New feature: Column creation in modern SharePoint lists and libraries
\r\nWe're improving the column creation experience in modern SharePoint Online lists and libraries. You’ll begin seeing this new feature in the coming days.More\r\n ...
\r\nMC110033 Like | Dislike
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
See all my messages on Office 365 message center  \r\n\r\n
\r\nThanks,
\r\nThe Microsoft Office 365 team
\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n
This admin digest email is personalized for your organization and reflects your individual preferences. To customize what's included in this email and who gets it,\r\n\r\nset your Message center preferences.
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
Microsoft Corporation
\r\nOne Microsoft Way
\r\nRedmond, WA 98052
\r\nUSA
© 2016 Microsoft Corporation
Privacy |\r\n\r\nUnsubscribe
\r\n\r\n\r\n\r\n" + }, + "sender": { + "emailAddress": { + "name": "Office365 Message Center", + "address": "o365mc6@microsoft.com" + } + }, + "from": { + "emailAddress": { + "name": "Office365 Message Center", + "address": "o365mc6@microsoft.com" + } + }, + "toRecipients": [ + { + "emailAddress": { + "name": "Anne Weiler", + "address": "annew@CIE493742.onmicrosoft.com" + } + }, + { + "emailAddress": { + "name": "Keyur Patel", + "address": "kepatel@microsoft.com" + } + } + ], + "ccRecipients": [], + "bccRecipients": [], + "replyTo": [], + "id": "AAMkADRmZWM1ODE4LWQ4YWItNDlkYS1iZTY4LWVhZWEzYjRlODgzOQBGAAAAAAALmV7Xl1RCS6mHDvhC5ayOBwBuW0RzxJhUT4ez5BWQCxI9AAAAAAEMAABuW0RzxJhUT4ez5BWQCxI9AABYT96wAAA=" + } + ] +} \ No newline at end of file