-
Notifications
You must be signed in to change notification settings - Fork 169
fix: allow omitted task push config id #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
78494f1
483868d
e4a3d37
a9b96c8
1c21dcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,10 +151,10 @@ public void testSetInfoAppendsToExistingConfig() { | |
| } | ||
|
|
||
| @Test | ||
| public void testSetInfoWithoutConfigId() { | ||
| public void testSetInfoWithEmptyConfigId() { | ||
| String taskId = "task1"; | ||
| TaskPushNotificationConfig initialConfig = TaskPushNotificationConfig.builder() | ||
| .id("") // No ID set | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create a new test rather than changing this existing one. Removing
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous comment should still be addressed. |
||
| .id("") | ||
| .url("http://initial.url/callback") | ||
| .taskId(taskId) | ||
| .build(); | ||
|
|
@@ -166,18 +166,37 @@ public void testSetInfoWithoutConfigId() { | |
| assertEquals(1, configResult.configs().size()); | ||
| assertEquals(taskId, configResult.configs().get(0).id()); | ||
|
|
||
| TaskPushNotificationConfig updatedConfig = TaskPushNotificationConfig.builder() | ||
| .id("") // No ID set | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create a new test rather than changing this existing one.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous comment should still be addressed. |
||
| TaskPushNotificationConfig duplicateConfig = TaskPushNotificationConfig.builder() | ||
| .id("") | ||
| .url("http://initial.url/callback_new") | ||
| .taskId(taskId) | ||
| .build(); | ||
|
|
||
| TaskPushNotificationConfig updatedResult = configStore.setInfo(updatedConfig); | ||
| assertEquals(taskId, updatedResult.id()); | ||
| assertThrows(InvalidParamsError.class, () -> configStore.setInfo(duplicateConfig)); | ||
|
|
||
| configResult = configStore.getInfo(new ListTaskPushNotificationConfigsParams(taskId)); | ||
| assertEquals(1, configResult.configs().size(), "Should replace existing config with same ID rather than adding new one"); | ||
| assertEquals(updatedConfig.url(), configResult.configs().get(0).url()); | ||
| assertEquals(1, configResult.configs().size()); | ||
| assertEquals(initialConfig.url(), configResult.configs().get(0).url()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSetInfoWithNullConfigId() { | ||
| String taskId = "task_with_null_config_id"; | ||
| TaskPushNotificationConfig config = TaskPushNotificationConfig.builder() | ||
| .url("http://initial.url/callback") | ||
| .taskId(taskId) | ||
| .build(); | ||
|
|
||
| TaskPushNotificationConfig result = configStore.setInfo(config); | ||
|
|
||
| assertEquals(taskId, result.id(), "Config ID should default to taskId when null"); | ||
|
|
||
| TaskPushNotificationConfig duplicateConfig = TaskPushNotificationConfig.builder() | ||
| .url("http://updated.url/callback") | ||
| .taskId(taskId) | ||
| .build(); | ||
|
|
||
| assertThrows(InvalidParamsError.class, () -> configStore.setInfo(duplicateConfig)); | ||
| } | ||
|
|
||
| @Test | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package org.a2aproject.sdk.spec; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class GetTaskPushNotificationConfigParamsTest { | ||
|
|
||
| @Test | ||
| void testConstructionAllowsOmittedConfigurationId() { | ||
| GetTaskPushNotificationConfigParams params = new GetTaskPushNotificationConfigParams("task-1"); | ||
|
|
||
| assertEquals("task-1", params.taskId()); | ||
| assertNull(params.id()); | ||
| } | ||
|
|
||
| @Test | ||
| void testBuilderAllowsOmittedConfigurationId() { | ||
| GetTaskPushNotificationConfigParams params = GetTaskPushNotificationConfigParams.builder() | ||
| .taskId("task-1") | ||
| .build(); | ||
|
|
||
| assertNull(params.id()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a comment about this code, but
JpaDatabasePushNotificationConfigStorehas the same latent NPE, and needs fixing too.