Search in sources :

Example 6 with QueryOption

use of com.microsoft.graph.options.QueryOption 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 QueryOption

use of com.microsoft.graph.options.QueryOption in project msgraph-sdk-java by microsoftgraph.

the class SharePointTests method testSearch.

@Test
public void testSearch() {
    List<Option> requestOptions = new LinkedList<Option>();
    requestOptions.add(new QueryOption("search", "Contoso"));
    ISiteCollectionPage sites = testBase.graphClient.sites().buildRequest(requestOptions).get();
    assertNotNull(sites);
}
Also used : ISiteCollectionPage(com.microsoft.graph.requests.extensions.ISiteCollectionPage) QueryOption(com.microsoft.graph.options.QueryOption) Option(com.microsoft.graph.options.Option) QueryOption(com.microsoft.graph.options.QueryOption) LinkedList(java.util.LinkedList)

Example 8 with QueryOption

use of com.microsoft.graph.options.QueryOption in project msgraph-sdk-java by microsoftgraph.

the class SharePointTests method setUp.

@Before
public void setUp() {
    testBase = new TestBase();
    List<Option> requestOptions = new LinkedList<Option>();
    requestOptions.add(new QueryOption("search", "Contoso"));
    ISiteCollectionPage sites = testBase.graphClient.sites().buildRequest(requestOptions).get();
    testSite = sites.getCurrentPage().get(0);
}
Also used : ISiteCollectionPage(com.microsoft.graph.requests.extensions.ISiteCollectionPage) QueryOption(com.microsoft.graph.options.QueryOption) Option(com.microsoft.graph.options.Option) QueryOption(com.microsoft.graph.options.QueryOption) LinkedList(java.util.LinkedList)

Example 9 with QueryOption

use of com.microsoft.graph.options.QueryOption in project msgraph-sdk-java by microsoftgraph.

the class BaseCollectionRequestTests method testQueryParameters.

@Test
public void testQueryParameters() {
    final Option q1 = new QueryOption("q1", "option1 ");
    final Option q2 = new QueryOption("q2", "option2");
    final BaseCollectionRequest<String, String> request = new BaseCollectionRequest<String, String>("https://a.b.c", null, Arrays.asList(q1, q2), null, null) {
    };
    assertEquals("https://a.b.c?q1=option1+&q2=option2", request.getRequestUrl().toString());
    request.addQueryOption(new QueryOption("q3", "option3"));
    assertEquals("https://a.b.c?q1=option1+&q2=option2&q3=option3", request.getRequestUrl().toString());
    assertEquals(4, request.getOptions().size());
}
Also used : QueryOption(com.microsoft.graph.options.QueryOption) QueryOption(com.microsoft.graph.options.QueryOption) Option(com.microsoft.graph.options.Option) FunctionOption(com.microsoft.graph.options.FunctionOption) Test(org.junit.Test)

Example 10 with QueryOption

use of com.microsoft.graph.options.QueryOption in project msgraph-sdk-java by microsoftgraph.

the class BaseRequestTests method testProtectedProperties.

@Test
public void testProtectedProperties() {
    assertEquals(0, request.functionOptions.size());
    assertEquals(0, request.queryOptions.size());
    final Option q1 = new QueryOption("q1", "option1 ");
    final Option f1 = new FunctionOption("f1", "option2");
    final BaseRequest request = new BaseRequest("https://a.b.c", null, Arrays.asList(q1, f1), null) {
    };
    assertEquals(1, request.functionOptions.size());
    assertEquals(1, request.queryOptions.size());
    assertEquals("q1", request.queryOptions.get(0).getName());
    assertEquals("option1 ", request.queryOptions.get(0).getValue());
    assertEquals("f1", request.functionOptions.get(0).getName());
    assertEquals("option2", request.functionOptions.get(0).getValue());
}
Also used : FunctionOption(com.microsoft.graph.options.FunctionOption) QueryOption(com.microsoft.graph.options.QueryOption) QueryOption(com.microsoft.graph.options.QueryOption) Option(com.microsoft.graph.options.Option) FunctionOption(com.microsoft.graph.options.FunctionOption) HeaderOption(com.microsoft.graph.options.HeaderOption) Test(org.junit.Test)

Aggregations

QueryOption (com.microsoft.graph.options.QueryOption)11 Option (com.microsoft.graph.options.Option)9 Test (org.junit.Test)6 FunctionOption (com.microsoft.graph.options.FunctionOption)5 LinkedList (java.util.LinkedList)4 ClientException (com.microsoft.graph.core.ClientException)3 HeaderOption (com.microsoft.graph.options.HeaderOption)3 ICallback (com.microsoft.graph.concurrency.ICallback)2 User (com.microsoft.graph.extensions.User)2 ISiteCollectionPage (com.microsoft.graph.requests.extensions.ISiteCollectionPage)2 SharedPreferences (android.content.SharedPreferences)1 DirectoryObject (com.microsoft.graph.extensions.DirectoryObject)1 IDirectoryObjectCollectionWithReferencesPage (com.microsoft.graph.extensions.IDirectoryObjectCollectionWithReferencesPage)1 IUserCollectionPage (com.microsoft.graph.extensions.IUserCollectionPage)1 PasswordProfile (com.microsoft.graph.extensions.PasswordProfile)1 ProfilePhoto (com.microsoft.graph.extensions.ProfilePhoto)1 EmailAddress (com.microsoft.graph.models.extensions.EmailAddress)1 Message (com.microsoft.graph.models.extensions.Message)1 Recipient (com.microsoft.graph.models.extensions.Recipient)1 User (com.microsoft.graph.models.extensions.User)1