Examples of ErrorCollection


Examples of com.atlassian.bamboo.utils.error.ErrorCollection

    return config;
  }

  @NotNull
  public ErrorCollection validate(@NotNull BuildConfiguration buildConfiguration)  {
    ErrorCollection errorCollection = super.validate(buildConfiguration);

        String repName = buildConfiguration.getString(Constants.PLASTIC_REPOSITORY);
        String repServer = buildConfiguration.getString(Constants.PLASTIC_REPOSITORYSERVER);
        String branch = buildConfiguration.getString(Constants.PLASTIC_BRANCH_TO_TRACK);

    if (repName == null || repName.trim().length() == 0) {
      errorCollection.addError(Constants.PLASTIC_REPOSITORY, "The repository name must be specified");
    }

    try  {
            BranchInfo brInfo;
            if (branch.equals(Constants.BR_NAME))
                brInfo = Utils.getBranchInfo(Constants.MAIN, repName, repServer);
            else
                brInfo = Utils.getBranchInfo(branch, repName, repServer);

            if (brInfo == null)
                throw new Exception("Branch not found:" + branch);
    }
    catch(Exception ex) {
      errorCollection.addError(Constants.PLASTIC_BRANCH_TO_TRACK,
                    "The specified branch does not exist in the specified repository and server.");
    }
    return errorCollection;
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

    setAnonymousMode();
    try {
      testAddWorklogImpl(ISSUE_KEY, createDefaulWorklogInputBuilder());
      fail("error expected, no permissions");
    } catch (RestClientException ex) {
      final ErrorCollection errors = Iterators.getOnlyElement(ex.getErrorCollections().iterator());
      assertThat(errors.getErrorMessages(),
          containsInAnyOrder("You do not have the permission to see the specified issue.", "Login Required"));
    }
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

    if (jsonErrors != null && jsonErrors.length() > 0) {
      errors = JsonParseUtil.toStringMap(jsonErrors.names(), jsonErrors);
    } else {
      errors = Collections.emptyMap();
    }
    return new ErrorCollection(status, errorMessages, errors);
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

    this.statusCode = Optional.of(statusCode);
  }

  public RestClientException(final String errorMessage, final Throwable cause) {
    super(errorMessage, cause);
    this.errorCollections = ImmutableList.of(new ErrorCollection(errorMessage));
    statusCode = Optional.absent();
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

    if (jsonErrors != null && jsonErrors.length() > 0) {
      errors = JsonParseUtil.toStringMap(jsonErrors.names(), jsonErrors);
    } else {
      errors = Collections.emptyMap();
    }
    return new ErrorCollection(status, errorMessages, errors);
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

    this.statusCode = Optional.of(statusCode);
  }

  public RestClientException(final String errorMessage, final Throwable cause) {
    super(errorMessage, cause);
    this.errorCollections = ImmutableList.of(new ErrorCollection(errorMessage));
    statusCode = Optional.absent();
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

  public static void assertErrorCodeWithRegexp(int errorCode, String regExp, Runnable runnable) {
    try {
      runnable.run();
      Assert.fail(RestClientException.class + " exception expected");
    } catch (com.atlassian.jira.rest.client.api.RestClientException ex) {
      final ErrorCollection errorElement = getOnlyElement(ex.getErrorCollections().iterator());
      final String errorMessage = getOnlyElement(errorElement.getErrorMessages().iterator());
      Assert.assertTrue("'" + ex.getMessage() + "' does not match regexp '" + regExp + "'", errorMessage.matches(regExp));
      Assert.assertTrue(ex.getStatusCode().isPresent());
      Assert.assertEquals(errorCode, ex.getStatusCode().get().intValue());
    }
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

  @Test
  public void testExtractErrors() throws JSONException {
    final String str = ResourceUtil.getStringFromResource("/json/error/valid.json");
    final Collection<ErrorCollection> errors = AbstractAsynchronousRestClient.extractErrors(BAD_REQUEST, str);
    final ErrorCollection errorCollection = Iterators.getOnlyElement(errors.iterator());
    Assert.assertThat(errorCollection.getErrors().values(), IsIterableContainingInAnyOrder.containsInAnyOrder("abcfsd"));
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

  @Test
  public void testExtractErrors2() throws JSONException {
    final String str = ResourceUtil.getStringFromResource("/json/error/valid2.json");
    final Collection<ErrorCollection> errors = AbstractAsynchronousRestClient.extractErrors(BAD_REQUEST, str);
    final ErrorCollection errorCollection = Iterators.getOnlyElement(errors.iterator());
    Assert.assertThat(errorCollection.getErrorMessages(), IsIterableContainingInAnyOrder.containsInAnyOrder("a", "b", "xxx"));
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

  @Test
  public void testExtractErrors3() throws JSONException {
    final String str = ResourceUtil.getStringFromResource("/json/error/valid3.json");
    final Collection<ErrorCollection> errors = AbstractAsynchronousRestClient.extractErrors(BAD_REQUEST, str);
    final ErrorCollection errorCollection = Iterators.getOnlyElement(errors.iterator());
    Assert.assertThat(errorCollection.getErrors().values(), IsIterableContainingInAnyOrder.containsInAnyOrder("aa", "bb"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.