Java Code Examples for org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage#setId()

The following examples show how to use org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValidationTest.java    From lsp4j with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testInvalidCodeLens() {
	ResponseMessage message = new ResponseMessage();
	message.setId("1");
	CodeLens codeLens = new CodeLens(new Range(new Position(3, 32), new Position(3, 35)), null, null);
	// forbidden self reference!
	codeLens.setData(codeLens);
	message.setResult(codeLens);
	assertIssues(message, "An element of the message has a direct or indirect reference to itself.");
}
 
Example 2
Source File: TracingMessageConsumerTest.java    From lsp4j with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testReceivedResponse() {
	StringWriter stringWriter = new StringWriter();
	PrintWriter printWriter = new PrintWriter(stringWriter);

	Map<String, RequestMetadata> sentRequests = new HashMap<>();
	sentRequests.put("1", new RequestMetadata("foo", TEST_CLOCK_1.instant()));

	TracingMessageConsumer consumer =
			new TracingMessageConsumer(
					TEST_REMOTE_ENDPOINT, sentRequests, new HashMap<>(), printWriter, TEST_CLOCK_2);

	ResponseMessage message = new ResponseMessage();
	message.setId("1");
	message.setResult("bar");

	consumer.consume(message);

	String actualTrace = stringWriter.toString();
	String expectedTrace = "" +
			"[Trace - 06:07:30 PM] Received response 'foo - (1)' in 100ms\n" +
			"Result: \"bar\"\n" +
			"\n" +
			"\n";

	assertEquals(expectedTrace, actualTrace);
}
 
Example 3
Source File: TracingMessageConsumerTest.java    From lsp4j with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSendingResponse() {
	StringWriter stringWriter = new StringWriter();
	PrintWriter printWriter = new PrintWriter(stringWriter);

	Map<String, RequestMetadata> receivedRequests = new HashMap<>();
	receivedRequests.put("1", new RequestMetadata("foo", TEST_CLOCK_1.instant()));

	TracingMessageConsumer consumer =
			new TracingMessageConsumer(
					TEST_STREAM_MESSAGE_CONSUMER, new HashMap<>(), receivedRequests, printWriter, TEST_CLOCK_2);

	ResponseMessage message = new ResponseMessage();
	message.setId("1");
	message.setResult("bar");

	consumer.consume(message);

	String actualTrace = stringWriter.toString();
	String expectedTrace = "" +
			"[Trace - 06:07:30 PM] Sending response 'foo - (1)'. Processing request took 100ms\n" +
			"Result: \"bar\"\n" +
			"\n" +
			"\n";

	assertEquals(expectedTrace, actualTrace);
}