Package org.sonatype.plexus.rest.resource.error

Examples of org.sonatype.plexus.rest.resource.error.ErrorMessage


    ErrorResponse payload = (ErrorResponse) representation.getPayload(new ErrorResponse());

    List errors = payload.getErrors();
    assertThat((Collection<?>) errors, hasSize(1));
    ErrorMessage error = (ErrorMessage) errors.get(0);
    String msg = error.getMsg();

    msg = msg.replaceAll(
        "Cannot parse '([^']*)':.*",
        "$1");

View Full Code Here


      throw validationError(name, enumClass);
    }
  }

  private static <E> PlexusResourceException validationError(String name, Class<E> enumClass) {
    ErrorMessage err = new ErrorMessage();
    err.setId("*");
    err.setMsg("No enum const " + enumClass + "." + name);

    ErrorResponse ner = new ErrorResponse();
    ner.addError(err);

    return new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", ner);
View Full Code Here

  // ===

  protected ErrorResponse getNexusErrorResponse(String id, String msg) {
    ErrorResponse ner = new ErrorResponse();
    ErrorMessage ne = new ErrorMessage();
    ne.setId(id);
    ne.setMsg(StringEscapeUtils.escapeHtml(msg));
    ner.addError(ne);
    return ner;
  }
View Full Code Here

    ErrorResponse errorResponse = (ErrorResponse) xstream.fromXML(xml, new ErrorResponse());

    Assert.assertTrue("Error response is empty.", errorResponse.getErrors().size() > 0);

    for (Iterator<ErrorMessage> iter = errorResponse.getErrors().iterator(); iter.hasNext(); ) {
      ErrorMessage error = iter.next();
      Assert.assertFalse("Response Error message is empty.", StringUtils.isEmpty(error.getMsg()));

    }

  }
View Full Code Here

    return securitySystem;
  }

  protected ErrorResponse getErrorResponse(String id, String msg) {
    ErrorResponse ner = new ErrorResponse();
    ErrorMessage ne = new ErrorMessage();
    ne.setId(id);
    ne.setMsg(msg);
    ner.addError(ne);
    return ner;
  }
View Full Code Here

    catch (PlexusResourceException e) {
      ErrorResponse resultObject = (ErrorResponse) e.getResultObject();
      assertThat(resultObject, notNullValue());
      List<ErrorMessage> errors = resultObject.getErrors();
      assertThat(errors, hasSize(1));
      ErrorMessage errorMessage = errors.get(0);

      // ID needs to be stable for UI handling
      assertThat(errorMessage.getId(), equalTo("search"));
      assertThat(errorMessage.getMsg(), containsString("mock"));
    }
  }
View Full Code Here

      resource.post(null, this.buildRequest(), null, resourceRequest);
      Assert.fail("expected PlexusResourceException");
    }
    catch (PlexusResourceException e) {
      ErrorResponse errorResponse = (ErrorResponse) e.getResultObject();
      ErrorMessage errorMessage = (ErrorMessage) errorResponse.getErrors().get(0);
      Assert.assertTrue(errorMessage.getId().contains("email"));
    }

    // now list
    resource.get(null, this.buildRequest(), null, null);
  }
View Full Code Here

      resource.post(null, this.buildRequest(), null, resourceRequest);
      Assert.fail("expected PlexusResourceException");
    }
    catch (PlexusResourceException e) {
      ErrorResponse errorResponse = (ErrorResponse) e.getResultObject();
      ErrorMessage errorMessage = (ErrorMessage) errorResponse.getErrors().get(0);
      Assert.assertTrue(errorMessage.getId().contains("userId"));
    }

    // fix it
    userResource.setUserId("testUserIdWithSpace");
    resource.post(null, this.buildRequest(), null, resourceRequest);
View Full Code Here

      resource.put(null, this.buildRequest(), null, resourceRequest);
      Assert.fail("expected PlexusResourceException");
    }
    catch (PlexusResourceException e) {
      ErrorResponse errorResponse = (ErrorResponse) e.getResultObject();
      ErrorMessage errorMessage = (ErrorMessage) errorResponse.getErrors().get(0);
      Assert.assertTrue(errorMessage.getId().contains("email"));
    }

  }
View Full Code Here

    ErrorResponse errorResponse = (ErrorResponse) xstream.fromXML(xml, new ErrorResponse());

    Assert.assertTrue("Error response is empty.", errorResponse.getErrors().size() > 0);

    for (Iterator<ErrorMessage> iter = errorResponse.getErrors().iterator(); iter.hasNext(); ) {
      ErrorMessage error = iter.next();
      Assert.assertFalse("Response Error message is empty.", StringUtils.isEmpty(error.getMsg()));

    }

  }
View Full Code Here

TOP

Related Classes of org.sonatype.plexus.rest.resource.error.ErrorMessage

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.