Search in sources :

Example 1 with CommandCallback

use of com.microsoft.identity.common.internal.commands.CommandCallback in project microsoft-authentication-library-common-for-android by AzureAD.

the class CommandDispatcherTest method testSubmitSilentWithTerminalException.

@Test
public void testSubmitSilentWithTerminalException() {
    final String errorCode = "anError";
    final CountDownLatch testLatch = new CountDownLatch(1);
    CommandDispatcher.submitSilent(new CommandThrowingIErrorInformationException(getEmptyTestParams(), new CommandCallback<String, Exception>() {

        @Override
        public void onCancel() {
            testLatch.countDown();
            Assert.fail();
        }

        @Override
        public void onError(Exception error) {
            Assert.assertEquals(ClientException.class, error.getClass());
            Assert.assertEquals(errorCode, ((ClientException) error).getErrorCode());
            testLatch.countDown();
        }

        @Override
        public void onTaskCompleted(String s) {
            testLatch.countDown();
            Assert.fail();
        }
    }, errorCode));
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) CommandCallback(com.microsoft.identity.common.internal.commands.CommandCallback) TerminalException(com.microsoft.identity.common.exception.TerminalException) ClientException(com.microsoft.identity.common.exception.ClientException) Test(org.junit.Test)

Example 2 with CommandCallback

use of com.microsoft.identity.common.internal.commands.CommandCallback in project microsoft-authentication-library-common-for-android by AzureAD.

the class CommandDispatcherTest method testSubmitSilentWithException.

@Test
public void testSubmitSilentWithException() {
    final CountDownLatch testLatch = new CountDownLatch(1);
    CommandDispatcher.submitSilent(new ExceptionCommand(getEmptyTestParams(), new CommandCallback<String, Exception>() {

        @Override
        public void onCancel() {
            testLatch.countDown();
            Assert.fail();
        }

        @Override
        public void onError(Exception error) {
            testLatch.countDown();
        }

        @Override
        public void onTaskCompleted(String s) {
            testLatch.countDown();
            Assert.fail();
        }
    }));
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) CommandCallback(com.microsoft.identity.common.internal.commands.CommandCallback) TerminalException(com.microsoft.identity.common.exception.TerminalException) ClientException(com.microsoft.identity.common.exception.ClientException) Test(org.junit.Test)

Aggregations

ClientException (com.microsoft.identity.common.exception.ClientException)2 TerminalException (com.microsoft.identity.common.exception.TerminalException)2 CommandCallback (com.microsoft.identity.common.internal.commands.CommandCallback)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2