/**
   * Test - AONE-13000:Combination - Account and Case
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Account Identifier Search text of the CRM search form, enter 001b0000009aPo1AAE
   *   <li>In the Account Name Search text of the CRM search form, enter helloaccount
   *   <li>In the Case Number Search text of the CRM search form, enter 00001006
   *   <li>In the Case Name Search text of the CRM search form, enter 00001006
   *   <li>Validate the search results is same for all combinations of search and any one of the
   *       result item should be from helloaccountoppor folder.
   * </ul>
   */
  @Test
  public void AONE_13881() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with Account Name and Contract Number
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.ACCOUNT_NAME.getSearchKeys(), accountName);
    keyWordSearchText.put(SearchKeys.CASE_NUMBER.getSearchKeys(), caseNameOrNumber);

    List<SearchResult> results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));

    // Advance CRM Search with Account Name, Identifier, Case Number and Case Name.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.ACCOUNT_NAME.getSearchKeys(), accountName);
    keyWordSearchText.put(SearchKeys.CASE_NAME.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.CASE_NUMBER.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.ACCOUNT_IDENTIFIER.getSearchKeys(), accountIdentifier);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));

    // Retrieving the folderNames from folderPath of the first resultItem.
    List<String> folders = ((SearchResultItem) results.get(0)).getFolderNamesFromContentPath();

    Assert.assertTrue(folders.get(0).equalsIgnoreCase(attachments_Folder));
    Assert.assertTrue(folders.get(1).equalsIgnoreCase(caseNameOrNumber));

    // Advance CRM Search with Account Identifier and Case Name.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NAME.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.ACCOUNT_IDENTIFIER.getSearchKeys(), accountIdentifier);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));

    // Advance CRM Search with Account Identifier and Case Number.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NUMBER.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.ACCOUNT_IDENTIFIER.getSearchKeys(), accountIdentifier);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));
  }
  /**
   * Test - Cloud-2850:Case Search based on Case number
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Case Number Search text of the CRM search form, enter 00001006
   *   <li>Validate the search results, any one of the result item should be from 00001006 folder.
   * </ul>
   */
  @Test
  public void AONE_13876() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with Case Number
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NUMBER.getSearchKeys(), caseNameOrNumber);
    List<SearchResult> results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);

    // Retrieving the folderNames from folderPath of the first resultItem.
    List<String> folders = ((SearchResultItem) results.get(0)).getFolderNamesFromContentPath();
    Assert.assertTrue(folders.get(0).equalsIgnoreCase(attachments_Folder));
    Assert.assertTrue(folders.get(1).equalsIgnoreCase(caseNameOrNumber));
  }