コード例 #1
0
ファイル: DashboardView.java プロジェクト: j1cken/rhq
  /**
   * LocatorIds need to be repeatable and non-duplicated. The natural key for a portlet is the Id
   * but the Id is not a good locatorId as it may change (it's a sequence generated id) on
   * subsequent test runs. A portlet has an internal identifier (portletKey) and a name, but the
   * key-name tuple is not guaranteed to be unique as multiple instances of the same portlet type
   * may be present on the same, or across multiple dashboards. There is one tuple that is
   * guaranteed unique and useful for a repeatable locator Id: DashBoard-Position. This means that
   * the on a single dashboard each portlet has a unique column-columnIndex pair. Although portlets
   * can move, and the positions can change at runtime, it's still valid for a locatorId because it
   * is unique and repeatable for test purposes. We also add the portletKey for an easier visual
   * cue. The portalLayout's locatorId already incorporates the dashboardName, so we need only
   * extend it with the positioning information.
   *
   * @param portalLayout
   * @param dashboardPortlet
   * @return The locatorId for the portlet. Form PortleyKey_DashboardId_Column_ColumnIndex
   */
  private String getPortletLocatorId(PortalLayout portalLayout, DashboardPortlet dashboardPortlet) {
    StringBuilder locatorId = new StringBuilder(dashboardPortlet.getPortletKey());
    locatorId.append("_");
    locatorId.append(dashboardPortlet.getColumn());
    locatorId.append("_");
    locatorId.append(dashboardPortlet.getIndex());

    return portalLayout.extendLocatorId(locatorId.toString());
  }