Search in sources :

Example 1 with CustomRequest

use of com.microsoft.graph.http.CustomRequest in project msgraph-sdk-java-core by microsoftgraph.

the class BaseClientTests method testCustomRequest.

@Test
public void testCustomRequest() {
    baseClient.setHttpProvider(new CoreHttpProvider(new DefaultSerializer(mLogger), mLogger, new OkHttpClient.Builder().build()));
    final CustomRequestBuilder<JsonElement> simpleRequestBuilder = baseClient.customRequest("");
    assertNotNull(simpleRequestBuilder);
    final CustomRequestBuilder<String> stringRequestBuilder = baseClient.customRequest("", String.class);
    assertNotNull(stringRequestBuilder);
    final CustomRequest<String> abs = stringRequestBuilder.buildRequest();
    abs.setHttpMethod(HttpMethod.POST);
    final Request nat = abs.getHttpRequest("somestring");
    assertEquals("\"somestring\"", getStringFromRequestBody(nat));
    assertEquals("application", nat.body().contentType().type());
    assertEquals("json", nat.body().contentType().subtype());
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) OkHttpClient(okhttp3.OkHttpClient) JsonElement(com.google.gson.JsonElement) Request(okhttp3.Request) CustomRequest(com.microsoft.graph.http.CustomRequest) CoreHttpProvider(com.microsoft.graph.http.CoreHttpProvider) Test(org.junit.jupiter.api.Test)

Aggregations

JsonElement (com.google.gson.JsonElement)1 CoreHttpProvider (com.microsoft.graph.http.CoreHttpProvider)1 CustomRequest (com.microsoft.graph.http.CustomRequest)1 DefaultSerializer (com.microsoft.graph.serializer.DefaultSerializer)1 OkHttpClient (okhttp3.OkHttpClient)1 Request (okhttp3.Request)1 Test (org.junit.jupiter.api.Test)1