// Path: ggglib/src/main/java/com/gigigo/ggglib/ContextProvider.java
// public interface ContextProvider {
// 
//   Activity getCurrentActivity();
// 
//   boolean isActivityContextAvailable();
// 
//   Context getApplicationContext();
// 
//   boolean isApplicationContextAvailable();
// }
// 
// Path: ggglib/src/test/java/com/gigigo/ggglib/permissions/utils/DummyPermissionListenerImplementation.java
// public class DummyPermissionListenerImplementation extends AbstractPermissionListener {
// 
//   private final StubString stubString;
// 
//   public DummyPermissionListenerImplementation(ContextProvider contextProvider,
//       StubString stubString) {
//     super(contextProvider);
//     this.stubString = stubString;
//   }
// 
//   public DummyPermissionListenerImplementation(UserPermissionRequestResponseListener
//       userPermissionRequestResponseListener, ContextProvider contextProvider,
//       StubString stubString) {
//     super(userPermissionRequestResponseListener, contextProvider);
//     this.stubString = stubString;
//   }
// 
//   @Override public int getPermissionDeniedFeedback() {
//     return stubString.getPermissionDeniedFeedback();
//   }
// 
//   @Override public int getPermissionRationaleMessage() {
//     return stubString.getPermissionRationaleMessage();
//   }
// 
//   @Override public int getPermissionRationaleTitle() {
//     return stubString.getPermissionRationaleTitle();
//   }
// 
// }
// 
// Path: ggglib/src/test/java/com/gigigo/ggglib/permissions/utils/StubString.java
// public class StubString {
//   public static final int FAKE_RES = 3;
// 
//   public int getPermissionDeniedFeedback() {
//     return FAKE_RES;
//   }
// 
//   public int getPermissionRationaleMessage() {
//     return FAKE_RES;
//   }
// 
//   public int getPermissionRationaleTitle() {
//     return FAKE_RES;
//   }
// }


import android.app.Activity;
import android.content.Context;
import com.gigigo.ggglib.ContextProvider;
import com.gigigo.ggglib.permissions.utils.DummyPermissionListenerImplementation;
import com.gigigo.ggglib.permissions.utils.StubString;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionDeniedResponse;
import com.karumi.dexter.listener.PermissionGrantedResponse;
import com.karumi.dexter.listener.PermissionRequest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.gigigo.ggglib.permissions;





@RunWith(MockitoJUnitRunner.class)
public class AbstractPermissionListenerTest {

  @Mock UserPermissionRequestResponseListener userPermissionRequestResponseListener;

  @Mock ContextProvider contextProvider;

  @Mock Context applicationContext;
  @Mock Activity activityContext;

  @Mock PermissionToken permissionToken;

  @Mock StubString stubString;

  private void setUpActivityContextInitializedScenario() {
    when(contextProvider.getApplicationContext()).thenReturn(applicationContext);
    when(contextProvider.getCurrentActivity()).thenReturn(activityContext);
    when(contextProvider.isActivityContextAvailable()).thenReturn(true);
    when(contextProvider.isApplicationContextAvailable()).thenReturn(true);
  }

  @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
// Path: ggglib/src/main/java/com/gigigo/ggglib/ContextProvider.java
// public interface ContextProvider {
// 
//   Activity getCurrentActivity();
// 
//   boolean isActivityContextAvailable();
// 
//   Context getApplicationContext();
// 
//   boolean isApplicationContextAvailable();
// }
// 
// Path: ggglib/src/test/java/com/gigigo/ggglib/permissions/utils/DummyPermissionListenerImplementation.java
// public class DummyPermissionListenerImplementation extends AbstractPermissionListener {
// 
//   private final StubString stubString;
// 
//   public DummyPermissionListenerImplementation(ContextProvider contextProvider,
//       StubString stubString) {
//     super(contextProvider);
//     this.stubString = stubString;
//   }
// 
//   public DummyPermissionListenerImplementation(UserPermissionRequestResponseListener
//       userPermissionRequestResponseListener, ContextProvider contextProvider,
//       StubString stubString) {
//     super(userPermissionRequestResponseListener, contextProvider);
//     this.stubString = stubString;
//   }
// 
//   @Override public int getPermissionDeniedFeedback() {
//     return stubString.getPermissionDeniedFeedback();
//   }
// 
//   @Override public int getPermissionRationaleMessage() {
//     return stubString.getPermissionRationaleMessage();
//   }
// 
//   @Override public int getPermissionRationaleTitle() {
//     return stubString.getPermissionRationaleTitle();
//   }
// 
// }
// 
// Path: ggglib/src/test/java/com/gigigo/ggglib/permissions/utils/StubString.java
// public class StubString {
//   public static final int FAKE_RES = 3;
// 
//   public int getPermissionDeniedFeedback() {
//     return FAKE_RES;
//   }
// 
//   public int getPermissionRationaleMessage() {
//     return FAKE_RES;
//   }
// 
//   public int getPermissionRationaleTitle() {
//     return FAKE_RES;
//   }
// }


// Path: ggglib/src/test/java/com/gigigo/ggglib/permissions/AbstractPermissionListenerTest.java
import android.app.Activity;
import android.content.Context;
import com.gigigo.ggglib.ContextProvider;
import com.gigigo.ggglib.permissions.utils.DummyPermissionListenerImplementation;
import com.gigigo.ggglib.permissions.utils.StubString;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionDeniedResponse;
import com.karumi.dexter.listener.PermissionGrantedResponse;
import com.karumi.dexter.listener.PermissionRequest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

package com.gigigo.ggglib.permissions;





@RunWith(MockitoJUnitRunner.class)
public class AbstractPermissionListenerTest {

  @Mock UserPermissionRequestResponseListener userPermissionRequestResponseListener;

  @Mock ContextProvider contextProvider;

  @Mock Context applicationContext;
  @Mock Activity activityContext;

  @Mock PermissionToken permissionToken;

  @Mock StubString stubString;

  private void setUpActivityContextInitializedScenario() {
    when(contextProvider.getApplicationContext()).thenReturn(applicationContext);
    when(contextProvider.getCurrentActivity()).thenReturn(activityContext);
    when(contextProvider.isActivityContextAvailable()).thenReturn(true);
    when(contextProvider.isApplicationContextAvailable()).thenReturn(true);
  }

  @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 getPermissionDeniedFeedbackMethodIsCalledForShowingToastOnActivityContextNull(){