AbstractPermissionListener implements PermissionListener { @Override public void onPermissionDenied(PermissionDeniedResponse response) { if (!contextProvider.isActivityContextAvailable()){ PermissionsUIViews.showPermissionToast(contextProvider.getApplicationContext(), getPermissionDeniedFeedback()); } if (userPermissionRequestResponseListener!=null){ userPermissionRequestResponseListener.onPermissionAllowed(false); } } AbstractPermissionListener(ContextProvider contextProvider);  AbstractPermissionListener(UserPermissionRequestResponseListener
      userPermissionRequestResponseListener, ContextProvider contextProvider); @Override void onPermissionGranted(PermissionGrantedResponse response); @Override void onPermissionDenied(PermissionDeniedResponse response); @Override void onPermissionRationaleShouldBeShown(PermissionRequest permissionRequest,
      PermissionToken token); abstract int getPermissionDeniedFeedback(); abstract int getPermissionRationaleMessage(); abstract int getPermissionRationaleTitle();  }
@Test public void responseListenerIsNotCalledWithNullListenerOnPermissionGranted(){ DummyPermissionListenerImplementation dummyPermissionListenerImplementation = new DummyPermissionListenerImplementation(contextProvider, stubString); setUpActivityContextInitializedScenario(); dummyPermissionListenerImplementation.onPermissionDenied( new PermissionDeniedResponse(new PermissionRequest("Test"), true)); verify(userPermissionRequestResponseListener, never()).onPermissionAllowed(false); }
@Test public void responseListenerIsCalledWithNotNullListenerOnPermissionDenied() { DummyPermissionListenerImplementation dummyPermissionListenerImplementation = new DummyPermissionListenerImplementation(userPermissionRequestResponseListener, contextProvider, stubString); setUpActivityContextInitializedScenario(); dummyPermissionListenerImplementation.onPermissionDenied( new PermissionDeniedResponse(new PermissionRequest("Test"), true)); verify(userPermissionRequestResponseListener).onPermissionAllowed(false); }