@Test public void request() throws Exception { final String permission = "permission"; final PermissionAuthorizationResponse response = new PermissionAuthorizationResponse(permission, true); when(permissionRequesterFragment.request(permission)).thenReturn(Single.just(response)); permissionsRequester.request(permission).test() .assertValue(response) .assertComplete() .assertNoErrors(); }
@NonNull @Override public Single<PermissionAuthorizationResponse> request(@NonNull String manifestPermission) { Logger.info(this, "Requesting permission: {}", manifestPermission); try { return permissionRequesterFactory.get().request(manifestPermission); } catch (IllegalStateException e) { return Single.error(e); } }
ActivityPermissionsRequester implements PermissionRequester { @NonNull @Override public Single<PermissionAuthorizationResponse> request(@NonNull String manifestPermission) { Logger.info(this, "Requesting permission: {}", manifestPermission); try { return permissionRequesterFactory.get().request(manifestPermission); } catch (IllegalStateException e) { return Single.error(e); } } }
ActivityPermissionsRequester implements PermissionRequester { @NonNull @Override public Single<PermissionAuthorizationResponse> request(@NonNull String manifestPermission) { Logger.info(this, "Requesting permission: {}", manifestPermission); try { return permissionRequesterFactory.get().request(manifestPermission); } catch (IllegalStateException e) { return Single.error(e); } } @Inject  ActivityPermissionsRequester(@NonNull T activity); @VisibleForTesting  ActivityPermissionsRequester(@NonNull HeadlessFragmentPermissionRequesterFactory permissionRequesterFactory); }
ActivityPermissionsRequester implements PermissionRequester { @NonNull @Override public Single<PermissionAuthorizationResponse> request(@NonNull String manifestPermission) { Logger.info(this, "Requesting permission: {}", manifestPermission); try { return permissionRequesterFactory.get().request(manifestPermission); } catch (IllegalStateException e) { return Single.error(e); } } @Inject  ActivityPermissionsRequester(@NonNull T activity); @VisibleForTesting  ActivityPermissionsRequester(@NonNull HeadlessFragmentPermissionRequesterFactory permissionRequesterFactory); @NonNull @Override Single<PermissionAuthorizationResponse> request(@NonNull String manifestPermission); @Override void markRequestConsumed(@NonNull String manifestPermission); }
ActivityPermissionsRequester implements PermissionRequester { @NonNull @Override public Single<PermissionAuthorizationResponse> request(@NonNull String manifestPermission) { Logger.info(this, "Requesting permission: {}", manifestPermission); try { return permissionRequesterFactory.get().request(manifestPermission); } catch (IllegalStateException e) { return Single.error(e); } } @Inject  ActivityPermissionsRequester(@NonNull T activity); @VisibleForTesting  ActivityPermissionsRequester(@NonNull HeadlessFragmentPermissionRequesterFactory permissionRequesterFactory); @NonNull @Override Single<PermissionAuthorizationResponse> request(@NonNull String manifestPermission); @Override void markRequestConsumed(@NonNull String manifestPermission);  }