package de.nenick.espressomacchiato.mocks;

import android.app.Activity;
import android.app.Instrumentation;
import android.content.Intent;
import android.net.Uri;

import org.hamcrest.Matcher;

import de.nenick.espressomacchiato.tools.EspContactTool;

import static android.support.test.espresso.intent.Intents.intending;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction;
import static org.hamcrest.CoreMatchers.allOf;

/**
 * Mock requests for contact picker.
 *
 * @see EspContactTool to modify given contacts.
 */
public class EspContactPickerMock {

    /**
     * Create mock for {@link Intent#ACTION_PICK} intents.
     *
     * As result you get reported an {@link Activity#RESULT_OK}.
     *
     * @param uri Contact data uri which should be reported as result.
     */
    public void registerMockWithData(Uri uri) {
        Intent contactData = new Intent();
        contactData.setData(uri);
        intending(hasAction(Intent.ACTION_PICK)).respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, contactData));
    }

    /**
     * Create mock for {@link Intent#ACTION_PICK} intents.
     *
     * As result you get reported an {@link Activity#RESULT_OK}.
     *
     * @param uri Contact data uri which should be reported as result.
     * @param extraMatcher React only when intent match the given additional matcher.
     */
    public void registerMockWithData(Uri uri, Matcher<? super Intent> extraMatcher) {
        Intent contactData = new Intent();
        contactData.setData(uri);
        intending(allOf(hasAction(Intent.ACTION_PICK), extraMatcher)).respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, contactData));
    }

}

@@ -452,208 +452,424 @@
 Of;%0A
-%0A/**%0A * Mock requests for contact picker.%0A *%0A * @see EspContactTool to modify given contacts.%0A */%0Apublic class EspContactPickerMock %7B%0A%0A    /**%0A     * Create mock for %7B@link Intent#ACTION_PICK%7D intents
+import static org.hamcrest.CoreMatchers.anything;%0A%0A/**%0A * Stubbing contact request with %7B@link Intent#ACTION_PICK%7D.%0A *%0A * @see EspContactTool to modify given contacts.%0A * @see de.nenick.espressomacchiato.intents Base description for intent mocking.%0A * @since Espresso Macchiato 0.6%0A */%0Apublic class EspContactPickerMock %7B%0A%0A    /**%0A     * Register new stub (convenience method for %7B@link #register(Uri, Matcher, int)%7D
 .%0A  
@@ -1012,24 +1012,68 @@
  as result.%0A
+     *%0A     * @since Espresso Macchiato 0.6%0A
      */%0A    
@@ -1088,36 +1088,24 @@
 oid register
-MockWithData
 (Uri uri) %7B%0A
@@ -1116,173 +1116,34 @@
     
-Intent contactData = new Intent();%0A        contactData.setData(uri);%0A        intending(hasAction(Intent.ACTION_PICK)).respondWith(new Instrumentation.ActivityResult(
+register(uri, anything(), 
 Acti
@@ -1152,38 +1152,24 @@
 ty.RESULT_OK
-, contactData)
 );%0A    %7D%0A%0A  
@@ -1185,58 +1185,86 @@
   * 
-Create mock for %7B@link Intent#ACTION_PICK%7D intents
+Register new stub (convenience method for %7B@link #register(Uri, Matcher, int)%7D
 .%0A  
@@ -1350,32 +1350,41 @@
    * @param uri 
+         
 Contact data uri
@@ -1449,18 +1449,19 @@
 tcher Re
-ac
+por
 t only w
@@ -1509,24 +1509,598 @@
 cher.%0A     *
+%0A     * @since Espresso Macchiato 0.6%0A     */%0A    public void register(Uri uri, Matcher%3C? super Intent%3E extraMatcher) %7B%0A        register(uri, extraMatcher, Activity.RESULT_OK);%0A    %7D%0A%0A    /**%0A     * Register new stub for contact data requests%0A     *%0A     * @param uri            Uri will be reported as intent data.%0A     * @param extraMatcher   Report only when intent match the given additional matcher.%0A     * @param activityResult Specific activity result (%7B@link Activity#RESULT_OK%7D or %7B@link Activity#RESULT_CANCELED%7D.%0A     *%0A     * @since Espresso Macchiato 0.6%0A     *
 /%0A    public
@@ -2117,20 +2117,8 @@
 ster
-MockWithData
 (Uri
@@ -2151,32 +2151,52 @@
 nt%3E extraMatcher
+, int activityResult
 ) %7B%0A        Inte
@@ -2377,34 +2377,30 @@
 yResult(
-A
+a
 ctivity
-.RESULT_OK
+Result
 , contac
@@ -2414,11 +2414,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

update javadoc