@UsesMocks({
    NotificationAuthenticator.class,
    ActivitySystem.class,
    SocializeSession.class,
    SocializeAction.class,
    User.class,
    NotificationMessage.class
  })
  public void test_translate() throws SocializeException {

    NotificationAuthenticator notificationAuthenticator =
        AndroidMock.createMock(NotificationAuthenticator.class);
    ActivitySystem activitySystem = AndroidMock.createMock(ActivitySystem.class);
    SocializeSession session = AndroidMock.createMock(SocializeSession.class);
    SocializeAction action = AndroidMock.createMock(SocializeAction.class);
    User user = AndroidMock.createMock(User.class);
    NotificationMessage message = AndroidMock.createMock(NotificationMessage.class);

    final long actionId = 69L;
    final long userId = 1001L;
    final ActionType type = ActionType.COMMENT;
    final Context context = getContext();

    AndroidMock.expect(message.getActionId()).andReturn(actionId).anyTimes();
    AndroidMock.expect(message.getActionType()).andReturn(type).anyTimes();
    AndroidMock.expect(notificationAuthenticator.authenticate(context)).andReturn(session);
    AndroidMock.expect(activitySystem.getAction(session, actionId, type)).andReturn(action);
    AndroidMock.expect(action.getUser()).andReturn(user);
    AndroidMock.expect(user.getId()).andReturn(userId).anyTimes();

    AndroidMock.replay(notificationAuthenticator, activitySystem, session, action, user, message);

    SocializeActionMessageTranslator translator = new SocializeActionMessageTranslator();
    Bundle data = new Bundle();

    translator.setActivitySystem(activitySystem);
    translator.setNotificationAuthenticator(notificationAuthenticator);

    SocializeAction translated = translator.translate(context, data, message);

    AndroidMock.verify(notificationAuthenticator, activitySystem, session, action, user, message);

    assertNotNull(translated);
    assertSame(action, translated);
    assertNotNull(data.getString(Socialize.ACTION_ID));
    assertNotNull(data.getString(Socialize.USER_ID));

    assertEquals(String.valueOf(actionId), data.getString(Socialize.ACTION_ID));
    assertEquals(String.valueOf(userId), data.getString(Socialize.USER_ID));
  }
  protected void verifyProviderCredentialsForUser(WritableSession session, User user) {
    List<UserAuthData> authData = user.getAuthData();
    UserProviderCredentialsMap credentials = session.getUserProviderCredentials();

    if (credentials != null) {

      if (authData != null) {
        Map<AuthProviderType, UserProviderCredentials> validCreds =
            new LinkedHashMap<AuthProviderType, UserProviderCredentials>();
        for (UserAuthData userAuthData : authData) {
          UserProviderCredentials creds = credentials.get(userAuthData.getAuthProviderType());
          if (creds != null) {
            validCreds.put(userAuthData.getAuthProviderType(), creds);
          }
        }

        // Clear and reset
        credentials.removeAll();

        Set<Entry<AuthProviderType, UserProviderCredentials>> entrySet = validCreds.entrySet();

        for (Entry<AuthProviderType, UserProviderCredentials> entry : entrySet) {
          credentials.put(entry.getKey(), entry.getValue());
        }
      } else {
        credentials.removeAll();
      }

      // Set back to session
      session.setUserProviderCredentials(credentials);
    }
  }
  protected void doGetUserProfile(final long userId, final SocializeAction action) {

    if (userId >= 0 && (currentUser == null || !currentUser.getId().equals(userId))) {
      UserUtils.getUser(
          getActivity(),
          userId,
          new UserGetListener() {

            @Override
            public void onGet(User user) {
              // Set the user details into the view elements
              currentUser = user;
              setUserDetails(user, action);
              countdown();
            }

            @Override
            public void onError(SocializeException error) {
              countdown();
              showError(getContext(), error);
            }
          });
    } else {
      countdown();
    }
  }
  public void testProfileActivityLoadsCorrectData() throws Throwable {

    TestUtils.setupSocializeOverrides(true, true);
    Instrumentation.ActivityMonitor monitor =
        TestUtils.setUpActivityMonitor(this, ProfileActivity.class);

    final User dummy = new User();

    dummy.setId(69L);
    dummy.setFirstName("foo");
    dummy.setLastName("bar");

    SocializeUserUtils userUtils =
        new SocializeUserUtils() {
          @Override
          public void getUser(Context context, long id, UserGetListener listener) {
            listener.onGet(dummy);
          }

          @Override
          public User getCurrentUser(Context context) {
            return dummy;
          }
        };

    SocializeAccess.setUserUtilsProxy(userUtils);

    // Ensure facebook is enabled
    ConfigUtils.getConfig(getContext()).setFacebookAppId("1234567890");
    ConfigUtils.getConfig(getContext())
        .setTwitterKeySecret(
            "U18LUnVjULkkpGoJ6CoP3A", "RiIljnFq4RWV9LEaCM1ZLsAHf053vX2KyhJhmCOlBE");

    UserUtils.showUserSettings(TestUtils.getActivity(this));

    Activity waitForActivity = monitor.waitForActivityWithTimeout(5000);

    assertNotNull(waitForActivity);

    // Check that the user's name is displayed
    assertTrue(TestUtils.lookForText(waitForActivity, "foo", 10000));
    assertTrue(TestUtils.lookForText(waitForActivity, "bar", 10000));

    waitForActivity.finish();
  }
  public void setUserDetails(User user, SocializeAction action) {

    String profilePicData = user.getSmallImageUri();
    final ImageView userIcon = content.getProfilePicture();

    if (!StringUtils.isEmpty(profilePicData)) {
      userIcon.getBackground().setAlpha(64);

      imageLoader.loadImageByUrl(
          profilePicData,
          new ImageLoadListener() {
            @Override
            public void onImageLoadFail(ImageLoadRequest request, Exception error) {
              Log.e(SocializeLogger.LOG_TAG, error.getMessage(), error);
              userIcon.post(
                  new Runnable() {
                    public void run() {
                      userIcon.setImageDrawable(defaultProfilePicture);
                      userIcon.getBackground().setAlpha(255);
                    }
                  });
            }

            @Override
            public void onImageLoad(ImageLoadRequest request, final SafeBitmapDrawable drawable) {
              // Must be run on UI thread
              userIcon.post(
                  new Runnable() {
                    public void run() {
                      drawable.setAlpha(255);
                      userIcon.setImageDrawable(drawable);
                      userIcon.getBackground().setAlpha(255);
                    }
                  });
            }
          });
    } else {
      userIcon.setImageDrawable(defaultProfilePicture);
      userIcon.getBackground().setAlpha(255);
    }

    content.getDisplayName().setText(user.getDisplayName());
    content.loadUserActivity(user, action);
  }
 public MockSocializeSession() {
   super();
   user = new User();
   user.setId(-1L);
 }