@UsesMocks({SocializeConfig.class, MockContext.class, Intent.class})
  public void test_registerC2DM() {
    final String senderId = "foobar";

    NotificationRegistrationState notificationRegistrationState =
        AndroidMock.createMock(NotificationRegistrationState.class);
    SocializeConfig config = AndroidMock.createMock(SocializeConfig.class);
    MockContext context = AndroidMock.createNiceMock(MockContext.class);
    final Intent registrationIntent = AndroidMock.createMock(Intent.class);

    AndroidMock.expect(notificationRegistrationState.isC2dmPending()).andReturn(false);

    notificationRegistrationState.setC2dmPendingRequestTime(AndroidMock.anyLong());
    notificationRegistrationState.save(context);

    AndroidMock.expect(config.getProperty(SocializeConfig.SOCIALIZE_C2DM_SENDER_ID))
        .andReturn(senderId);

    AndroidMock.expect(
            registrationIntent.putExtra(
                SocializeNotificationRegistrationSystem.EXTRA_APPLICATION_PENDING_INTENT,
                (PendingIntent) null))
        .andReturn(registrationIntent);
    AndroidMock.expect(
            registrationIntent.putExtra(
                SocializeNotificationRegistrationSystem.EXTRA_SENDER, senderId))
        .andReturn(registrationIntent);
    AndroidMock.expect(context.startService(registrationIntent)).andReturn(null);

    AndroidMock.replay(notificationRegistrationState, config, context, registrationIntent);

    SocializeNotificationRegistrationSystem system =
        new SocializeNotificationRegistrationSystem() {
          @Override
          public boolean isRegisteredC2DM() {
            return false;
          }

          @Override
          protected Intent newIntent(String action) {
            return registrationIntent;
          }

          @Override
          protected PendingIntent newPendingIntent(Context context) {
            return null;
          }
        };

    system.setConfig(config);
    system.setNotificationRegistrationState(notificationRegistrationState);

    system.registerC2DM(context);

    AndroidMock.verify(notificationRegistrationState, config, context, registrationIntent);
  }
  public void test_registerSocialize() {
    NotificationRegistrationState notificationRegistrationState =
        AndroidMock.createMock(NotificationRegistrationState.class);
    notificationRegistrationState.setPendingSocializeRequestTime(AndroidMock.anyLong());
    notificationRegistrationState.save(getContext());

    final SocializeSession session = AndroidMock.createMock(SocializeSession.class);
    final String registrationId = "foobar";

    SocializeUserSystem userSystem =
        new SocializeUserSystem(null) {
          @Override
          public void authenticate(
              Context context,
              SocializeAuthListener listener,
              SocializeSessionConsumer sessionConsumer) {
            listener.onAuthSuccess(session);
          }
        };

    SocializeNotificationRegistrationSystem system =
        new SocializeNotificationRegistrationSystem() {
          @Override
          protected void doRegistrationSocialize(
              Context context, SocializeSession session, String registrationId) {
            addResult(0, session);
          }
        };

    system.setUserSystem(userSystem);
    system.setNotificationRegistrationState(notificationRegistrationState);

    AndroidMock.replay(notificationRegistrationState, session);

    system.registerSocialize(getContext(), registrationId);

    AndroidMock.verify(notificationRegistrationState, session);

    SocializeSession result = getResult(0);

    assertSame(session, result);
  }