/**
   * Test - AONE-12998:Combination - Account and Opportunity
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Account Name Search text of the CRM search form, enter helloaccount
   *   <li>In the Opportunity Name Search text of the CRM search form, enter helloaccountoppor
   *   <li>In the Account Number Search text of the CRM search form, enter 001b0000009aPo1AAE
   *   <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_13879() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with Account Name and Opportunity Name
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.ACCOUNT_NAME.getSearchKeys(), accountName);
    keyWordSearchText.put(SearchKeys.OPPORTUNITY_NAME.getSearchKeys(), oppName);

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

    // Advance CRM Search with Account Name, Opportunity Name and Account
    // Identifier.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.ACCOUNT_NAME.getSearchKeys(), accountName);
    keyWordSearchText.put(SearchKeys.OPPORTUNITY_NAME.getSearchKeys(), oppName);
    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(oppo_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(oppName));

    // Advance CRM Search with Opportunity Name and Account Identifier.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.OPPORTUNITY_NAME.getSearchKeys(), oppName);
    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(oppo_Content));

    // Advance CRM Search with Opportunity Name and Account Identifier.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.OPPORTUNITY_NAME.getSearchKeys(), oppName);
    keyWordSearchText.put(SearchKeys.ACCOUNT_NAME.getSearchKeys(), accountName);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(oppo_Content));
  }
  /**
   * Test - AONE-13001:Negative test case for combination
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Oppo Name Search text of the CRM search form, enter helloaccount
   *   <li>In the Contract Name Search text of the CRM search form, enter 00000104
   *   <li>In the Case Name Search text of the CRM search form, enter 00001006
   *   <li>Validate the search results is zero.
   * </ul>
   */
  @Test
  public void AONE_13882() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with Opportunity Name and Contract Name
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.OPPORTUNITY_NAME.getSearchKeys(), oppName);
    keyWordSearchText.put(SearchKeys.CONTRACT_NAME.getSearchKeys(), contractNameOrNumber);

    List<SearchResult> results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() == 0);

    // Advance CRM Search with Contract Name and Case Name.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NAME.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.CONTRACT_NAME.getSearchKeys(), contractNameOrNumber);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() == 0);
  }