コード例 #1
0
  @BeforeClass
  public static void setUp() {
    mockedValidNetworkConnection = spy(stubNetworkConnection);
    when(mockedValidNetworkConnection.isValidated()).thenReturn(Boolean.TRUE);

    mockedInValidNetworkConnection = spy(stubNetworkConnection);
    when(mockedInValidNetworkConnection.isValidated()).thenReturn(Boolean.FALSE);
  }
コード例 #2
0
  @Test
  public void rootUserCanHaveValidSocialNetworkConnection() {
    RootUser user = this.generateRootUser().findRootUser(null);
    assertNotNull(user.addSocialNetworkConnection(mockedValidNetworkConnection));
    assertNotNull(user.getConnection(SocialNetwork.STUB).getSocialNetwork());

    // we should be able to override this;
    SocialNetworkConnection stubConnection = mockedValidNetworkConnection;
    stubConnection.addToken(SocialNetworkToken.TOKEN, "testvalue");
    user.addSocialNetworkConnection(stubConnection);
    assertTrue(
        user.getConnection(stubConnection.getSocialNetwork())
            .getTokens()
            .equals(stubConnection.getTokens()));
  }