// 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/main/java/rx_gcm/TokenUpdate.java
// public class TokenUpdate {
//     private final String token;
//     private final Application application;
// 
//     public TokenUpdate(String token, Application application) {
//         this.token = token;
//         this.application = application;
//     }
// 
//     public String getToken() {
//         return token;
//     }
// 
//     public Application getApplication() {
//         return application;
//     }
// }


import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Application;
import android.os.Bundle;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.List;
import rx.observers.TestSubscriber;
import rx_gcm.Message;
import rx_gcm.TokenUpdate;
                .register(applicationMock, GcmReceiverDataMock.class, GcmReceiverMockUIBackground.class)
                .subscribe(subscriberMock);
        subscriberMock.awaitTerminalEvent();

        subscriberMock.assertNoValues();
        subscriberMock.assertNoErrors();
        subscriberMock.assertCompleted();

        verify(getGcmServerTokenMock, times(0)).retrieve(applicationMock);
    }

    @Test public void When_Call_Current_Token_And_There_Is_A_Token_Emit_It() {
        when(persistenceMock.getToken(applicationMock)).thenReturn(MOCK_TOKEN);

        TestSubscriber<String> subscriberMock = new TestSubscriber<>();
        RxGcm.Notifications.currentToken().subscribe(subscriberMock);
        subscriberMock.awaitTerminalEvent();

        subscriberMock.assertValue(MOCK_TOKEN);
        subscriberMock.assertNoErrors();
    }

    @Test public void When_Call_On_Token_Refresh_Emit_Properly_Item() throws Exception {
        TestSubscriber<TokenUpdate> subscriberMock = GcmRefreshTokenReceiverMock.initSubscriber();
        when(persistenceMock.getClassNameGcmRefreshTokenReceiver(applicationMock)).thenReturn(GcmRefreshTokenReceiverMock.class.getName());

        when(getGcmServerTokenMock.retrieve(applicationMock)).thenReturn(MOCK_TOKEN);
        RxGcm.Notifications.onTokenRefreshed();
        subscriberMock.awaitTerminalEvent();
        subscriberMock.assertNoErrors();
// 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/main/java/rx_gcm/TokenUpdate.java
// public class TokenUpdate {
//     private final String token;
//     private final Application application;
// 
//     public TokenUpdate(String token, Application application) {
//         this.token = token;
//         this.application = application;
//     }
// 
//     public String getToken() {
//         return token;
//     }
// 
//     public Application getApplication() {
//         return application;
//     }
// }


// Path: rx_gcm/src/test/java/rx_gcm/internal/RxGcmTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Application;
import android.os.Bundle;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.List;
import rx.observers.TestSubscriber;
import rx_gcm.Message;
import rx_gcm.TokenUpdate;

                .register(applicationMock, GcmReceiverDataMock.class, GcmReceiverMockUIBackground.class)
                .subscribe(subscriberMock);
        subscriberMock.awaitTerminalEvent();

        subscriberMock.assertNoValues();
        subscriberMock.assertNoErrors();
        subscriberMock.assertCompleted();

        verify(getGcmServerTokenMock, times(0)).retrieve(applicationMock);
    }

    @Test public void When_Call_Current_Token_And_There_Is_A_Token_Emit_It() {
        when(persistenceMock.getToken(applicationMock)).thenReturn(MOCK_TOKEN);

        TestSubscriber<String> subscriberMock = new TestSubscriber<>();
        RxGcm.Notifications.currentToken().subscribe(subscriberMock);
        subscriberMock.awaitTerminalEvent();

        subscriberMock.assertValue(MOCK_TOKEN);
        subscriberMock.assertNoErrors();
    }

    @Test public void When_Call_On_Token_Refresh_Emit_Properly_Item() throws Exception {
        TestSubscriber<TokenUpdate> subscriberMock = GcmRefreshTokenReceiverMock.initSubscriber();
        when(persistenceMock.getClassNameGcmRefreshTokenReceiver(applicationMock)).thenReturn(GcmRefreshTokenReceiverMock.class.getName());

        when(getGcmServerTokenMock.retrieve(applicationMock)).thenReturn(MOCK_TOKEN);
        RxGcm.Notifications.onTokenRefreshed();
        subscriberMock.awaitTerminalEvent();
        subscriberMock.assertNoErrors();
        TokenUpdate token1 = subscriberMock.getOnNextEvents().get(0);