Search in sources :

Example 1 with AttachmentCollectionPage

use of com.microsoft.graph.requests.AttachmentCollectionPage 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 AttachmentCollectionPage

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

the class OutlookTests method testAttachments.

@Test
public void testAttachments() throws Exception {
    final TestBase testBase = new TestBase();
    final AttachmentCollectionPage page = testBase.graphClient.me().messages("AAMkADc5NmMyYjUxLTQ0ZDEtNGM3Yi1iY2JkLTgyZWYwZjgzNDI3NwBGAAAAAADVwiXSJFUqQrTdi_SlUV7QBwCD0ThbORwuS5hfVs_PIdoqAAAAAAENAACD0ThbORwuS5hfVs_PIdoqAAZ6u3D_AAA=").attachments().buildRequest().get();
    final List<Attachment> attchs = page.getCurrentPage();
    assertEquals(1, attchs.size());
    assertTrue(attchs.get(0) instanceof FileAttachment);
}
Also used : AttachmentCollectionPage(com.microsoft.graph.requests.AttachmentCollectionPage) FileAttachment(com.microsoft.graph.models.FileAttachment) Attachment(com.microsoft.graph.models.Attachment) FileAttachment(com.microsoft.graph.models.FileAttachment) ItemAttachment(com.microsoft.graph.models.ItemAttachment) Test(org.junit.jupiter.api.Test)

Example 3 with AttachmentCollectionPage

use of com.microsoft.graph.requests.AttachmentCollectionPage 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 4 with AttachmentCollectionPage

use of com.microsoft.graph.requests.AttachmentCollectionPage 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 5 with AttachmentCollectionPage

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

the class OutlookTests method testAttachments.

@Test
public void testAttachments() throws Exception {
    final TestBase testBase = new TestBase();
    final AttachmentCollectionPage page = testBase.graphClient.me().messages("AAMkADc5NmMyYjUxLTQ0ZDEtNGM3Yi1iY2JkLTgyZWYwZjgzNDI3NwBGAAAAAADVwiXSJFUqQrTdi_SlUV7QBwCD0ThbORwuS5hfVs_PIdoqAAAAAAENAACD0ThbORwuS5hfVs_PIdoqAAZ6u3D_AAA=").attachments().buildRequest().get();
    final List<Attachment> attchs = page.getCurrentPage();
    assertEquals(1, attchs.size());
    assertTrue(attchs.get(0) instanceof FileAttachment);
}
Also used : AttachmentCollectionPage(com.microsoft.graph.requests.AttachmentCollectionPage) FileAttachment(com.microsoft.graph.models.FileAttachment) Attachment(com.microsoft.graph.models.Attachment) FileAttachment(com.microsoft.graph.models.FileAttachment) ItemAttachment(com.microsoft.graph.models.ItemAttachment) Test(org.junit.jupiter.api.Test)

Aggregations

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