// Path: rx_gcm/src/main/java/rx_gcm/GcmReceiverUIForeground.java
// public interface GcmReceiverUIForeground {
//     /**
//      * Called when Activity or Fragment matches with the desired target specified in the bundle notification.
//      * @see GcmReceiverUIForeground
//      */
//     void onTargetNotification(Observable<Message> oMessage);
// 
//     /**
//      * Called when Activity or Fragment does not match with the desired target specified in the bundle notification.
//      * @see GcmReceiverUIForeground
//      */
//     void onMismatchTargetNotification(Observable<Message> oMessage);
// 
//     /**
//      * Determines if the implementing class is interested on be notified when updating the data model or seeking for the activity/fragment to be notified.
//      * @param key The value provided in the bundle notification by the server
//      * @return true if the implementing class is interested on be notified
//      */
//     boolean matchesTarget(String key);
// }
// 
// Path: rx_gcm/src/main/java/rx_gcm/Message.java
// public class Message {
//     private final String from;
//     private final Bundle payload;
//     private final String target;
//     private final Application application;
// 
//     public Message(String from, Bundle payload, String target, Application application) {
//         this.from = from;
//         this.payload = payload;
//         this.target = target;
//         this.application = application;
//     }
// 
//     public String from() {
//         return from;
//     }
// 
//     @Nullable public String target() {
//         return target;
//     }
// 
//     public Bundle payload() {
//         return payload;
//     }
// 
//     public Application application() {
//         return application;
//     }
// }


import rx_gcm.Message;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx_gcm.GcmReceiverUIForeground;
        assertThat(wrapper.isTargetScreen(), is(false));
        assertThat(wrapper.gcmReceiverUIForeground() instanceof FragmentMock1Receiver, is(true));

        reset(fragmentManagerMock);
        when(fragmentManagerMock.getFragments()).thenReturn(new ArrayList<Fragment>());

        wrapper = getGcmReceiversUIForegroundUT.retrieve(targetScreen, activityMockReceiver);
        assertThat(wrapper.isTargetScreen(), is(false));
        assertThat(wrapper.gcmReceiverUIForeground() instanceof ActivityMockReceiver, is(true));
    }

    @Test public void When_No_One_GcmReceiverUIForeground_Return_Null_Wrapper() {
        when(fragmentManagerMock.getFragments()).thenReturn(getFragments());
        when(activityMock.getSupportFragmentManager()).thenReturn(fragmentManagerMock);

        GetGcmReceiversUIForeground.Wrapper wrapper = getGcmReceiversUIForegroundUT.retrieve("no one", activityMock);
        assertNull(wrapper);
    }

    private List<Fragment> getFragmentsReceivers() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new FragmentMock1Receiver());
        fragments.add(new FragmentMock2Receiver());
        return fragments;
    }

    private List<Fragment> getFragments() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new FragmentMock1());
        fragments.add(new FragmentMock2());
// Path: rx_gcm/src/main/java/rx_gcm/GcmReceiverUIForeground.java
// public interface GcmReceiverUIForeground {
//     /**
//      * Called when Activity or Fragment matches with the desired target specified in the bundle notification.
//      * @see GcmReceiverUIForeground
//      */
//     void onTargetNotification(Observable<Message> oMessage);
// 
//     /**
//      * Called when Activity or Fragment does not match with the desired target specified in the bundle notification.
//      * @see GcmReceiverUIForeground
//      */
//     void onMismatchTargetNotification(Observable<Message> oMessage);
// 
//     /**
//      * Determines if the implementing class is interested on be notified when updating the data model or seeking for the activity/fragment to be notified.
//      * @param key The value provided in the bundle notification by the server
//      * @return true if the implementing class is interested on be notified
//      */
//     boolean matchesTarget(String key);
// }
// 
// Path: rx_gcm/src/main/java/rx_gcm/Message.java
// public class Message {
//     private final String from;
//     private final Bundle payload;
//     private final String target;
//     private final Application application;
// 
//     public Message(String from, Bundle payload, String target, Application application) {
//         this.from = from;
//         this.payload = payload;
//         this.target = target;
//         this.application = application;
//     }
// 
//     public String from() {
//         return from;
//     }
// 
//     @Nullable public String target() {
//         return target;
//     }
// 
//     public Bundle payload() {
//         return payload;
//     }
// 
//     public Application application() {
//         return application;
//     }
// }


// Path: rx_gcm/src/test/java/rx_gcm/internal/GetGcmReceiversUIForegroundTestData.java
import rx_gcm.Message;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx_gcm.GcmReceiverUIForeground;

        assertThat(wrapper.isTargetScreen(), is(false));
        assertThat(wrapper.gcmReceiverUIForeground() instanceof FragmentMock1Receiver, is(true));

        reset(fragmentManagerMock);
        when(fragmentManagerMock.getFragments()).thenReturn(new ArrayList<Fragment>());

        wrapper = getGcmReceiversUIForegroundUT.retrieve(targetScreen, activityMockReceiver);
        assertThat(wrapper.isTargetScreen(), is(false));
        assertThat(wrapper.gcmReceiverUIForeground() instanceof ActivityMockReceiver, is(true));
    }

    @Test public void When_No_One_GcmReceiverUIForeground_Return_Null_Wrapper() {
        when(fragmentManagerMock.getFragments()).thenReturn(getFragments());
        when(activityMock.getSupportFragmentManager()).thenReturn(fragmentManagerMock);

        GetGcmReceiversUIForeground.Wrapper wrapper = getGcmReceiversUIForegroundUT.retrieve("no one", activityMock);
        assertNull(wrapper);
    }

    private List<Fragment> getFragmentsReceivers() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new FragmentMock1Receiver());
        fragments.add(new FragmentMock2Receiver());
        return fragments;
    }

    private List<Fragment> getFragments() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new FragmentMock1());
        fragments.add(new FragmentMock2());
        return fragments;