Search in sources :

Example 16 with ClientException

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

the class DefaultExecutorsTests method testPerformOnForegroundWithClientException.

@Test
public void testPerformOnForegroundWithClientException() {
    final String expectedExceptionMessage = "client exception message";
    final String expectedLogMessage = "Starting foreground task, current active count:0, with exception com.microsoft.graph.core.ClientException: client exception message";
    final ExecutorTestCallback<String> callback = new ExecutorTestCallback<>();
    defaultExecutors.performOnForeground(new ClientException(expectedExceptionMessage, null), callback);
    callback.waitForCompletion();
    assertFalse(callback._successCalled.get());
    assertTrue(callback._failureCalled.get());
    assertEquals(expectedExceptionMessage, callback._exceptionResult.get().getMessage());
    assertEquals(1, mLogger.getLogMessages().size());
    assertTrue(mLogger.hasMessage(expectedLogMessage));
}
Also used : ClientException(com.microsoft.graph.core.ClientException) Test(org.junit.Test)

Aggregations

ClientException (com.microsoft.graph.core.ClientException)16 ICallback (com.microsoft.graph.concurrency.ICallback)10 Test (org.junit.Test)6 InputStream (java.io.InputStream)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 JsonObject (com.google.gson.JsonObject)3 QueryOption (com.microsoft.graph.options.QueryOption)3 HashMap (java.util.HashMap)3 IProgressCallback (com.microsoft.graph.concurrency.IProgressCallback)2 MockExecutors (com.microsoft.graph.concurrency.MockExecutors)2 IDirectoryObjectCollectionWithReferencesPage (com.microsoft.graph.extensions.IDirectoryObjectCollectionWithReferencesPage)2 User (com.microsoft.graph.extensions.User)2 MockLogger (com.microsoft.graph.logger.MockLogger)2 Option (com.microsoft.graph.options.Option)2 MockSerializer (com.microsoft.graph.serializer.MockSerializer)2 BufferedInputStream (java.io.BufferedInputStream)2 IOException (java.io.IOException)2 URL (java.net.URL)2 LinkedList (java.util.LinkedList)2 SharedPreferences (android.content.SharedPreferences)1