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());
}
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);
}
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);
}
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());
}
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);
}
Aggregations