Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.github.vishalmysore.a2a.domain;

import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.*;

public class TaskArtifactUpdateEventTest {

Check warning on line 10 in src/test/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEventTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSu-d2q_a0AoNraDO&open=AZ0CSu-d2q_a0AoNraDO&pullRequest=4

@Test
public void testDefaultConstructor() {

Check warning on line 13 in src/test/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEventTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSu-d2q_a0AoNraDJ&open=AZ0CSu-d2q_a0AoNraDJ&pullRequest=4
TaskArtifactUpdateEvent event = new TaskArtifactUpdateEvent();
assertNotNull(event);
assertNull(event.getId());
assertNull(event.getArtifact());
assertNull(event.getMetadata());
}

@Test
public void testAllArgsConstructor() {

Check warning on line 22 in src/test/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEventTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSu-d2q_a0AoNraDK&open=AZ0CSu-d2q_a0AoNraDK&pullRequest=4
Artifact artifact = new Artifact();
artifact.setName("test-artifact");
artifact.setDescription("A test artifact");

Map<String, Object> metadata = new HashMap<>();
metadata.put("key1", "value1");
metadata.put("key2", 42);

TaskArtifactUpdateEvent event = new TaskArtifactUpdateEvent("task-123", artifact, metadata);

assertEquals("task-123", event.getId());
assertEquals(artifact, event.getArtifact());
assertEquals(metadata, event.getMetadata());
assertEquals("value1", event.getMetadata().get("key1"));
assertEquals(42, event.getMetadata().get("key2"));
}

@Test
public void testSettersAndGetters() {

Check warning on line 41 in src/test/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEventTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSu-d2q_a0AoNraDL&open=AZ0CSu-d2q_a0AoNraDL&pullRequest=4
TaskArtifactUpdateEvent event = new TaskArtifactUpdateEvent();

Artifact artifact = new Artifact();
artifact.setName("updated-artifact");

Map<String, Object> metadata = new HashMap<>();
metadata.put("status", "completed");

event.setId("event-456");
event.setArtifact(artifact);
event.setMetadata(metadata);

assertEquals("event-456", event.getId());
assertEquals("updated-artifact", event.getArtifact().getName());
assertEquals("completed", event.getMetadata().get("status"));
}

@Test
public void testTwoArgConstructor() {

Check warning on line 60 in src/test/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEventTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSu-d2q_a0AoNraDM&open=AZ0CSu-d2q_a0AoNraDM&pullRequest=4
Artifact artifact = new Artifact();
artifact.setName("simple-artifact");

TaskArtifactUpdateEvent event = new TaskArtifactUpdateEvent("task-789", artifact);
assertNotNull(event);
}
Comment on lines +64 to +66

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Test masks broken two-arg constructor that sends null fields in production SSE events

The testTwoArgConstructor test only asserts assertNotNull(event) on the result of new TaskArtifactUpdateEvent("task-789", artifact), but the underlying constructor at src/main/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEvent.java:18-19 has an empty body — it never assigns this.id = taskId or this.artifact = artifact. This means event.getId() and event.getArtifact() are both null after construction.

This constructor is used in production at src/main/java/io/github/vishalmysore/a2a/server/DyanamicTaskContoller.java:531 to emit SSE artifact update events: new TaskArtifactUpdateEvent(id, artifact). Because the constructor body is empty, all such events are sent with null id and null artifact fields. The test provides false confidence by not verifying the fields are actually set.

Prompt for agents
Two changes are needed:

1. Fix the production code in src/main/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEvent.java lines 18-19. The two-arg constructor has an empty body and should assign the fields:

    public TaskArtifactUpdateEvent(String taskId, Artifact artifact) {
        this.id = taskId;
        this.artifact = artifact;
    }

2. Fix the test in src/test/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEventTest.java lines 64-66 to actually verify the fields are set:

    TaskArtifactUpdateEvent event = new TaskArtifactUpdateEvent("task-789", artifact);
    assertNotNull(event);
    assertEquals("task-789", event.getId());
    assertEquals(artifact, event.getArtifact());
    assertNull(event.getMetadata());
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


@Test
public void testEqualsAndHashCode() {

Check warning on line 69 in src/test/java/io/github/vishalmysore/a2a/domain/TaskArtifactUpdateEventTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSu-d2q_a0AoNraDN&open=AZ0CSu-d2q_a0AoNraDN&pullRequest=4
Artifact artifact = new Artifact();
artifact.setName("artifact-1");

Map<String, Object> metadata = new HashMap<>();
metadata.put("key", "value");

TaskArtifactUpdateEvent event1 = new TaskArtifactUpdateEvent("id-1", artifact, metadata);
TaskArtifactUpdateEvent event2 = new TaskArtifactUpdateEvent("id-1", artifact, metadata);

assertEquals(event1, event2);
assertEquals(event1.hashCode(), event2.hashCode());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.github.vishalmysore.a2a.domain;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class TaskCancelParamsTest {

Check warning on line 7 in src/test/java/io/github/vishalmysore/a2a/domain/TaskCancelParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBQ2q_a0AoNraDh&open=AZ0CSvBQ2q_a0AoNraDh&pullRequest=4

@Test
public void testDefaultConstructor() {

Check warning on line 10 in src/test/java/io/github/vishalmysore/a2a/domain/TaskCancelParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBQ2q_a0AoNraDc&open=AZ0CSvBQ2q_a0AoNraDc&pullRequest=4
TaskCancelParams params = new TaskCancelParams();
assertNotNull(params);
assertNull(params.getId());
}

@Test
public void testSetAndGetId() {

Check warning on line 17 in src/test/java/io/github/vishalmysore/a2a/domain/TaskCancelParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBQ2q_a0AoNraDd&open=AZ0CSvBQ2q_a0AoNraDd&pullRequest=4
TaskCancelParams params = new TaskCancelParams();
params.setId("task-to-cancel-123");

assertEquals("task-to-cancel-123", params.getId());
}

@Test
public void testToString() {

Check warning on line 25 in src/test/java/io/github/vishalmysore/a2a/domain/TaskCancelParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBQ2q_a0AoNraDe&open=AZ0CSvBQ2q_a0AoNraDe&pullRequest=4
TaskCancelParams params = new TaskCancelParams();
params.setId("cancel-456");

String toString = params.toString();
assertNotNull(toString);
assertTrue(toString.contains("cancel-456"));
}

@Test
public void testEqualsAndHashCode() {

Check warning on line 35 in src/test/java/io/github/vishalmysore/a2a/domain/TaskCancelParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBQ2q_a0AoNraDf&open=AZ0CSvBQ2q_a0AoNraDf&pullRequest=4
TaskCancelParams params1 = new TaskCancelParams();
params1.setId("same-id");

TaskCancelParams params2 = new TaskCancelParams();
params2.setId("same-id");

TaskCancelParams params3 = new TaskCancelParams();
params3.setId("different-id");

assertEquals(params1, params2);
assertEquals(params1.hashCode(), params2.hashCode());
assertNotEquals(params1, params3);
}

@Test
public void testSetIdToNull() {

Check warning on line 51 in src/test/java/io/github/vishalmysore/a2a/domain/TaskCancelParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBQ2q_a0AoNraDg&open=AZ0CSvBQ2q_a0AoNraDg&pullRequest=4
TaskCancelParams params = new TaskCancelParams();
params.setId("initial-id");
assertEquals("initial-id", params.getId());

params.setId(null);
assertNull(params.getId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package io.github.vishalmysore.a2a.domain;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class TaskSetPushNotificationParamsTest {

Check warning on line 7 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDW&open=AZ0CSvA_2q_a0AoNraDW&pullRequest=4

@Test
public void testDefaultConstructor() {

Check warning on line 10 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDP&open=AZ0CSvA_2q_a0AoNraDP&pullRequest=4
TaskSetPushNotificationParams params = new TaskSetPushNotificationParams();
assertNotNull(params);
assertNull(params.getTaskId());
assertNull(params.getNotificationUrl());
assertNull(params.getPushNotificationUrl());
}

@Test
public void testSetAndGetTaskId() {

Check warning on line 19 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDQ&open=AZ0CSvA_2q_a0AoNraDQ&pullRequest=4
TaskSetPushNotificationParams params = new TaskSetPushNotificationParams();
params.setTaskId("task-789");

assertEquals("task-789", params.getTaskId());
}

@Test
public void testSetAndGetNotificationUrl() {

Check warning on line 27 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDR&open=AZ0CSvA_2q_a0AoNraDR&pullRequest=4
TaskSetPushNotificationParams params = new TaskSetPushNotificationParams();
params.setNotificationUrl("https://example.com/notify");

assertEquals("https://example.com/notify", params.getNotificationUrl());
}

@Test
public void testSetAndGetPushNotificationUrl() {

Check warning on line 35 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDS&open=AZ0CSvA_2q_a0AoNraDS&pullRequest=4
TaskSetPushNotificationParams params = new TaskSetPushNotificationParams();
params.setPushNotificationUrl("https://example.com/push");

assertEquals("https://example.com/push", params.getPushNotificationUrl());
}

@Test
public void testAllFieldsSet() {

Check warning on line 43 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDT&open=AZ0CSvA_2q_a0AoNraDT&pullRequest=4
TaskSetPushNotificationParams params = new TaskSetPushNotificationParams();
params.setTaskId("task-100");
params.setNotificationUrl("https://example.com/notify");
params.setPushNotificationUrl("https://example.com/push");

assertEquals("task-100", params.getTaskId());
assertEquals("https://example.com/notify", params.getNotificationUrl());
assertEquals("https://example.com/push", params.getPushNotificationUrl());
}

@Test
public void testEqualsAndHashCode() {

Check warning on line 55 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDU&open=AZ0CSvA_2q_a0AoNraDU&pullRequest=4
TaskSetPushNotificationParams params1 = new TaskSetPushNotificationParams();
params1.setTaskId("task-1");
params1.setNotificationUrl("https://example.com/a");
params1.setPushNotificationUrl("https://example.com/b");

TaskSetPushNotificationParams params2 = new TaskSetPushNotificationParams();
params2.setTaskId("task-1");
params2.setNotificationUrl("https://example.com/a");
params2.setPushNotificationUrl("https://example.com/b");

assertEquals(params1, params2);
assertEquals(params1.hashCode(), params2.hashCode());
}

@Test
public void testToString() {

Check warning on line 71 in src/test/java/io/github/vishalmysore/a2a/domain/TaskSetPushNotificationParamsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvA_2q_a0AoNraDV&open=AZ0CSvA_2q_a0AoNraDV&pullRequest=4
TaskSetPushNotificationParams params = new TaskSetPushNotificationParams();
params.setTaskId("task-200");
params.setNotificationUrl("https://example.com/notify");

String toString = params.toString();
assertNotNull(toString);
assertTrue(toString.contains("task-200"));
assertTrue(toString.contains("https://example.com/notify"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.github.vishalmysore.a2a.domain;

import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.*;

public class VersionNotSupportedErrorTest {

Check warning on line 10 in src/test/java/io/github/vishalmysore/a2a/domain/VersionNotSupportedErrorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBH2q_a0AoNraDb&open=AZ0CSvBH2q_a0AoNraDb&pullRequest=4

@Test
public void testConstructorWithMessage() {

Check warning on line 13 in src/test/java/io/github/vishalmysore/a2a/domain/VersionNotSupportedErrorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBH2q_a0AoNraDX&open=AZ0CSvBH2q_a0AoNraDX&pullRequest=4
VersionNotSupportedError error = new VersionNotSupportedError("Version 0.5 is not supported");

assertEquals(-32009, error.getCode());
assertEquals("Version 0.5 is not supported", error.getMessage());
assertNull(error.getData());
}

@Test
public void testConstructorWithMessageAndData() {

Check warning on line 22 in src/test/java/io/github/vishalmysore/a2a/domain/VersionNotSupportedErrorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBH2q_a0AoNraDY&open=AZ0CSvBH2q_a0AoNraDY&pullRequest=4
Map<String, Object> data = new HashMap<>();
data.put("requestedVersion", "0.5");
data.put("supportedVersions", "1.0, 1.1");

VersionNotSupportedError error = new VersionNotSupportedError("Unsupported version", data);

assertEquals(-32009, error.getCode());
assertEquals("Unsupported version", error.getMessage());
assertNotNull(error.getData());
assertEquals("0.5", error.getData().get("requestedVersion"));
assertEquals("1.0, 1.1", error.getData().get("supportedVersions"));
}

@Test
public void testInheritsFromJSONRPCError() {

Check warning on line 37 in src/test/java/io/github/vishalmysore/a2a/domain/VersionNotSupportedErrorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBH2q_a0AoNraDZ&open=AZ0CSvBH2q_a0AoNraDZ&pullRequest=4
VersionNotSupportedError error = new VersionNotSupportedError("test");
assertTrue(error instanceof JSONRPCError);
}

@Test
public void testErrorCodeIsAlwaysNeg32009() {

Check warning on line 43 in src/test/java/io/github/vishalmysore/a2a/domain/VersionNotSupportedErrorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBH2q_a0AoNraDa&open=AZ0CSvBH2q_a0AoNraDa&pullRequest=4
VersionNotSupportedError error1 = new VersionNotSupportedError("msg1");
VersionNotSupportedError error2 = new VersionNotSupportedError("msg2", new HashMap<>());

assertEquals(-32009, error1.getCode());
assertEquals(-32009, error2.getCode());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package io.github.vishalmysore.mcp.domain;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

public class JSONRPCRequestTest {

Check warning on line 10 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDq&open=AZ0CSvBZ2q_a0AoNraDq&pullRequest=4

@Test
public void testDefaultValues() {

Check warning on line 13 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDi&open=AZ0CSvBZ2q_a0AoNraDi&pullRequest=4
JSONRPCRequest request = new JSONRPCRequest();
assertEquals("2.0", request.getJsonrpc());
assertNull(request.getId());
assertNull(request.getMethod());
assertNull(request.getParams());
}

@Test
public void testSetAndGetId() {

Check warning on line 22 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDj&open=AZ0CSvBZ2q_a0AoNraDj&pullRequest=4
JSONRPCRequest request = new JSONRPCRequest();
request.setId("req-001");
assertEquals("req-001", request.getId());
}

@Test
public void testSetAndGetMethod() {

Check warning on line 29 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDk&open=AZ0CSvBZ2q_a0AoNraDk&pullRequest=4
JSONRPCRequest request = new JSONRPCRequest();
request.setMethod("tools/list");
assertEquals("tools/list", request.getMethod());
}

@Test
public void testSetAndGetParams() {

Check warning on line 36 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDl&open=AZ0CSvBZ2q_a0AoNraDl&pullRequest=4
JSONRPCRequest request = new JSONRPCRequest();
JSONRPCRequest.Params params = new JSONRPCRequest.Params();

JSONRPCRequest.Params.Meta meta = new JSONRPCRequest.Params.Meta();
meta.setProgressToken("progress-token-123");
params.setMeta(meta);

request.setParams(params);

assertNotNull(request.getParams());
assertNotNull(request.getParams().getMeta());
assertEquals("progress-token-123", request.getParams().getMeta().getProgressToken());
}

@Test
public void testJsonrpcVersionIsFixed() {

Check warning on line 52 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDm&open=AZ0CSvBZ2q_a0AoNraDm&pullRequest=4
JSONRPCRequest request = new JSONRPCRequest();
assertEquals("2.0", request.getJsonrpc());
}

@Test
public void testFullRequest() {

Check warning on line 58 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDn&open=AZ0CSvBZ2q_a0AoNraDn&pullRequest=4
JSONRPCRequest request = new JSONRPCRequest();
request.setId("42");
request.setMethod("tools/call");

JSONRPCRequest.Params params = new JSONRPCRequest.Params();
JSONRPCRequest.Params.Meta meta = new JSONRPCRequest.Params.Meta();
meta.setProgressToken("token-abc");
params.setMeta(meta);
request.setParams(params);

assertEquals("42", request.getId());
assertEquals("tools/call", request.getMethod());
assertEquals("2.0", request.getJsonrpc());
assertEquals("token-abc", request.getParams().getMeta().getProgressToken());
}

@Test
public void testBatchRequest() {

Check warning on line 76 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDo&open=AZ0CSvBZ2q_a0AoNraDo&pullRequest=4
JSONRPCBatchRequest batch = new JSONRPCBatchRequest();
List<Object> requests = new ArrayList<>();

JSONRPCRequest req1 = new JSONRPCRequest();
req1.setId("1");
req1.setMethod("tools/list");

JSONRPCRequest req2 = new JSONRPCRequest();
req2.setId("2");
req2.setMethod("tools/call");

requests.add(req1);
requests.add(req2);
batch.setJsonRpcRequests(requests);

assertNotNull(batch.getJsonRpcRequests());
assertEquals(2, batch.getJsonRpcRequests().size());
}

@Test
public void testBatchResponse() {

Check warning on line 97 in src/test/java/io/github/vishalmysore/mcp/domain/JSONRPCRequestTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vishalmysore_a2ajava&issues=AZ0CSvBZ2q_a0AoNraDp&open=AZ0CSvBZ2q_a0AoNraDp&pullRequest=4
JSONRPCBatchResponse batch = new JSONRPCBatchResponse();
List<Object> responses = new ArrayList<>();

JSONRPCResponse resp1 = new JSONRPCResponse();
JSONRPCResponse resp2 = new JSONRPCResponse();

responses.add(resp1);
responses.add(resp2);
batch.setJsonRpcResponses(responses);

assertNotNull(batch.getJsonRpcResponses());
assertEquals(2, batch.getJsonRpcResponses().size());
}
}
Loading