Source:
<code>public void testVerifyManifestPermission_missingPermission_MANAGE_ACCOUNTS_USE_CREDENTIALS() throws NoSuchAlgorithmException, NoSuchPaddingException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException, NameNotFoundException { FileMockContext mockContext = new FileMockContext(getContext()); mockContext.setPermission("android.permission.INTERNET",PackageManager.PERMISSION_GRANTED); mockContext.setPermission("android.permission.GET_ACCOUNTS",PackageManager.PERMISSION_GRANTED); Object brokerProxy = ReflectionUtils.getInstance("com.microsoft.aad.adal.BrokerProxy"); String authenticatorType = AuthenticationConstants.Broker.BROKER_ACCOUNT_TYPE; String brokerPackage = AuthenticationConstants.Broker.PACKAGE_NAME; String contextPackage = "com.test"; Signature signature = new Signature(testSignature); AuthenticationSettings.INSTANCE.setBrokerSignature(testTag); Account[] accts = getAccountList("currentUserName", authenticatorType); <START> prepareProxyForTest(brokerProxy, authenticatorType, brokerPackage, contextPackage, <END> signature, true, accts); ReflectionUtils.setFieldValue(brokerProxy, "mContext", mockContext); Method m = ReflectionUtils.getTestMethod(brokerProxy, "verifyManifestPermissions"); try { m.invoke(brokerProxy); Assert.fail(); } catch(InvocationTargetException e) { assertTrue(e.getCause() instanceof UsageAuthenticationException); assertTrue(((UsageAuthenticationException)e.getCause()).getMessage().contains("[MANAGE_ACCOUNTS, USE_CREDENTIALS]")); assertEquals(ADALError.DEVELOPER_BROKER_PERMISSIONS_MISSING, ((UsageAuthenticationException)e.getCause()).getCode()); } }</code><technical_language>is prepareProxyForTest</technical_language>

Target:
public void testVerifyManifestPermission_missingPermission_MANAGE_ACCOUNTS_USE_CREDENTIALS() throws NoSuchAlgorithmException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException, NameNotFoundException { FileMockContext mockContext = new FileMockContext(getContext()); mockContext.setPermission("android.permission.INTERNET",PackageManager.PERMISSION_GRANTED); mockContext.setPermission("android.permission.GET_ACCOUNTS",PackageManager.PERMISSION_GRANTED); Object brokerProxy = ReflectionUtils.getInstance("com.microsoft.aad.adal.BrokerProxy"); String authenticatorType = AuthenticationConstants.Broker.BROKER_ACCOUNT_TYPE; String brokerPackage = AuthenticationConstants.Broker.COMPANY_PORTAL_APP_PACKAGE_NAME; String contextPackage = "com.test"; Signature signature = new Signature(testSignature); AuthenticationSettings.INSTANCE.setBrokerSignature(testTag); Account[] accts = getAccountList("currentUserName", authenticatorType); prepareProxyForTest(brokerProxy, authenticatorType, brokerPackage, contextPackage, signature, true, accts); ReflectionUtils.setFieldValue(brokerProxy, "mContext", mockContext); Method m = ReflectionUtils.getTestMethod(brokerProxy, "verifyManifestPermissions"); try { m.invoke(brokerProxy); Assert.fail(); } catch(InvocationTargetException e) { assertTrue(e.getCause() instanceof UsageAuthenticationException); assertTrue(((UsageAuthenticationException)e.getCause()).getMessage().contains("[MANAGE_ACCOUNTS, USE_CREDENTIALS]")); assertEquals(ADALError.DEVELOPER_BROKER_PERMISSIONS_MISSING, ((UsageAuthenticationException)e.getCause()).getCode()); } }