PermissionManager { public synchronized void obtainPermission() { if (haveAllPermissions()) { return; } mActivity.requestPermissions(mPerms, mRequestCode); } PermissionManager(int androidLevel, Activity activity, int requestCode, String[] perms);  PermissionManager(Activity activity, int requestCode, String[] perms); boolean haveAllPermissions(); synchronized void obtainPermission(); synchronized boolean granted(
            int requestCode, String[] permissions, int[] results);  }
@Test public void obtainPermission() { when(mActivity.checkSelfPermission(PERM0)).thenReturn(PackageManager.PERMISSION_GRANTED); when(mActivity.checkSelfPermission(PERM1)).thenReturn(PackageManager.PERMISSION_DENIED); mManager.obtainPermission(); verify(mActivity).requestPermissions(REQUIRED_PERMS, REQUEST_CODE); }