@VisibleForTesting
  DefaultIssueFilter createIssueFilterResult(
      Map<String, String> params, boolean checkId, boolean checkUser) {
    String id = params.get(ID_PARAM);
    String name = params.get(NAME_PARAM);
    String description = params.get(DESCRIPTION_PARAM);
    String data = params.get("data");
    String user = params.get(USER_PARAM);
    Boolean sharedParam = RubyUtils.toBoolean(params.get("shared"));
    boolean shared = sharedParam != null ? sharedParam : false;

    if (checkId) {
      Validation.checkMandatoryParameter(id, ID_PARAM);
    }
    if (checkUser) {
      Validation.checkMandatoryParameter(user, USER_PARAM);
    }
    Validation.checkMandatorySizeParameter(name, NAME_PARAM, 100);
    checkOptionalSizeParameter(description, DESCRIPTION_PARAM, 4000);

    DefaultIssueFilter defaultIssueFilter =
        DefaultIssueFilter.create(name)
            .setDescription(description)
            .setShared(shared)
            .setUser(user)
            .setData(data);
    if (!Strings.isNullOrEmpty(id)) {
      defaultIssueFilter.setId(Long.valueOf(id));
    }
    return defaultIssueFilter;
  }
Ejemplo n.º 2
0
 static ComponentQuery toQuery(Map<String, Object> props) {
   ComponentQuery.Builder builder =
       ComponentQuery.builder()
           .keys(RubyUtils.toStrings(props.get("keys")))
           .names(RubyUtils.toStrings(props.get("names")))
           .qualifiers(RubyUtils.toStrings(props.get("qualifiers")))
           .pageSize(RubyUtils.toInteger(props.get("pageSize")))
           .pageIndex(RubyUtils.toInteger(props.get("pageIndex")));
   String sort = (String) props.get("sort");
   if (!Strings.isNullOrEmpty(sort)) {
     builder.sort(sort);
     builder.asc(RubyUtils.toBoolean(props.get("asc")));
   }
   return builder.build();
 }