@Test
  public void testGetAccountReferenceFromSeveral() throws Exception {
    doReturn(
            "[{"
                + "roles:[\""
                + SaasAccountServiceProxy.ACCOUNT_OWNER_ROLE
                + "\"],"
                + "accountReference:{id:\""
                + ACCOUNT_ID
                + "\",name:\""
                + ACCOUNT_NAME
                + "\"}"
                + "},{roles:[\""
                + SaasAccountServiceProxy.ACCOUNT_OWNER_ROLE
                + "\"],"
                + "accountReference:{id:\"another-account-id\"}"
                + "}]")
        .when(transport)
        .doGet(endsWith("account"), eq(TOKEN));
    AccountReference accountRef = saasAccountServiceProxy.getAccountWhereUserIsOwner(null, TOKEN);

    assertNotNull(accountRef);
    assertEquals(accountRef.getId(), ACCOUNT_ID);
    assertEquals(accountRef.getName(), ACCOUNT_NAME);
  }
  @Test
  public void testGetAccountReferenceReturnNullIfAccountWasNotFound() throws Exception {
    doReturn(
            "[{"
                + "roles:[\"account/member\"],"
                + "accountReference:{id:\""
                + ACCOUNT_ID
                + "\"}"
                + "}]")
        .when(transport)
        .doGet(endsWith("account"), eq(TOKEN));
    AccountReference accountRef = saasAccountServiceProxy.getAccountWhereUserIsOwner(null, TOKEN);

    assertNull(accountRef);
  }
  @Test
  public void testGetAccountReferenceWithSpecificNameReturnNullIfAccountWasNotFound()
      throws Exception {
    doReturn(
            "[{"
                + "roles:[\""
                + SaasAccountServiceProxy.ACCOUNT_OWNER_ROLE
                + "\"],"
                + "accountReference:{id:\""
                + ACCOUNT_ID
                + "\",name:\""
                + ACCOUNT_NAME
                + "\"}"
                + "}]")
        .when(transport)
        .doGet(endsWith("account"), eq(TOKEN));

    AccountReference accountRef =
        saasAccountServiceProxy.getAccountWhereUserIsOwner("another name", TOKEN);

    assertNull(accountRef);
  }
  @Test(expectedExceptions = IOException.class)
  public void testGetAccountReferenceErrorIfAuthenticationFailed() throws Exception {
    doThrow(AuthenticationException.class).when(transport).doGet(endsWith("account"), eq(TOKEN));

    saasAccountServiceProxy.getAccountWhereUserIsOwner(null, TOKEN);
  }