Package com.atlassian.jira.rest.client.api.domain.util

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


    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

    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

    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

    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

  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

  @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

  @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

  @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

  @Test
  public void testExtractErrors4() throws JSONException {
    final String str = ResourceUtil.getStringFromResource("/json/error/valid4.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"));
    Assert.assertEquals(errorCollection.getErrors().get("a"), "y");
    Assert.assertEquals(errorCollection.getErrors().get("c"), "z");
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.api.domain.util.ErrorCollection

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.