예제 #1
0
  /**
   * Checks if the given user exist.
   *
   * @param user
   * @return
   * @throws TestLinkAPIException
   */
  protected Boolean doesUserExist(String user) throws TestLinkAPIException {
    Boolean userExist = false;

    try {
      Map<String, Object> executionData = new HashMap<String, Object>();
      executionData.put(TestLinkParams.USER.toString(), user);
      Object response =
          this.executeXmlRpcCall(TestLinkMethods.DOES_USER_EXIST.toString(), executionData);
      userExist = Boolean.valueOf(response.toString());
    } catch (XmlRpcException xmlrpcex) {
      throw new TestLinkAPIException(
          "Error verifying if user exists: " + xmlrpcex.getMessage(), xmlrpcex);
    }

    return userExist;
  }
예제 #2
0
  /**
   * Get user by login.
   *
   * @param login
   * @return user
   * @throws TestLinkAPIException
   */
  @SuppressWarnings("unchecked")
  protected User getUserByLogin(String login) throws TestLinkAPIException {
    User user = null;

    try {
      Map<String, Object> executionData = new HashMap<String, Object>();
      executionData.put(TestLinkParams.USER.toString(), login);
      Object response =
          this.executeXmlRpcCall(TestLinkMethods.GET_USER_BY_LOGIN.toString(), executionData);
      Object[] responseArray = Util.castToArray(response);
      Map<String, Object> responseMap = (Map<String, Object>) responseArray[0];
      user = Util.getUser(responseMap);
    } catch (XmlRpcException xmlrpcex) {
      throw new TestLinkAPIException(
          "Error verifying if user exists: " + xmlrpcex.getMessage(), xmlrpcex);
    }

    return user;
  }