Search in sources :

Example 1 with IGraphServiceClient

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

the class GraphServiceClientTest method testOverrideOfHttpSerializer.

@Test
public void testOverrideOfHttpSerializer() {
    IHttpProvider hp = new IHttpProvider() {

        @Override
        public ISerializer getSerializer() {
            return null;
        }

        @Override
        public <Result, BodyType> void send(IHttpRequest request, ICallback<Result> callback, Class<Result> resultClass, BodyType serializable) {
        // do nothing
        }

        @Override
        public <Result, BodyType> Result send(IHttpRequest request, Class<Result> resultClass, BodyType serializable) throws ClientException {
            return null;
        }

        @Override
        public <Result, BodyType, DeserializeType> Result send(IHttpRequest request, Class<Result> resultClass, BodyType serializable, IStatefulResponseHandler<Result, DeserializeType> handler) throws ClientException {
            return null;
        }
    };
    IGraphServiceClient client = // 
    GraphServiceClient.builder().authenticationProvider(// 
    auth).httpProvider(// 
    hp).buildClient();
    assertEquals(hp, client.getHttpProvider());
    assertEquals(auth, client.getAuthenticationProvider());
    assertNotNull(client.getSerializer());
    assertNotNull(client.getLogger());
    assertNotNull(client.getExecutors());
}
Also used : IHttpRequest(com.microsoft.graph.http.IHttpRequest) ICallback(com.microsoft.graph.concurrency.ICallback) IHttpProvider(com.microsoft.graph.http.IHttpProvider) IStatefulResponseHandler(com.microsoft.graph.http.IStatefulResponseHandler) IGraphServiceClient(com.microsoft.graph.models.extensions.IGraphServiceClient) Test(org.junit.Test)

Example 2 with IGraphServiceClient

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

the class GraphServiceClientTest method testOverrideOfDefaultLogger.

@Test
public void testOverrideOfDefaultLogger() {
    ILogger logger = createLogger();
    IGraphServiceClient client = // 
    GraphServiceClient.builder().authenticationProvider(// 
    auth).logger(// 
    logger).buildClient();
    assertEquals(auth, client.getAuthenticationProvider());
    assertNotNull(client.getExecutors());
    assertNotNull(client.getHttpProvider());
    assertNotNull(client.getLogger());
    assertNotNull(client.getSerializer());
    assertEquals(logger, ((DefaultHttpProvider) client.getHttpProvider()).getLogger());
    assertEquals(logger, ((DefaultSerializer) client.getSerializer()).getLogger());
    assertEquals(logger, ((DefaultExecutors) client.getExecutors()).getLogger());
    assertEquals(logger, client.getLogger());
}
Also used : ILogger(com.microsoft.graph.logger.ILogger) IGraphServiceClient(com.microsoft.graph.models.extensions.IGraphServiceClient) Test(org.junit.Test)

Example 3 with IGraphServiceClient

use of com.microsoft.graph.models.extensions.IGraphServiceClient 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 4 with IGraphServiceClient

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

the class GraphServiceClientTest method testClientMethodsReturnStuff.

@Test
public void testClientMethodsReturnStuff() {
    IGraphServiceClient client = GraphServiceClient.fromConfig(new DefaultClientConfig() {

        @Override
        public IAuthenticationProvider getAuthenticationProvider() {
            return auth;
        }
    });
    assertEquals(auth, client.getAuthenticationProvider());
    assertNotNull(client.getExecutors());
    assertNotNull(client.getHttpProvider());
    assertNotNull(client.getLogger());
    assertNotNull(client.getSerializer());
}
Also used : DefaultClientConfig(com.microsoft.graph.core.DefaultClientConfig) IAuthenticationProvider(com.microsoft.graph.authentication.IAuthenticationProvider) IGraphServiceClient(com.microsoft.graph.models.extensions.IGraphServiceClient) Test(org.junit.Test)

Example 5 with IGraphServiceClient

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

the class GraphServiceClientTest method testOverrideOfDefaultExecutors.

@Test
public void testOverrideOfDefaultExecutors() {
    IExecutors ex = new IExecutors() {

        @Override
        public void performOnBackground(Runnable runnable) {
        // do nothing
        }

        @Override
        public <Result> void performOnForeground(Result result, ICallback<Result> callback) {
        // do nothing
        }

        @Override
        public <Result> void performOnForeground(int progress, int progressMax, IProgressCallback<Result> callback) {
        // do nothing
        }

        @Override
        public <Result> void performOnForeground(ClientException exception, ICallback<Result> callback) {
        // do nothing
        }
    };
    IGraphServiceClient client = // 
    GraphServiceClient.builder().authenticationProvider(// 
    auth).executors(// 
    ex).buildClient();
    assertEquals(ex, client.getExecutors());
    assertEquals(auth, client.getAuthenticationProvider());
    assertNotNull(client.getHttpProvider());
    assertNotNull(client.getLogger());
    assertNotNull(client.getSerializer());
    assertEquals(ex, ((DefaultHttpProvider) client.getHttpProvider()).getExecutors());
}
Also used : ICallback(com.microsoft.graph.concurrency.ICallback) IExecutors(com.microsoft.graph.concurrency.IExecutors) ClientException(com.microsoft.graph.core.ClientException) IProgressCallback(com.microsoft.graph.concurrency.IProgressCallback) IGraphServiceClient(com.microsoft.graph.models.extensions.IGraphServiceClient) Test(org.junit.Test)

Aggregations

IGraphServiceClient (com.microsoft.graph.models.extensions.IGraphServiceClient)6 Test (org.junit.Test)6 IAuthenticationProvider (com.microsoft.graph.authentication.IAuthenticationProvider)2 ICallback (com.microsoft.graph.concurrency.ICallback)2 IHttpRequest (com.microsoft.graph.http.IHttpRequest)2 IExecutors (com.microsoft.graph.concurrency.IExecutors)1 IProgressCallback (com.microsoft.graph.concurrency.IProgressCallback)1 ClientException (com.microsoft.graph.core.ClientException)1 DefaultClientConfig (com.microsoft.graph.core.DefaultClientConfig)1 IHttpProvider (com.microsoft.graph.http.IHttpProvider)1 IStatefulResponseHandler (com.microsoft.graph.http.IStatefulResponseHandler)1 ILogger (com.microsoft.graph.logger.ILogger)1 ISerializer (com.microsoft.graph.serializer.ISerializer)1 Map (java.util.Map)1