// Path: app/src/test/java/io/petros/posts/PreconfiguredRobolectricTestRunner.java
// public class PreconfiguredRobolectricTestRunner extends RobolectricTestRunner {
// 
//     private static final int SDK_API_LEVEL_TO_EMULATE = 25;
// 
//     /**
//      * Creates a runner to run {@code testClass}. Looks in your working directory for your AndroidManifest.xml file and res directory by
//      * default. Use the {@link Config} annotation to configure.
//      *
//      * @param testClass The test class to be run.
//      * @throws InitializationError If junit says so.
//      */
//     public PreconfiguredRobolectricTestRunner(final Class<?> testClass) throws InitializationError {
//         super(testClass);
//     }
// 
//     @Override
//     protected Config buildGlobalConfig() {
//         return new Config.Builder()
//                 .setSdk(SDK_API_LEVEL_TO_EMULATE)
//                 .setManifest(Config.NONE)
//                 .setApplication(TestPostsApplication.class)
//                 .build();
//     }
// 
// }
// 
// Path: app/src/test/java/io/petros/posts/RobolectricGeneralTestHelper.java
// public class RobolectricGeneralTestHelper extends GeneralTestHelper {
// 
//     // Application specific fields.
//     protected final Context context = getTestContext();
//     protected final PostsApplication application = getTestApplication();
// 
//     // System specific fields.
//     @Mock protected ConnectivityManager connectivityManagerMock;
// 
//     // Activity specific fields.
//     @Mock protected PostsApplication applicationMock;
//     @Mock protected SnackbarActions snackbarActionsMock;
// 
//     // ROBOLECTRIC // *******************************************************************************************************
// 
//     private Context getTestContext() {
//         return getShadowApplication().getApplicationContext();
//     }
// 
//     private ShadowApplication getShadowApplication() {
//         return ShadowApplication.getInstance();
//     }
// 
//     private PostsApplication getTestApplication() {
//         return (PostsApplication) RuntimeEnvironment.application;
//     }
// 
//     // MOCKS // *************************************************************************************************************
// 
//     protected void setUpMocks() {
//         super.setUpMocks();
//         setUpApplicationMocks();
//     }
// 
//     private void setUpApplicationMocks() {
//         when(applicationMock.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(connectivityManagerMock);
//         when(applicationMock.snackbar()).thenReturn(snackbarActionsMock);
//     }
// 
//     // POST // **************************************************************************************************************
// 
//     protected Bundle getExtras(final Post post) {
//         final Bundle extras = new Bundle();
//         extras.putInt(Post.USER_ID, post.getUserId());
//         extras.putInt(Post.ID, post.getId());
//         extras.putString(Post.TITLE, post.getTitle());
//         extras.putString(Post.BODY, post.getBody());
//         return extras;
//     }
// 
// }
// 
// Path: app/src/main/java/io/petros/posts/activity/posts/presenter/PostsPresenter.java
// public interface PostsPresenter extends MvpPresenter<PostsView> {
// 
//     void loadPosts(final boolean pullToRefresh);
// 
// }
// 
// Path: app/src/main/java/io/petros/posts/activity/posts/view/recycler/PostRecyclerViewAdapter.java
// public class PostRecyclerViewAdapter extends RecyclerView.Adapter<PostViewHolder> implements RecyclerViewAdapter {
// 
//     private final OnViewClickListener onViewClickListener;
// 
//     @VisibleForTesting List<Post> allPosts;
// 
//     public PostRecyclerViewAdapter(final OnViewClickListener onViewClickListener) {
//         this.onViewClickListener = onViewClickListener;
//         allPosts = new ArrayList<>();
//     }
// 
//     @Override
//     public PostViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
//         final View itemView = LayoutInflater.from(parent.getContext())
//                 .inflate(R.layout.item_view_post, parent, false);
//         return new PostViewHolder(itemView);
//     }
// 
//     @Override
//     public void onBindViewHolder(final PostViewHolder holder, final int position) {
//         holder.bind(getItem(position), onViewClickListener);
//     }
// 
//     @Override
//     public int getItemCount() {
//         return allPosts.size();
//     }
// 
//     @Override
//     public void reloadAdapter(final List<Post> posts) {
//         Timber.d("Reloading post recycler view adapter.");
//         allPosts.clear();
//         allPosts.addAll(posts);
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public Post getItem(int position) {
//         return allPosts.get(position);
//     }
// 
// }


import android.app.ProgressDialog;
import android.support.v7.widget.RecyclerView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil;
import io.petros.posts.PreconfiguredRobolectricTestRunner;
import io.petros.posts.RobolectricGeneralTestHelper;
import io.petros.posts.activity.posts.presenter.PostsPresenter;
import io.petros.posts.activity.posts.view.recycler.PostRecyclerViewAdapter;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
package io.petros.posts.activity.posts.view;





@RunWith(PreconfiguredRobolectricTestRunner.class)
public class PostsFragmentTest extends RobolectricGeneralTestHelper {

    private static final boolean PULL_TO_REFRESH = true;

    private PostsFragment postsFragment;
    @Mock private PostsPresenter postsPresenterMock;
    @Mock private RecyclerView postsRecyclerViewMock;
// Path: app/src/test/java/io/petros/posts/PreconfiguredRobolectricTestRunner.java
// public class PreconfiguredRobolectricTestRunner extends RobolectricTestRunner {
// 
//     private static final int SDK_API_LEVEL_TO_EMULATE = 25;
// 
//     /**
//      * Creates a runner to run {@code testClass}. Looks in your working directory for your AndroidManifest.xml file and res directory by
//      * default. Use the {@link Config} annotation to configure.
//      *
//      * @param testClass The test class to be run.
//      * @throws InitializationError If junit says so.
//      */
//     public PreconfiguredRobolectricTestRunner(final Class<?> testClass) throws InitializationError {
//         super(testClass);
//     }
// 
//     @Override
//     protected Config buildGlobalConfig() {
//         return new Config.Builder()
//                 .setSdk(SDK_API_LEVEL_TO_EMULATE)
//                 .setManifest(Config.NONE)
//                 .setApplication(TestPostsApplication.class)
//                 .build();
//     }
// 
// }
// 
// Path: app/src/test/java/io/petros/posts/RobolectricGeneralTestHelper.java
// public class RobolectricGeneralTestHelper extends GeneralTestHelper {
// 
//     // Application specific fields.
//     protected final Context context = getTestContext();
//     protected final PostsApplication application = getTestApplication();
// 
//     // System specific fields.
//     @Mock protected ConnectivityManager connectivityManagerMock;
// 
//     // Activity specific fields.
//     @Mock protected PostsApplication applicationMock;
//     @Mock protected SnackbarActions snackbarActionsMock;
// 
//     // ROBOLECTRIC // *******************************************************************************************************
// 
//     private Context getTestContext() {
//         return getShadowApplication().getApplicationContext();
//     }
// 
//     private ShadowApplication getShadowApplication() {
//         return ShadowApplication.getInstance();
//     }
// 
//     private PostsApplication getTestApplication() {
//         return (PostsApplication) RuntimeEnvironment.application;
//     }
// 
//     // MOCKS // *************************************************************************************************************
// 
//     protected void setUpMocks() {
//         super.setUpMocks();
//         setUpApplicationMocks();
//     }
// 
//     private void setUpApplicationMocks() {
//         when(applicationMock.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(connectivityManagerMock);
//         when(applicationMock.snackbar()).thenReturn(snackbarActionsMock);
//     }
// 
//     // POST // **************************************************************************************************************
// 
//     protected Bundle getExtras(final Post post) {
//         final Bundle extras = new Bundle();
//         extras.putInt(Post.USER_ID, post.getUserId());
//         extras.putInt(Post.ID, post.getId());
//         extras.putString(Post.TITLE, post.getTitle());
//         extras.putString(Post.BODY, post.getBody());
//         return extras;
//     }
// 
// }
// 
// Path: app/src/main/java/io/petros/posts/activity/posts/presenter/PostsPresenter.java
// public interface PostsPresenter extends MvpPresenter<PostsView> {
// 
//     void loadPosts(final boolean pullToRefresh);
// 
// }
// 
// Path: app/src/main/java/io/petros/posts/activity/posts/view/recycler/PostRecyclerViewAdapter.java
// public class PostRecyclerViewAdapter extends RecyclerView.Adapter<PostViewHolder> implements RecyclerViewAdapter {
// 
//     private final OnViewClickListener onViewClickListener;
// 
//     @VisibleForTesting List<Post> allPosts;
// 
//     public PostRecyclerViewAdapter(final OnViewClickListener onViewClickListener) {
//         this.onViewClickListener = onViewClickListener;
//         allPosts = new ArrayList<>();
//     }
// 
//     @Override
//     public PostViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
//         final View itemView = LayoutInflater.from(parent.getContext())
//                 .inflate(R.layout.item_view_post, parent, false);
//         return new PostViewHolder(itemView);
//     }
// 
//     @Override
//     public void onBindViewHolder(final PostViewHolder holder, final int position) {
//         holder.bind(getItem(position), onViewClickListener);
//     }
// 
//     @Override
//     public int getItemCount() {
//         return allPosts.size();
//     }
// 
//     @Override
//     public void reloadAdapter(final List<Post> posts) {
//         Timber.d("Reloading post recycler view adapter.");
//         allPosts.clear();
//         allPosts.addAll(posts);
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public Post getItem(int position) {
//         return allPosts.get(position);
//     }
// 
// }


// Path: app/src/test/java/io/petros/posts/activity/posts/view/PostsFragmentTest.java
import android.app.ProgressDialog;
import android.support.v7.widget.RecyclerView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil;
import io.petros.posts.PreconfiguredRobolectricTestRunner;
import io.petros.posts.RobolectricGeneralTestHelper;
import io.petros.posts.activity.posts.presenter.PostsPresenter;
import io.petros.posts.activity.posts.view.recycler.PostRecyclerViewAdapter;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

package io.petros.posts.activity.posts.view;





@RunWith(PreconfiguredRobolectricTestRunner.class)
public class PostsFragmentTest extends RobolectricGeneralTestHelper {

    private static final boolean PULL_TO_REFRESH = true;

    private PostsFragment postsFragment;
    @Mock private PostsPresenter postsPresenterMock;
    @Mock private RecyclerView postsRecyclerViewMock;
    @Mock private PostRecyclerViewAdapter postRecyclerViewAdapterMock;