/**
  * Verifies, whether value exists in row..
  *
  * @param row The row of the cell.
  * @param rowOperator the row header operator
  * @param value The cell text to verify.
  * @param operator The operation used to verify
  * @param searchType Determines where the search begins ("relative" or "absolute")
  * @param exists true if value exists, false otherwise
  * @throws StepExecutionException If the row or the column is invalid, or if the rendered text
  *     cannot be extracted.
  */
 public void rcVerifyValueInRow(
     final String row,
     final String rowOperator,
     final String value,
     final String operator,
     final String searchType,
     boolean exists)
     throws StepExecutionException {
   final TreeTableOperationContext adapter = getContext();
   final int implRow = adapter.getRowFromString(row, rowOperator);
   boolean valueIsExisting = false;
   // if row is header
   if (implRow == -1) {
     for (int i = getStartingColIndex(searchType); i < adapter.getColumnCount(); ++i) {
       if (MatchUtil.getInstance().match(adapter.getColumnHeaderText(i), value, operator)) {
         valueIsExisting = true;
         break;
       }
     }
   } else {
     for (int i = getStartingColIndex(searchType); i < adapter.getColumnCount(); ++i) {
       if (MatchUtil.getInstance().match(getCellText(implRow, i), value, operator)) {
         valueIsExisting = true;
         break;
       }
     }
   }
   Verifier.equals(exists, valueIsExisting);
 }
예제 #2
0
 /**
  * @param value The value to check
  * @param operator The operator used to verify
  * @return <code>true</code> if the combobox contains an element rendered with the passed value
  */
 private boolean containsValue(String value, String operator) {
   String[] comboValues = getCBAdapter().getValues();
   for (int i = 0; i < comboValues.length; i++) {
     boolean contains = MatchUtil.getInstance().match(comboValues[i], value, operator);
     if (contains) {
       return contains;
     }
   }
   return false;
 }
 /**
  * Looks if value exists in the Column.
  *
  * @param adapter the table adapter working on.
  * @param implCol the implementation column of the cell.
  * @param value the cell text to verify.
  * @param operator The operation used to verify.
  * @param searchType searchType Determines where the search begins ("relative" or "absolute")
  * @return <code>true</code> it the value exists in the column
  */
 private boolean isValueExisting(
     TreeTableOperationContext adapter,
     int implCol,
     String value,
     String operator,
     final String searchType) {
   final int rowCount = adapter.getRowCount();
   for (int i = getStartingRowIndex(searchType); i < rowCount; ++i) {
     if (MatchUtil.getInstance().match(getCellText(i, implCol), value, operator)) {
       return true;
     }
   }
   if (adapter.isHeaderVisible()) {
     String header = adapter.getColumnHeaderText(implCol);
     if (MatchUtil.getInstance().match(header, value, operator)) {
       return true;
     }
   }
   return false;
 }
  /**
   * Finds the first column which contains the value <code>value</code> in the given row and selects
   * the cell.
   *
   * @param row the row
   * @param rowOperator the row header operator
   * @param value the value
   * @param regex search using regex
   * @param extendSelection Should this selection be part of a multiple selection
   * @param searchType Determines where the search begins ("relative" or "absolute")
   * @param co the click options to use
   */
  protected void selectCellByColValue(
      String row,
      String rowOperator,
      final String value,
      final String regex,
      final String extendSelection,
      final String searchType,
      ClickOptions co) {
    TreeTableOperationContext adapter = getContext();
    final int implRow = adapter.getRowFromString(row, rowOperator);
    int colCount = adapter.getColumnCount();
    Integer implCol = null;
    if (implRow == -1) {

      for (int i = getStartingColIndex(searchType); i < colCount; ++i) {
        if (MatchUtil.getInstance().match(adapter.getColumnHeaderText(i), value, regex)) {
          implCol = new Integer(i);
          break;
        }
      }
    } else {
      for (int i = getStartingColIndex(searchType); i < colCount; ++i) {
        if (MatchUtil.getInstance().match(getCellText(implRow, i), value, regex)) {

          implCol = new Integer(i);
          break;
        }
      }
    }
    if (implCol == null) {
      throw new StepExecutionException(
          "no such cell found",
          EventFactory //$NON-NLS-1$
              .createActionError(TestErrorEvent.NOT_FOUND));
    }

    String usrIdxRowStr = new Integer(IndexConverter.toUserIndex(implRow)).toString();
    String usrIdxColStr = new Integer(IndexConverter.toUserIndex(implCol.intValue())).toString();

    selectCell(usrIdxRowStr, rowOperator, usrIdxColStr, MatchUtil.EQUALS, co, extendSelection);
  }
  /**
   * Finds the first row which contains the value <code>value</code> in column <code>col</code> and
   * selects this row.
   *
   * @param col the column
   * @param colOperator the column header operator
   * @param value the value
   * @param regexOp the regex operator
   * @param extendSelection Should this selection be part of a multiple selection
   * @param searchType Determines where the search begins ("relative" or "absolute")
   * @param co the clickOptions to use
   */
  protected void selectRowByValue(
      String col,
      String colOperator,
      final String value,
      final String regexOp,
      final String extendSelection,
      final String searchType,
      ClickOptions co) {
    TreeTableOperationContext adapter = getContext();
    final int implCol = adapter.getColumnFromString(col, colOperator, true);
    Integer implRow = null;
    final int rowCount = adapter.getRowCount();

    for (int i = getStartingRowIndex(searchType); i < rowCount; ++i) {
      if (MatchUtil.getInstance().match(getCellText(i, implCol), value, regexOp)) {

        implRow = new Integer(i);
        break;
      }
    }
    if (implRow == null) {
      String header = adapter.getColumnHeaderText(implCol);
      if (MatchUtil.getInstance().match(header, value, regexOp)) {
        implRow = new Integer(-1);
      }
    }

    if (implRow == null) {
      throw new StepExecutionException(
          "no such row found", //$NON-NLS-1$
          EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
    }

    String userIdxRow = new Integer(IndexConverter.toUserIndex(implRow.intValue())).toString();
    String userIdxCol = new Integer(IndexConverter.toUserIndex(implCol)).toString();

    selectCell(userIdxRow, MatchUtil.EQUALS, userIdxCol, colOperator, co, extendSelection);
  }
예제 #6
0
  /**
   * Selects a value from the list of the combobox
   *
   * @param value The value to select
   * @param operator if regular expressions are used
   * @param searchType Determines where the search begins ("relative" or "absolute")
   */
  public void rcSelectValue(String value, String operator, final String searchType) {
    String[] comboValues = getCBAdapter().getValues();
    Validate.notNull(value, "text must not be null"); // $NON-NLS-1$

    int index = -1;

    for (int i = getStartingIndex(searchType); i < comboValues.length; ++i) {
      String str = comboValues[i];
      if (MatchUtil.getInstance().match(str, value, operator)) {
        index = i;
        break;
      }
    }
    if (index < 0) {
      throw new StepExecutionException(
          "Text '"
              + value //$NON-NLS-1$
              + "' not found", //$NON-NLS-1$
          EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
    }

    getCBAdapter().select(index);
  }