Package org.apache.olingo.odata2.api.exception

Examples of org.apache.olingo.odata2.api.exception.MessageReference


      throw new UriSyntaxException(UriSyntaxException.INCOMPATIBLELITERAL.addContent(value, expectedType));
    }
  }

  private static UriSyntaxException convertEdmLiteralException(final EdmLiteralException e) {
    final MessageReference messageReference = e.getMessageReference();

    if (EdmLiteralException.LITERALFORMAT.equals(messageReference)) {
      return new UriSyntaxException(UriSyntaxException.LITERALFORMAT.addContent(messageReference.getContent()), e);
    } else if (EdmLiteralException.NOTEXT.equals(messageReference)) {
      return new UriSyntaxException(UriSyntaxException.NOTEXT.addContent(messageReference.getContent()), e);
    } else if (EdmLiteralException.UNKNOWNLITERAL.equals(messageReference)) {
      return new UriSyntaxException(UriSyntaxException.UNKNOWNLITERAL.addContent(messageReference.getContent()), e);
    } else {
      return new UriSyntaxException(ODataBadRequestException.COMMON, e);
    }
  }
View Full Code Here


    errorContext.setErrorCode(toHandleException.getCode());
  }

  private void enhanceContextWithMessageException(final ODataMessageException toHandleException) {
    errorContext.setErrorCode(toHandleException.getErrorCode());
    MessageReference messageReference = toHandleException.getMessageReference();
    Message localizedMessage = messageReference == null ? null : extractEntity(messageReference);
    if (localizedMessage != null) {
      errorContext.setMessage(localizedMessage.getText());
      errorContext.setLocale(localizedMessage.getLocale());
    }
View Full Code Here

  private static final Locale DEFAULT_LANGUAGE = new Locale("test", "foo");

  @Test
  public void testResourceBundleException() throws Exception {
    MessageReference context = MessageReference.create(ODataMessageException.class, "COMMON");
    Message ms = MessageService.getMessage(null, context);

    assertEquals(
        "MessageService could not be created because of exception 'IllegalArgumentException with message " +
        "'Parameter locale MUST NOT be NULL.'.",
View Full Code Here

        ms.getText());
  }

  @Test
  public void test() throws Exception {
    MessageReference context = MessageReference.create(ODataMessageException.class, "COMMON");
    Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

    assertEquals("Common exception", ms.getText());
  }
View Full Code Here

    assertEquals("Common exception", ms.getText());
  }

  @Test
  public void testParameter() throws Exception {
    MessageReference context =
        MessageReference.create(ODataMessageException.class, "ONE_REPLACEMENTS").addContent("first");
    Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

    assertEquals("Only replacement is [first]!", ms.getText());
  }
View Full Code Here

    assertEquals("Only replacement is [first]!", ms.getText());
  }

  @Test
  public void testOneParameterForTwo() throws Exception {
    MessageReference context =
        MessageReference.create(ODataMessageException.class, "TWO_REPLACEMENTS").addContent("first");
    Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

    assertEquals(
        "Missing replacement for place holder in value 'First was [%1$s] and second was [%2$s]!' " +
View Full Code Here

        ms.getText());
  }

  @Test
  public void testTwoParameters() throws Exception {
    MessageReference context =
        MessageReference.create(ODataMessageException.class, "TWO_REPLACEMENTS").addContent("first", "second");
    Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

    assertEquals("First was [first] and second was [second]!", ms.getText());
  }
View Full Code Here

    assertEquals("First was [first] and second was [second]!", ms.getText());
  }

  @Test
  public void testTwoParametersWithTwoAddContent() throws Exception {
    MessageReference context =
        MessageReference.create(ODataMessageException.class, "TWO_REPLACEMENTS").addContent("first").addContent(
            "second");
    Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

    assertEquals("First was [first] and second was [second]!", ms.getText());
View Full Code Here

    assertEquals("First was [first] and second was [second]!", ms.getText());
  }

  @Test
  public void testThreeParametersForTwo() throws Exception {
    MessageReference context =
        MessageReference.create(ODataMessageException.class, "TWO_REPLACEMENTS").addContent("first", "second", "third");
    Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

    assertEquals("First was [first] and second was [second]!", ms.getText());
  }
View Full Code Here

    assertEquals("First was [first] and second was [second]!", ms.getText());
  }

  @Test
  public void testThreeParametersPerAddContentForTwo() throws Exception {
    MessageReference context = MessageReference.create(ODataMessageException.class, "TWO_REPLACEMENTS")
        .addContent("first").addContent("second").addContent("third");
    Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

    assertEquals("First was [first] and second was [second]!", ms.getText());
  }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.exception.MessageReference

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.