/**
   * Test Case Name: Verify VIC vHBAs components
   *
   * <p>Summary: This test case verifies details of VIC vHBAs component of CiscoUCS/C- Series
   * device.
   *
   * <p>Pre-requisites: Add a new ucs device
   *
   * <p>Post-requisites: Remove the UCS device
   *
   * <p>Author Oscar Valerio
   *
   * @param testCaseId The TC id
   * @param adminUserName The admin user
   * @param adminUserPassword The admin password
   * @param deviceName The UCS device name to use
   * @param ucsType The ucs type
   * @param ucsUserName The ucs user name
   * @param ucsPass The ucs user pass
   * @param ucsCollectorName The ucs collector to assign
   * @throws Exception
   */
  @Test(
      groups = {"tc_1259"},
      priority = 0)
  @Parameters({
    "tc_1259_testcaseid", "tc_1259_username", "tc_1259_password", "tc_1259_device",
    "tc_1259_ucstype", "tc_1259_ucsusername", "tc_1259_ucsuserpass", "tc_1259_ucscollector",
    "tc_1259_ucscomponenttoverify", "tc_1259_ucsexpectdheaders", "tc_1259_ucsexpectddisplayoptions"
  })
  public void verifyVirtualHBAComponents(
      String testCaseId,
      String adminUserName,
      String adminUserPassword,
      String deviceName,
      String ucsType,
      String ucsUserName,
      String ucsPass,
      String ucsCollectorName,
      String ucsComponentToVerify,
      String ucsExpectedHeaders,
      String ucsexpectedDisplayOptions)
      throws Exception {

    CommonPage commonPage = new CommonPage();
    Autoinstall autoinstall = new Autoinstall();
    String[] expectedHeaders = ucsExpectedHeaders.split(ConstantsClass.CHAR_SEPARATOR_ARRAY);
    String[] expectedDisplayOptions =
        ucsexpectedDisplayOptions.split(ConstantsClass.CHAR_SEPARATOR_ARRAY);

    // ** Pre-test
    TestlinkCommands.setTestCaseID(testCaseId);
    setTestCaseSection(TEST_CASE_SECTION_PRETEST);
    LoginCommon.login(adminUserName, adminUserPassword);

    // Remove UCS device if exists
    Assert.assertTrue(
        autoinstall.deleteDevice(getEndPoint(), getTargetNameSpace(), getHostName(), deviceName),
        String.format("[WebService] Error. Device %s was NOT deleted", deviceName));

    // Go to infrastructure page
    DevicesPage devicesPage =
        (DevicesPage) commonPage.navigateTo(ConstantsClass.INFRASTRUCTURE_PAGE);
    Assert.assertTrue(
        devicesPage.checkPage(), "Infrastructure page was not displayed as expected.");

    // Add an UCS device
    DevicesCommon.addUCSDeviceAndWaitForJobToFinish(
        devicesPage, ucsType, deviceName, ucsUserName, ucsPass, ucsCollectorName);
    devicesPage.clickOnRefreshButton();

    // Select the ucs device
    DevicesCommon.selectDeviceInList(devicesPage, deviceName, ConstantsClass.DEVICE_FILTER);
    OverviewPage overviewPage = devicesPage.clickDeviceLink(deviceName);
    Assert.assertTrue(
        overviewPage.checkPage(deviceName), "Overview page was not displayed as expected");

    // Check values
    DeviceDetailPage deviceDetailPage = new DeviceDetailPage();
    Assert.assertEquals(
        deviceDetailPage.getDeviceStatus(),
        ConstantsClass.DEVICE_STATUS_UP,
        "The device status is not Up");

    // ** Test
    setTestCaseSection(TEST_CASE_SECTION_TEST);

    // Select component
    VirtualHBAsPage virtualHBAsPage =
        (VirtualHBAsPage) deviceDetailPage.clickOnDeviceComponents(ucsComponentToVerify);

    // Check headers
    VirtualHBAsCommons.checkComponentTableColumnValues(virtualHBAsPage, expectedHeaders);

    // Check display options
    VirtualHBAsCommons.checkComponentDisplayOPtions(virtualHBAsPage, expectedDisplayOptions);

    // Check collected data
    List<String> VirtualHBANames = virtualHBAsPage.getVirtualHBAColumnValues();
    Assert.assertTrue(VirtualHBANames.size() > 0, "The Virtual HBA table is not displaying data");

    for (String name : VirtualHBANames) {
      softAssert.assertTrue(!name.isEmpty(), "The Virtual HBA name is not defined. It is empty");
    }
    softAssert.assertAll();
    softAssert.clear();

    // *** Post Test
    setTestCaseSection(TEST_CASE_SECTION_POSTTEST);
    Assert.assertTrue(
        autoinstall.deleteDevice(getEndPoint(), getTargetNameSpace(), getHostName(), deviceName),
        String.format("[WebService] Error. Device %s was NOT deleted", deviceName));
  }