Codota Logo
ReflectiveMessageValidator.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.eclipse.lsp4j.jsonrpc.validation.ReflectiveMessageValidator
constructor

Best Java code snippets using org.eclipse.lsp4j.jsonrpc.validation.ReflectiveMessageValidator.<init> (Showing top 9 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: eclipse/lsp4j

protected MessageConsumer wrapMessageConsumer(MessageConsumer consumer) {
  MessageConsumer result = consumer;
  if (messageTracer != null) {
    final PrintWriter tracer = messageTracer;
    result = message -> {
      tracer.println(message);
      tracer.flush();
      consumer.consume(message);
    };
  }
  if (validateMessages) {
    result = new ReflectiveMessageValidator(result);
  }
  if (messageWrapper != null) {
    result = messageWrapper.apply(result);
  }
  return result;
}

origin: org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc

protected MessageConsumer wrapMessageConsumer(MessageConsumer consumer) {
  MessageConsumer result = consumer;
  if (messageTracer != null) {
    final PrintWriter tracer = messageTracer;
    result = message -> {
      tracer.println(message);
      tracer.flush();
      consumer.consume(message);
    };
  }
  if (validateMessages) {
    result = new ReflectiveMessageValidator(result);
  }
  if (messageWrapper != null) {
    result = messageWrapper.apply(result);
  }
  return result;
}

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.validationReflectiveMessageValidator<init>

Javadoc

When created with this constructor, the validator acts as a message sink.

Popular methods of ReflectiveMessageValidator

  • consume
  • createPathString
  • getPropertyName
  • isGetter
  • validate
    Validate all fields of the given object.

Popular in Java

  • Making http requests using okhttp
  • setRequestProperty (URLConnection)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • runOnUiThread (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JLabel (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now