// Path: app/src/main/java/apidez/com/databinding/ComponentBuilder.java
// public class ComponentBuilder {
//     private AppComponent appComponent;
// 
//     public ComponentBuilder(AppComponent appComponent) {
//         this.appComponent = appComponent;
//     }
// 
//     public PlacesComponent placesComponent() {
//         return appComponent.plus(new PlacesModule());
//     }
// 
//     public PurchaseComponent purchaseComponent() {
//         return appComponent.plus(new PurchaseModule());
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/dependency/component/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class})
// public interface AppComponent {
//     PurchaseComponent plus(PurchaseModule purchaseModule);
//     PlacesComponent plus(PlacesModule placesModule);
// }
// 
// Path: app/src/main/java/apidez/com/databinding/dependency/component/PurchaseComponent.java
// @ViewScope
// @Subcomponent(modules = {PurchaseModule.class})
// public interface PurchaseComponent {
//     void inject(PurchaseActivity purchaseActivity);
// }
// 
// Path: app/src/main/java/apidez/com/databinding/dependency/module/PurchaseModule.java
// @Module
// public class PurchaseModule {
//     @Provides
//     @ViewScope
//     public IPurchaseApi providePurchaseApi(Gson gson) {
//         return new PurchaseApi(gson);
//     }
// 
//     @Provides
//     @ViewScope
//     public IPurchaseViewModel providePurchaseViewModel(IPurchaseApi purchaseApi) {
//         return new PurchaseViewModel(purchaseApi);
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/model/api/IPurchaseApi.java
// public interface IPurchaseApi {
//     Observable<Boolean> submitPurchase(String creditCard, String email);
// }
// 
// Path: app/src/androidTest/java/apidez/com/databinding/utils/ApplicationUtils.java
// public class ApplicationUtils {
//     public static TestApplication application() {
//         Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
//         return (TestApplication) instrumentation.getTargetContext().getApplicationContext();
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/utils/UiUtils.java
// public class UiUtils {
//     public static void showDialog(String text, Context context) {
//         new AlertDialog.Builder(context)
//                 .setMessage(text)
//                 .setPositiveButton(android.R.string.yes, (dialog, which) -> {
//                 })
//                 .show();
//     }
// 
//     public static void closeKeyboard(Activity context) {
//         // Check if no view has focus:
//         View view = context.getCurrentFocus();
//         if (view != null) {
//             InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
//             imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
//         }
//     }
// }
// 
// Path: app/src/androidTest/java/apidez/com/databinding/utils/MatcherEx.java
// public static Matcher<View> isVisible() {
//     return new TypeSafeMatcher<View>() {
//         @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
//         @Override
//         protected boolean matchesSafely(View view) {
//             return view.getVisibility() == View.VISIBLE;
//         }
// 
//         @Override
//         public void describeTo(Description description) {
//             description.appendText("is visible");
//         }
//     };
// }
// 
// Path: app/src/androidTest/java/apidez/com/databinding/utils/MatcherEx.java
// public static void waitText(final String viewText, final long millis) throws Exception {
//     Thread.sleep(millis);
//     onView(withText(viewText)).check(matches(isDisplayed()));
// }


import android.content.Intent;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.MediumTest;
import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import apidez.com.databinding.ComponentBuilder;
import apidez.com.databinding.R;
import apidez.com.databinding.dependency.component.AppComponent;
import apidez.com.databinding.dependency.component.PurchaseComponent;
import apidez.com.databinding.dependency.module.PurchaseModule;
import apidez.com.databinding.model.api.IPurchaseApi;
import apidez.com.databinding.utils.ApplicationUtils;
import apidez.com.databinding.utils.UiUtils;
import rx.Observable;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static apidez.com.databinding.utils.MatcherEx.isVisible;
import static apidez.com.databinding.utils.MatcherEx.waitText;
import static org.hamcrest.Matchers.not;
package apidez.com.databinding.view.activity;






/**
 * Created by nongdenchet on 10/3/15.
 */

/**
 * Test the whole flow mocking long running task
 */
@MediumTest
@RunWith(AndroidJUnit4.class)
public class PurchaseActivityIntegrateTest {
    private String FAIL_CARD = "222222222222";

    @Rule
    public ActivityTestRule<PurchaseActivity> activityTestRule =
// Path: app/src/main/java/apidez/com/databinding/ComponentBuilder.java
// public class ComponentBuilder {
//     private AppComponent appComponent;
// 
//     public ComponentBuilder(AppComponent appComponent) {
//         this.appComponent = appComponent;
//     }
// 
//     public PlacesComponent placesComponent() {
//         return appComponent.plus(new PlacesModule());
//     }
// 
//     public PurchaseComponent purchaseComponent() {
//         return appComponent.plus(new PurchaseModule());
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/dependency/component/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class})
// public interface AppComponent {
//     PurchaseComponent plus(PurchaseModule purchaseModule);
//     PlacesComponent plus(PlacesModule placesModule);
// }
// 
// Path: app/src/main/java/apidez/com/databinding/dependency/component/PurchaseComponent.java
// @ViewScope
// @Subcomponent(modules = {PurchaseModule.class})
// public interface PurchaseComponent {
//     void inject(PurchaseActivity purchaseActivity);
// }
// 
// Path: app/src/main/java/apidez/com/databinding/dependency/module/PurchaseModule.java
// @Module
// public class PurchaseModule {
//     @Provides
//     @ViewScope
//     public IPurchaseApi providePurchaseApi(Gson gson) {
//         return new PurchaseApi(gson);
//     }
// 
//     @Provides
//     @ViewScope
//     public IPurchaseViewModel providePurchaseViewModel(IPurchaseApi purchaseApi) {
//         return new PurchaseViewModel(purchaseApi);
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/model/api/IPurchaseApi.java
// public interface IPurchaseApi {
//     Observable<Boolean> submitPurchase(String creditCard, String email);
// }
// 
// Path: app/src/androidTest/java/apidez/com/databinding/utils/ApplicationUtils.java
// public class ApplicationUtils {
//     public static TestApplication application() {
//         Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
//         return (TestApplication) instrumentation.getTargetContext().getApplicationContext();
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/utils/UiUtils.java
// public class UiUtils {
//     public static void showDialog(String text, Context context) {
//         new AlertDialog.Builder(context)
//                 .setMessage(text)
//                 .setPositiveButton(android.R.string.yes, (dialog, which) -> {
//                 })
//                 .show();
//     }
// 
//     public static void closeKeyboard(Activity context) {
//         // Check if no view has focus:
//         View view = context.getCurrentFocus();
//         if (view != null) {
//             InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
//             imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
//         }
//     }
// }
// 
// Path: app/src/androidTest/java/apidez/com/databinding/utils/MatcherEx.java
// public static Matcher<View> isVisible() {
//     return new TypeSafeMatcher<View>() {
//         @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
//         @Override
//         protected boolean matchesSafely(View view) {
//             return view.getVisibility() == View.VISIBLE;
//         }
// 
//         @Override
//         public void describeTo(Description description) {
//             description.appendText("is visible");
//         }
//     };
// }
// 
// Path: app/src/androidTest/java/apidez/com/databinding/utils/MatcherEx.java
// public static void waitText(final String viewText, final long millis) throws Exception {
//     Thread.sleep(millis);
//     onView(withText(viewText)).check(matches(isDisplayed()));
// }


// Path: app/src/androidTest/java/apidez/com/databinding/view/activity/PurchaseActivityIntegrateTest.java
import android.content.Intent;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.MediumTest;
import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import apidez.com.databinding.ComponentBuilder;
import apidez.com.databinding.R;
import apidez.com.databinding.dependency.component.AppComponent;
import apidez.com.databinding.dependency.component.PurchaseComponent;
import apidez.com.databinding.dependency.module.PurchaseModule;
import apidez.com.databinding.model.api.IPurchaseApi;
import apidez.com.databinding.utils.ApplicationUtils;
import apidez.com.databinding.utils.UiUtils;
import rx.Observable;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static apidez.com.databinding.utils.MatcherEx.isVisible;
import static apidez.com.databinding.utils.MatcherEx.waitText;
import static org.hamcrest.Matchers.not;

package apidez.com.databinding.view.activity;






/**
 * Created by nongdenchet on 10/3/15.
 */

/**
 * Test the whole flow mocking long running task
 */
@MediumTest
@RunWith(AndroidJUnit4.class)
public class PurchaseActivityIntegrateTest {
    private String FAIL_CARD = "222222222222";

    @Rule
    public ActivityTestRule<PurchaseActivity> activityTestRule =
            new ActivityTestRule<>(PurchaseActivity.class, true, false);