Beispiel #1
0
  /**
   * Validate authUser
   *
   * <ul>
   *   <li>If new authUser check for duplicate
   * </ul>
   *
   * @return flag true if validation is successful
   */
  private boolean validate() {
    boolean isvalid = true;
    if (this.authUser.getId() == null) {
      for (AuthUser theUser : this.authUsers) {
        if (this.authUser.getName().equals(theUser.getName())) {
          this.facesContextMessage.errorMessage("{0} already exists", this.authUser.getName());
          logger.error("validate: authUser {} already exists", this.authUser);
          isvalid = false;
          break;
        }
      }
    }

    return isvalid;
  }
  /**
   * save action
   *
   * <p>Update TestCase result based on test step results
   *
   * @throws UCMException
   */
  public void save() throws UCMException {
    try {
      this.testCase.setModifiedBy(authUser.getUsername());
      for (TestCaseStep tcs : this.testCase.getTestCaseSteps()) {
        if (tcs.getTestResultType() != null) {

          this.testCase.setTestResultType(TestResultType.Passed);

          if (tcs.getTestResultType().equals(TestResultType.Failed)) {
            this.testCase.setTestResultType(TestResultType.Failed);
            break;
          }
        } else {
          this.testCase.setTestResultType(TestResultType.Unknown);
        }
      }

      Timestamp now = new Timestamp(System.currentTimeMillis());
      this.testCase.setTestDate(now);

      em.persist(this.testCase);

      logger.info("saved: {}", this.testCase.getArtifact());
      this.facesContextMessage.infoMessage("{0} saved successfully", this.testCase.getArtifact());
    } catch (Exception e) {
      throw new UCMException(e);
    }
  }