Search in sources :

Example 1 with BaseException

use of com.microsoft.identity.common.exception.BaseException in project microsoft-authentication-library-common-for-android by AzureAD.

the class BrokerOperationExecutorTests method expectCorruptedBundleException.

private void expectCorruptedBundleException(final List<IIpcStrategy> strategyList) {
    try {
        final BrokerOperationExecutor executor = new BrokerOperationExecutor(strategyList);
        executor.execute(getMockParameter(), getBrokerOperation());
        Assert.fail("Failure is expected.");
    } catch (final BaseException e) {
        Assert.assertTrue(e instanceof ClientException);
        Assert.assertEquals(e.getErrorCode(), CORRUPTED_BUNDLE_ERROR_CODE);
    }
}
Also used : BrokerOperationExecutor(com.microsoft.identity.common.internal.controllers.BrokerOperationExecutor) BaseException(com.microsoft.identity.common.exception.BaseException) ClientException(com.microsoft.identity.common.exception.ClientException)

Example 2 with BaseException

use of com.microsoft.identity.common.exception.BaseException in project microsoft-authentication-library-common-for-android by AzureAD.

the class BrokerOperationExecutorTests method expectServiceException.

private void expectServiceException(final List<IIpcStrategy> strategyList) {
    try {
        final BrokerOperationExecutor executor = new BrokerOperationExecutor(strategyList);
        executor.execute(getMockParameter(), getBrokerOperation());
        Assert.fail("Failure is expected.");
    } catch (final BaseException e) {
        Assert.assertTrue(e instanceof ServiceException);
        Assert.assertEquals(e.getErrorCode(), SERVICE_EXCEPTION_BUNDLE_ERROR_CODE);
    }
}
Also used : BrokerOperationExecutor(com.microsoft.identity.common.internal.controllers.BrokerOperationExecutor) BaseException(com.microsoft.identity.common.exception.BaseException) ServiceException(com.microsoft.identity.common.exception.ServiceException)

Example 3 with BaseException

use of com.microsoft.identity.common.exception.BaseException in project microsoft-authentication-library-common-for-android by AzureAD.

the class BrokerOperationExecutorTests method expectValidResult.

private void expectValidResult(final List<IIpcStrategy> strategyList) {
    try {
        final BrokerOperationExecutor executor = new BrokerOperationExecutor(strategyList);
        Assert.assertTrue(executor.execute(getMockParameter(), getBrokerOperation()));
    } catch (final BaseException e) {
        Assert.fail("Unexpected exception.");
    }
}
Also used : BrokerOperationExecutor(com.microsoft.identity.common.internal.controllers.BrokerOperationExecutor) BaseException(com.microsoft.identity.common.exception.BaseException)

Example 4 with BaseException

use of com.microsoft.identity.common.exception.BaseException in project microsoft-authentication-library-common-for-android by AzureAD.

the class BrokerOperationExecutorTests method expectUserCancelledException.

private void expectUserCancelledException(final List<IIpcStrategy> strategyList) {
    try {
        final BrokerOperationExecutor executor = new BrokerOperationExecutor(strategyList);
        executor.execute(getMockParameter(), getBrokerOperation());
        Assert.fail("Failure is expected.");
    } catch (final BaseException e) {
        Assert.assertTrue(e instanceof UserCancelException);
    }
}
Also used : BrokerOperationExecutor(com.microsoft.identity.common.internal.controllers.BrokerOperationExecutor) BaseException(com.microsoft.identity.common.exception.BaseException) UserCancelException(com.microsoft.identity.common.exception.UserCancelException)

Example 5 with BaseException

use of com.microsoft.identity.common.exception.BaseException in project microsoft-authentication-library-common-for-android by AzureAD.

the class IpcStrategyTests method testOperationSucceeds.

protected void testOperationSucceeds(@NonNull final BrokerOperationBundle bundle, @NonNull final Bundle expectedResultBundle) {
    final IIpcStrategy strategy = getStrategy();
    try {
        final Bundle resultBundle = strategy.communicateToBroker(bundle);
        Assert.assertNotNull(resultBundle);
        Assert.assertTrue(isBundleEqual(resultBundle, expectedResultBundle));
    } catch (BaseException e) {
        Assert.fail("Exception is not expected.");
    }
}
Also used : BaseException(com.microsoft.identity.common.exception.BaseException) Bundle(android.os.Bundle) BrokerOperationBundle(com.microsoft.identity.common.internal.broker.ipc.BrokerOperationBundle) BaseBundle(android.os.BaseBundle) IIpcStrategy(com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy)

Aggregations

BaseException (com.microsoft.identity.common.exception.BaseException)16 ClientException (com.microsoft.identity.common.exception.ClientException)6 UserCancelException (com.microsoft.identity.common.exception.UserCancelException)5 IIpcStrategy (com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy)5 BrokerOperationExecutor (com.microsoft.identity.common.internal.controllers.BrokerOperationExecutor)5 BrokerCommunicationException (com.microsoft.identity.common.exception.BrokerCommunicationException)4 Bundle (android.os.Bundle)3 NonNull (androidx.annotation.NonNull)3 BrokerOperationBundle (com.microsoft.identity.common.internal.broker.ipc.BrokerOperationBundle)3 ArgumentException (com.microsoft.identity.common.exception.ArgumentException)2 ServiceException (com.microsoft.identity.common.exception.ServiceException)2 UiRequiredException (com.microsoft.identity.common.exception.UiRequiredException)2 AcquireTokenResult (com.microsoft.identity.common.internal.result.AcquireTokenResult)2 Context (android.content.Context)1 Intent (android.content.Intent)1 BaseBundle (android.os.BaseBundle)1 IntuneAppProtectionPolicyRequiredException (com.microsoft.identity.common.exception.IntuneAppProtectionPolicyRequiredException)1 BrokerResultFuture (com.microsoft.identity.common.internal.broker.BrokerResultFuture)1 TokenCommand (com.microsoft.identity.common.internal.commands.TokenCommand)1 CommandParameters (com.microsoft.identity.common.internal.commands.parameters.CommandParameters)1