Search in sources :

Example 1 with FunctionOption

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

the class BaseCollectionRequestTests method testFunctionAndQueryParameters.

@Test
public void testFunctionAndQueryParameters() {
    final Option f1 = new FunctionOption("f1", "fun1");
    final Option f2 = new FunctionOption("f2", null);
    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(f1, f2, q1, q2), null, null) {
    };
    assertEquals("https://a.b.c(f1='fun1',f2=null)?q1=option1+&q2=option2", request.getRequestUrl().toString());
    assertEquals(5, request.getOptions().size());
}
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) Test(org.junit.Test)

Example 2 with FunctionOption

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

the class BaseRequestTests method testFunctionAndQueryParameters.

@Test
public void testFunctionAndQueryParameters() {
    final Option f1 = new FunctionOption("f1", "fun1");
    final Option f2 = new FunctionOption("f2", null);
    final Option q1 = new QueryOption("q1", "option1 ");
    final Option q2 = new QueryOption("q2", "option2");
    final BaseRequest request = new BaseRequest("https://a.b.c", null, Arrays.asList(f1, f2, q1, q2), null) {
    };
    assertEquals("https://a.b.c(f1='fun1',f2=null)?q1=option1+&q2=option2", request.getRequestUrl().toString());
    assertEquals(5, request.getOptions().size());
}
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)

Example 3 with FunctionOption

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

the class BaseRequest method addFunctionParameters.

private String addFunctionParameters() {
    final StringBuilder requestUrl = new StringBuilder(this.requestUrl);
    if (!getFunctionOptions().isEmpty()) {
        requestUrl.append("(");
        for (int i = 0; i < functionOptions.size(); i++) {
            final FunctionOption option = functionOptions.get(i);
            requestUrl.append(option.getName());
            requestUrl.append("=");
            if (option.getValue() != null) {
                if (option.getValue() instanceof String) {
                    requestUrl.append("'" + option.getValue() + "'");
                } else {
                    requestUrl.append(option.getValue());
                }
            } else {
                requestUrl.append("null");
            }
            if (i + 1 < functionOptions.size()) {
                requestUrl.append(",");
            }
        }
        requestUrl.append(")");
    }
    return requestUrl.toString();
}
Also used : FunctionOption(com.microsoft.graph.options.FunctionOption)

Example 4 with FunctionOption

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

the class BaseCollectionRequestTests method testFunctionParameters.

@Test
public void testFunctionParameters() {
    final Option f1 = new FunctionOption("1", "one");
    final Option f2 = new FunctionOption("2", null);
    final BaseCollectionRequest<String, String> request = new BaseCollectionRequest<String, String>("https://a.b.c", null, Arrays.asList(f1, f2), null, null) {
    };
    String urlTest = request.getRequestUrl().toString();
    assertEquals("https://a.b.c(1='one',2=null)", request.getRequestUrl().toString());
    request.addFunctionOption(new FunctionOption("3", "two"));
    ;
    assertEquals("https://a.b.c(1='one',2=null,3='two')", request.getRequestUrl().toString());
    assertEquals(4, request.getOptions().size());
}
Also used : FunctionOption(com.microsoft.graph.options.FunctionOption) QueryOption(com.microsoft.graph.options.QueryOption) Option(com.microsoft.graph.options.Option) FunctionOption(com.microsoft.graph.options.FunctionOption) Test(org.junit.Test)

Example 5 with FunctionOption

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

the class BaseRequestTests method testFunctionParameters.

@Test
public void testFunctionParameters() {
    final Option fo1 = new FunctionOption("1", "one");
    final Option fo2 = new FunctionOption("2", null);
    final BaseRequest request = new BaseRequest("https://a.b.c", null, Arrays.asList(fo1, fo2), null) {
    };
    assertEquals("https://a.b.c(1='one',2=null)", request.getRequestUrl().toString());
    request.addFunctionOption(new FunctionOption("3", "two"));
    ;
    assertEquals("https://a.b.c(1='one',2=null,3='two')", request.getRequestUrl().toString());
    assertEquals(4, request.getOptions().size());
}
Also used : FunctionOption(com.microsoft.graph.options.FunctionOption) 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

FunctionOption (com.microsoft.graph.options.FunctionOption)6 Option (com.microsoft.graph.options.Option)5 QueryOption (com.microsoft.graph.options.QueryOption)5 Test (org.junit.Test)5 HeaderOption (com.microsoft.graph.options.HeaderOption)3