Package org.sonar.server.exceptions

Examples of org.sonar.server.exceptions.BadRequestException


      public boolean apply(Action action) {
        return action.key().equals(actionKey);
      }
    }, null);
    if (action == null) {
      throw new BadRequestException("The action : '" + actionKey + "' is unknown");
    }
    return action;
  }
View Full Code Here


    projectOperations.removeAllProjects(profileId, UserSession.get());
  }

  private void checkProfileNameParam(String name) {
    if (Strings.isNullOrEmpty(name)) {
      throw new BadRequestException("quality_profiles.please_type_profile_name");
    }
  }
View Full Code Here

    assertThat(context.getLimit()).isEqualTo(100);
    assertThat(context.getPage()).isEqualTo(1);
  }

  private void checkBadRequestException(Exception e, String key, Object... params) {
    BadRequestException exception = (BadRequestException) e;
    Message msg = exception.errors().messages().get(0);
    assertThat(msg.getKey()).isEqualTo(key);
    assertThat(msg.getParams()).containsOnly(params);
  }
View Full Code Here

  }

  private void parse(Map<String, Object> props, @Nullable String comment) {
    this.issues = sanitizeList(RubyUtils.toStrings(props.get("issues")));
    if (issues == null || issues.isEmpty()) {
      throw new BadRequestException("issue_bulk_change.error.empty_issues");
    }
    actions = sanitizeList(RubyUtils.toStrings(props.get("actions")));
    if (actions == null || actions.isEmpty()) {
      throw new BadRequestException("issue_bulk_change.error.need_one_action");
    }
    for (String action : actions) {
      Map<String, Object> actionProperties = getActionProps(action, props);
      propertiesByActions.put(action, actionProperties);
    }
View Full Code Here

    return profilesByName;
  }

  private void processValidationMessages(ValidationMessages messages) {
    if (!messages.getErrors().isEmpty()) {
      throw new BadRequestException(messages);
    }
  }
View Full Code Here

    }
  }

  private Object badRequestIfNullResult(@Nullable Object component, String objectType, String objectKey) {
    if (component == null) {
      throw new BadRequestException(String.format(NOT_FOUND_FORMAT, objectType, objectKey));
    }
    return component;
  }
View Full Code Here

    try {
      validation.validate("abc", newArrayList("a", "b", "c"));
      fail();
    } catch (Exception e) {
      assertThat(e).isInstanceOf(BadRequestException.class);
      BadRequestException badRequestException = (BadRequestException) e;
      assertThat(badRequestException.firstError().getParams()[0]).isEqualTo("abc");
      assertThat(badRequestException.firstError().getParams()[1]).isEqualTo("a, b, c");
    }
  }
View Full Code Here

  static Long parseId(Request request, String paramName) {
    try {
      return Long.valueOf(request.mandatoryParam(paramName));
    } catch (NumberFormatException badFormat) {
      throw new BadRequestException(paramName + " must be a valid long value");
    }
  }
View Full Code Here

      TypeValidations typeValidations = new TypeValidations(newArrayList(fakeTypeValidation));
      typeValidations.validate("10", "Unknown", null);
      fail();
    } catch (Exception e) {
      assertThat(e).isInstanceOf(BadRequestException.class);
      BadRequestException badRequestException = (BadRequestException) e;
      assertThat(badRequestException.firstError().getKey()).isEqualTo("Type 'Unknown' is not valid.");
    }
  }
View Full Code Here

    try {
      validation.validate("abc", null);
      fail();
    } catch (Exception e) {
      assertThat(e).isInstanceOf(BadRequestException.class);
      BadRequestException badRequestException = (BadRequestException) e;
      assertThat(badRequestException.firstError().getParams()[0]).isEqualTo("abc");
    }
  }
View Full Code Here

TOP

Related Classes of org.sonar.server.exceptions.BadRequestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.