Search in sources :

Example 1 with ISerializer

use of com.microsoft.graph.serializer.ISerializer in project msgraph-sdk-java by microsoftgraph.

the class GraphServiceClientTest method testOverrideOfSerializer.

@Test
public void testOverrideOfSerializer() {
    ISerializer serializer = new ISerializer() {

        @Override
        public <T> String serializeObject(T serializableObject) {
            return null;
        }

        @Override
        public <T> T deserializeObject(String inputString, Class<T> clazz, Map<String, List<String>> responseHeaders) {
            return null;
        }

        @Override
        public <T> T deserializeObject(String inputString, Class<T> clazz) {
            return null;
        }
    };
    IGraphServiceClient client = // 
    GraphServiceClient.builder().authenticationProvider(// 
    auth).serializer(// 
    serializer).buildClient();
    assertEquals(serializer, client.getSerializer());
    assertEquals(auth, client.getAuthenticationProvider());
    assertNotNull(client.getHttpProvider());
    assertNotNull(client.getLogger());
    assertNotNull(client.getExecutors());
    assertEquals(serializer, ((DefaultHttpProvider) client.getHttpProvider()).getSerializer());
}
Also used : Map(java.util.Map) ISerializer(com.microsoft.graph.serializer.ISerializer) IGraphServiceClient(com.microsoft.graph.models.extensions.IGraphServiceClient) Test(org.junit.Test)

Example 2 with ISerializer

use of com.microsoft.graph.serializer.ISerializer in project msgraph-sdk-java by microsoftgraph.

the class BaseCollectionPageTests method testRawObject.

@Test
public void testRawObject() {
    ISerializer serializer = new MockSerializer(null, null);
    JsonObject jsonObject = new JsonObject();
    assertNull(baseCollectionPage.getRawObject());
    assertNull(baseCollectionPage.getSerializer());
    baseCollectionPage.setRawObject(serializer, jsonObject);
    assertNotNull(baseCollectionPage.getRawObject());
    assertNotNull(baseCollectionPage.getSerializer());
    assertEquals(serializer, baseCollectionPage.getSerializer());
    assertEquals(jsonObject, baseCollectionPage.getRawObject());
}
Also used : MockSerializer(com.microsoft.graph.serializer.MockSerializer) JsonObject(com.google.gson.JsonObject) ISerializer(com.microsoft.graph.serializer.ISerializer) Test(org.junit.Test)

Example 3 with ISerializer

use of com.microsoft.graph.serializer.ISerializer in project msgraph-sdk-java by microsoftgraph.

the class ReferenceRequestBodyTests method testRawObject.

@Test
public void testRawObject() {
    ReferenceRequestBody body = new ReferenceRequestBody(null);
    ISerializer serializer = new MockSerializer(null, null);
    JsonObject jsonObject = new JsonObject();
    body.setRawObject(serializer, jsonObject);
    assertEquals(serializer, body.getSerializer());
    assertEquals(jsonObject, body.getRawObject());
}
Also used : MockSerializer(com.microsoft.graph.serializer.MockSerializer) JsonObject(com.google.gson.JsonObject) ISerializer(com.microsoft.graph.serializer.ISerializer) Test(org.junit.Test)

Aggregations

ISerializer (com.microsoft.graph.serializer.ISerializer)3 Test (org.junit.Test)3 JsonObject (com.google.gson.JsonObject)2 MockSerializer (com.microsoft.graph.serializer.MockSerializer)2 IGraphServiceClient (com.microsoft.graph.models.extensions.IGraphServiceClient)1 Map (java.util.Map)1