Search in sources :

Example 1 with AttachmentCollectionResponse

use of com.microsoft.graph.requests.AttachmentCollectionResponse in project msgraph-sdk-java by microsoftgraph.

the class CollectionPageSerializerTests method testAttachmentCollectionPageSerialization.

@Test
public void testAttachmentCollectionPageSerialization() throws Exception {
    String expectedString = "[{\"contentBytes\":\"ZGF0YQ==\",\"name\":\"document.pdf\",\"@odata.type\":\"#microsoft.graph.fileAttachment\",\"id\":\"54321\"},{\"item\":{\"end\":{\"dateTime\":\"2018-11-18T07:30:26.544Z\",\"timeZone\":\"UTC\"},\"start\":{\"dateTime\":\"2018-10-16T06:15:26.544Z\",\"timeZone\":\"UTC\"},\"subject\":\"Test Event Subject\",\"@odata.type\":\"microsoft.graph.event\",\"id\":\"1234\"},\"name\":\"Holiday event\",\"@odata.type\":\"#microsoft.graph.itemAttachment\"},{\"item\":{\"displayName\":\"displayname\",\"mobilePhone\":\"123456890\",\"@odata.type\":\"microsoft.graph.contact\"},\"name\":\"Attachment name\",\"@odata.type\":\"#microsoft.graph.itemAttachment\"}]";
    AttachmentCollectionResponse response = new AttachmentCollectionResponse();
    response.value = Arrays.asList(getFileAttachment(), getItemAttachmentWithEvent(), getItemAttachmentWithContact());
    AttachmentCollectionPage attachmentCollectionPage = new AttachmentCollectionPage(response, null);
    JsonElement serializedJson = CollectionPageSerializer.serialize(attachmentCollectionPage, logger);
    logger.logDebug(serializedJson.toString());
    assertEquals(expectedString, serializedJson.toString());
}
Also used : AttachmentCollectionPage(com.microsoft.graph.requests.AttachmentCollectionPage) AttachmentCollectionResponse(com.microsoft.graph.requests.AttachmentCollectionResponse) JsonElement(com.google.gson.JsonElement) Test(org.junit.jupiter.api.Test)

Example 2 with AttachmentCollectionResponse

use of com.microsoft.graph.requests.AttachmentCollectionResponse in project msgraph-sdk-java by microsoftgraph.

the class OutlookTests method sendEventWithAttachment.

@Test
public void sendEventWithAttachment() throws Exception {
    TestBase testBase = new TestBase();
    Event event = getEvent();
    event.body = getItemBody();
    event.hasAttachments = true;
    AttachmentCollectionResponse response = new AttachmentCollectionResponse();
    response.value = Arrays.asList(getFileAttachment(), getItemAttachmentWithContact());
    event.attachments = new AttachmentCollectionPage(response, null);
    Event eventResponse = testBase.graphClient.me().events().buildRequest().post(event);
    assertNotNull(eventResponse);
}
Also used : AttachmentCollectionPage(com.microsoft.graph.requests.AttachmentCollectionPage) AttachmentCollectionResponse(com.microsoft.graph.requests.AttachmentCollectionResponse) Event(com.microsoft.graph.models.Event) Test(org.junit.jupiter.api.Test)

Example 3 with AttachmentCollectionResponse

use of com.microsoft.graph.requests.AttachmentCollectionResponse in project msgraph-beta-sdk-java by microsoftgraph.

the class CollectionPageSerializerTests method testAttachmentCollectionPageSerialization.

@Test
public void testAttachmentCollectionPageSerialization() throws Exception {
    String expectedString = "[{\"contentBytes\":\"ZGF0YQ==\",\"name\":\"document.pdf\",\"@odata.type\":\"#microsoft.graph.fileAttachment\",\"id\":\"54321\"},{\"item\":{\"end\":{\"dateTime\":\"2018-11-18T07:30:26.544Z\",\"timeZone\":\"UTC\"},\"start\":{\"dateTime\":\"2018-10-16T06:15:26.544Z\",\"timeZone\":\"UTC\"},\"subject\":\"Test Event Subject\",\"@odata.type\":\"microsoft.graph.event\",\"id\":\"1234\"},\"name\":\"Holiday event\",\"@odata.type\":\"#microsoft.graph.itemAttachment\"},{\"item\":{\"displayName\":\"displayname\",\"officeLocation\":\"Montreal\",\"@odata.type\":\"microsoft.graph.contact\"},\"name\":\"Attachment name\",\"@odata.type\":\"#microsoft.graph.itemAttachment\"}]";
    AttachmentCollectionResponse response = new AttachmentCollectionResponse();
    response.value = Arrays.asList(getFileAttachment(), getItemAttachmentWithEvent(), getItemAttachmentWithContact());
    AttachmentCollectionPage attachmentCollectionPage = new AttachmentCollectionPage(response, null);
    JsonElement serializedJson = CollectionPageSerializer.serialize(attachmentCollectionPage, logger);
    logger.logDebug(serializedJson.toString());
    assertEquals(expectedString, serializedJson.toString());
}
Also used : AttachmentCollectionPage(com.microsoft.graph.requests.AttachmentCollectionPage) AttachmentCollectionResponse(com.microsoft.graph.requests.AttachmentCollectionResponse) JsonElement(com.google.gson.JsonElement) Test(org.junit.jupiter.api.Test)

Example 4 with AttachmentCollectionResponse

use of com.microsoft.graph.requests.AttachmentCollectionResponse in project msgraph-sdk-java by microsoftgraph.

the class OutlookTests method sendEmailWithAttachment.

@Test
public void sendEmailWithAttachment() throws Exception {
    TestBase testBase = new TestBase();
    Message message = getMessage();
    message.hasAttachments = true;
    AttachmentCollectionResponse response = new AttachmentCollectionResponse();
    response.value = Arrays.asList(getFileAttachment(), getItemAttachmentWithEvent(), getItemAttachmentWithContact());
    message.attachments = new AttachmentCollectionPage(response, null);
    testBase.graphClient.me().sendMail(UserSendMailParameterSet.newBuilder().withMessage(message).withSaveToSentItems(true).build()).buildRequest().post();
}
Also used : AttachmentCollectionPage(com.microsoft.graph.requests.AttachmentCollectionPage) Message(com.microsoft.graph.models.Message) AttachmentCollectionResponse(com.microsoft.graph.requests.AttachmentCollectionResponse) Test(org.junit.jupiter.api.Test)

Example 5 with AttachmentCollectionResponse

use of com.microsoft.graph.requests.AttachmentCollectionResponse in project msgraph-beta-sdk-java by microsoftgraph.

the class OutlookTests method sendEmailWithAttachment.

@Test
public void sendEmailWithAttachment() throws Exception {
    TestBase testBase = new TestBase();
    Message message = getMessage();
    message.hasAttachments = true;
    AttachmentCollectionResponse response = new AttachmentCollectionResponse();
    response.value = Arrays.asList(getFileAttachment(), getItemAttachmentWithEvent(), getItemAttachmentWithContact());
    message.attachments = new AttachmentCollectionPage(response, null);
    testBase.graphClient.me().sendMail(UserSendMailParameterSet.newBuilder().withMessage(message).withSaveToSentItems(true).build()).buildRequest().post();
}
Also used : AttachmentCollectionPage(com.microsoft.graph.requests.AttachmentCollectionPage) Message(com.microsoft.graph.models.Message) AttachmentCollectionResponse(com.microsoft.graph.requests.AttachmentCollectionResponse) Test(org.junit.jupiter.api.Test)

Aggregations

AttachmentCollectionPage (com.microsoft.graph.requests.AttachmentCollectionPage)6 AttachmentCollectionResponse (com.microsoft.graph.requests.AttachmentCollectionResponse)6 Test (org.junit.jupiter.api.Test)6 JsonElement (com.google.gson.JsonElement)2 Event (com.microsoft.graph.models.Event)2 Message (com.microsoft.graph.models.Message)2