congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
ReflectiveMessageValidator.consume
Code IndexAdd Tabnine to your IDE (free)

How to use
consume
method
in
org.eclipse.lsp4j.jsonrpc.validation.ReflectiveMessageValidator

Best Java code snippets using org.eclipse.lsp4j.jsonrpc.validation.ReflectiveMessageValidator.consume (Showing top 8 results out of 315)

origin: eclipse/lsp4j

  private void assertIssues(Message message, CharSequence expectedIssues) {
    try {
      validator.consume(message);
      Assert.fail("Expected InvalidMessageException: " + expectedIssues + ".");
    } catch (MessageIssueException e) {
      String expected = expectedIssues.toString();
      String actual = LineEndings.toSystemLineEndings(e.getMessage());
      // The expectation may be a prefix of the actual exception message
      if (!actual.startsWith(expected))
        Assert.assertEquals(expected, actual);
    }
  }
}
origin: eclipse/lsp4j

@Test public void testSkipJsonElement() {
  final AtomicBoolean result = new AtomicBoolean(false);
  ReflectiveMessageValidator validator = new ReflectiveMessageValidator((message) -> {
    result.set(true);
  });
  NotificationMessage message = new NotificationMessage();
  message.setMethod("foo");
  message.setParams(new JsonObject());
  validator.consume(message);
  Assert.assertTrue(result.get());
}

origin: eclipse/lsp4j

@Test public void testRequestValidation() {
  ReflectiveMessageValidator validator = new ReflectiveMessageValidator();
  
  RequestMessage message = new RequestMessage();
  message.setId("1");
  message.setParams(new Object());
  try {
    validator.consume(message);
    Assert.fail();
  } catch (MessageIssueException e) {
    Assert.assertEquals("The accessor 'RequestMessage.getMethod()' must return a non-null value. Path: $.method", e.getMessage());
  }
}

origin: eclipse/lsp4j

@Test public void testNoViolation() {
  ReflectiveMessageValidator validator = new ReflectiveMessageValidator();
  
  NotificationMessage message = new NotificationMessage();
  message.setMethod("foo");
  Foo foo = new Foo();
  foo.nonNullString = "test";
  foo.nested = new Foo() {{
    nonNullString = "something";
  }};
  message.setParams(foo);
  validator.consume(message);
}

origin: eclipse/lsp4j

@Test public void testReflectionOnPropertiesOnly() {
  ReflectiveMessageValidator validator = new ReflectiveMessageValidator();
  
  NotificationMessage message = new NotificationMessage();
  message.setMethod("foo");
  Foo foo = new Foo();
  foo.nonNullString = "test";
  foo.nested = new Foo() {{
    nonNullString = "something";
  }};
  foo.foos = new ArrayList<>();
  foo.foos.add(new Foo());
  message.setParams(foo);
  try {
    validator.consume(message);
    Assert.fail();
  } catch (MessageIssueException e) {
    Assert.assertEquals("The accessor 'Foo.getNonNullString()' must return a non-null value. Path: $.params.foos[0].nonNullString", e.getMessage());
  }
}
origin: eclipse/lsp4j

@Test public void testNonNullViolated() {
  ReflectiveMessageValidator validator = new ReflectiveMessageValidator();
  
  NotificationMessage message = new NotificationMessage();
  message.setMethod("foo");
  message.setParams(new Foo());
  try {
    validator.consume(message);
    Assert.fail();
  } catch (MessageIssueException e) {
    Assert.assertEquals("The accessor 'Foo.getNonNullString()' must return a non-null value. Path: $.params.nonNullString", e.getMessage());
  }
}

origin: eclipse/lsp4j

@Test public void testRecursionViolation() {
  ReflectiveMessageValidator validator = new ReflectiveMessageValidator();
  
  NotificationMessage message = new NotificationMessage();
  message.setMethod("foo");
  Foo foo = new Foo();
  foo.nonNullString = "test";
  foo.nested = foo;
  message.setParams(foo);
  try {
    validator.consume(message);
    Assert.fail();
  } catch (MessageIssueException e) {
    Assert.assertEquals("An element of the message has a direct or indirect reference to itself. Path: $.params.nested", e.getMessage());
  }
}

origin: eclipse/lsp4j

@Test public void testNonNullViolated_nested() {
  ReflectiveMessageValidator validator = new ReflectiveMessageValidator();
  
  NotificationMessage message = new NotificationMessage();
  message.setMethod("foo");
  Foo foo = new Foo();
  foo.nonNullString = "test";
  foo.nested = new Foo();
  message.setParams(foo);
  try {
    validator.consume(message);
    Assert.fail();
  } catch (MessageIssueException e) {
    Assert.assertEquals("The accessor 'Foo.getNonNullString()' must return a non-null value. Path: $.params.nested.nonNullString", e.getMessage());
  }
}

org.eclipse.lsp4j.jsonrpc.validationReflectiveMessageValidatorconsume

Popular methods of ReflectiveMessageValidator

  • <init>
    Forward messages to the given consumer unless an issue is found.
  • createPathString
  • getPropertyName
  • isGetter
  • validate
    Validate all fields of the given object.

Popular in Java

  • Creating JSON documents from java classes using gson
  • setScale (BigDecimal)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • JLabel (javax.swing)
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now