Search in sources :

Example 6 with User

use of com.microsoft.graph.models.extensions.User in project msgraph-sdk-java by microsoftgraph.

the class OutlookTests method testSendDraft.

@Test
public void testSendDraft() {
    TestBase testBase = new TestBase();
    // Attempt to identify the sent message via randomly generated subject
    String draftSubject = "Draft Test Message " + Double.toString(Math.random() * 1000);
    User me = testBase.graphClient.me().buildRequest().get();
    Recipient r = new Recipient();
    EmailAddress address = new EmailAddress();
    address.address = me.mail;
    r.emailAddress = address;
    Message message = new Message();
    message.subject = draftSubject;
    ArrayList<Recipient> recipients = new ArrayList<Recipient>();
    recipients.add(r);
    message.toRecipients = recipients;
    message.isDraft = true;
    // Save the message as a draft
    Message newMessage = testBase.graphClient.me().messages().buildRequest().post(message);
    // Send the drafted message
    testBase.graphClient.me().mailFolders("Drafts").messages(newMessage.id).send().buildRequest().post();
    java.util.List<QueryOption> options = new ArrayList<QueryOption>();
    QueryOption o = new QueryOption("$filter", "subject eq '" + draftSubject + "'");
    options.add(o);
    // Check that the sent message exists on the server
    IMessageCollectionPage mcp = testBase.graphClient.me().messages().buildRequest(options).get();
    assertFalse(mcp.getCurrentPage().isEmpty());
}
Also used : User(com.microsoft.graph.models.extensions.User) Message(com.microsoft.graph.models.extensions.Message) IMessageCollectionPage(com.microsoft.graph.requests.extensions.IMessageCollectionPage) ArrayList(java.util.ArrayList) QueryOption(com.microsoft.graph.options.QueryOption) Recipient(com.microsoft.graph.models.extensions.Recipient) EmailAddress(com.microsoft.graph.models.extensions.EmailAddress) Test(org.junit.Test)

Example 7 with User

use of com.microsoft.graph.models.extensions.User in project msgraph-sdk-java by microsoftgraph.

the class CustomRequestTests method testCustomGet.

/**
 * Test GET with a custom request for both serialized and JSON content
 */
@Test
public void testCustomGet() {
    User meOriginal = testBase.graphClient.me().buildRequest().get();
    User meGraphService = testBase.graphClient.customRequest("/me", User.class).buildRequest().get();
    JsonObject meJson = testBase.graphClient.customRequest("/me").buildRequest().get();
    assertEquals(meGraphService.displayName, meOriginal.displayName);
    assertEquals(meJson.get("displayName").getAsString(), meOriginal.displayName);
}
Also used : User(com.microsoft.graph.models.extensions.User) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test)

Aggregations

User (com.microsoft.graph.models.extensions.User)7 Test (org.junit.Test)7 EmailAddress (com.microsoft.graph.models.extensions.EmailAddress)3 ArrayList (java.util.ArrayList)3 JsonElement (com.google.gson.JsonElement)2 Message (com.microsoft.graph.models.extensions.Message)2 Recipient (com.microsoft.graph.models.extensions.Recipient)2 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 MockConnection (com.microsoft.graph.http.MockConnection)1 DefaultLogger (com.microsoft.graph.logger.DefaultLogger)1 PlannerAssignment (com.microsoft.graph.models.extensions.PlannerAssignment)1 PlannerAssignments (com.microsoft.graph.models.extensions.PlannerAssignments)1 PlannerTask (com.microsoft.graph.models.extensions.PlannerTask)1 QueryOption (com.microsoft.graph.options.QueryOption)1 IMessageCollectionPage (com.microsoft.graph.requests.extensions.IMessageCollectionPage)1 IPlannerTaskRequest (com.microsoft.graph.requests.extensions.IPlannerTaskRequest)1 IUserCollectionPage (com.microsoft.graph.requests.extensions.IUserCollectionPage)1 Duration (javax.xml.datatype.Duration)1