feat(whatsapp): support groups api payloads#1655
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe changes add comprehensive WhatsApp group participant webhook support, including a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java (1)
77-78: Consider asserting the actual timestamp value.The test only checks
assertNotNull(firstRequest.getCreationTimestamp())but doesn't verify the parsed value. Given the fixture has"creation_timestamp": "1751210000", asserting the expectedDatevalue would strengthen coverage for epoch-to-Date conversion.🔧 Suggested enhancement
+ // 1751210000 seconds since epoch = specific date + assertEquals(1751210000L * 1000L, firstRequest.getCreationTimestamp().getTime()); assertNotNull(firstRequest.getCreationTimestamp());🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java` around lines 77 - 78, The test only checks non-null for creation timestamp; update the GroupApiJsonTest to assert the exact parsed Date value from the fixture by converting the fixture epoch string "1751210000" to the expected Date and comparing it to firstRequest.getCreationTimestamp() (use the same epoch-to-milliseconds conversion used in production) so the test verifies correct epoch-to-Date conversion.src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java (1)
74-83: Optionally assert message list/id in the new group response test.Line 74 through Line 83 validates contact mapping well; adding
messagesassertions would make this test fully symmetric with the neighboring successful-response tests.Suggested test tightening
void checkSuccessfulResponseWithGroupId() { SuccessfulResponse response = createJsonMapper().toJavaObject(jsonFromClasspath("whatsapp/message-response-group"), SuccessfulResponse.class); assertNotNull(response); assertEquals("whatsapp", response.getMessagingProduct()); assertEquals(1, response.getContacts().size()); + assertEquals(1, response.getMessages().size()); + assertEquals("wamid.foobar", response.getMessages().get(0).getId()); assertEquals("[email protected]", response.getContacts().get(0).getInput()); assertNull(response.getContacts().get(0).getWaId()); assertNull(response.getContacts().get(0).getUserId()); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java` around lines 74 - 83, The test checkSuccessfulResponseWithGroupId currently asserts contact mapping but omits verifying the messages payload; update this test (method checkSuccessfulResponseWithGroupId) to also assert that response.getMessages() is non-null, has the expected size (e.g., 1) and that the first message's id matches the expected id from whatsapp/message-response-group (use response.getMessages().get(0).getId()). This mirrors neighboring successful-response tests and ensures message list/id mapping is validated alongside contacts.src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java (1)
91-98: Optionally assert raw change-value type before conversion to validate factory routing.Line 91 through Line 98 currently verifies conversion into
GroupParticipantsUpdateValue, but it does not explicitly prove theChangeValueFactoryenum dispatch selected the correct type before conversion.Suggested assertion to lock enum dispatch behavior
private <T extends ChangeValue> T getWHObjectFromJson(String jsonName, Class<T> clazz) { WebhookObject webhookObject = createJsonMapper().toJavaObject(jsonFromClasspath("whatsapp/" + jsonName), WebhookObject.class); assertThat(webhookObject.isWhatsAppBusinessAccount()).isTrue(); assertThat(webhookObject.getEntryList()).hasSize(1); WebhookEntry entry = webhookObject.getEntryList().get(0); + assertThat(entry.getChanges().get(0).getValue()).isInstanceOf(clazz); return entry.getChanges().get(0).getValue().convertChangeValue(clazz); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java` around lines 91 - 98, Update getWHObjectFromJson to assert the raw change-value type before calling convertChangeValue: after getting WebhookEntry entry and before return, fetch the raw ChangeValue (entry.getChanges().get(0).getValue()) and assert its factory/enum-dispatch indicator equals the expected enum (e.g., ChangeValueFactory.GroupParticipantsUpdate or the appropriate enum constant) to validate routing, then proceed to call convertChangeValue(clazz) as before; reference getWHObjectFromJson, WebhookObject, WebhookEntry, ChangeValueFactory and convertChangeValue/GroupParticipantsUpdateValue to locate where to insert the check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java`:
- Around line 91-98: Update getWHObjectFromJson to assert the raw change-value
type before calling convertChangeValue: after getting WebhookEntry entry and
before return, fetch the raw ChangeValue (entry.getChanges().get(0).getValue())
and assert its factory/enum-dispatch indicator equals the expected enum (e.g.,
ChangeValueFactory.GroupParticipantsUpdate or the appropriate enum constant) to
validate routing, then proceed to call convertChangeValue(clazz) as before;
reference getWHObjectFromJson, WebhookObject, WebhookEntry, ChangeValueFactory
and convertChangeValue/GroupParticipantsUpdateValue to locate where to insert
the check.
In `@src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java`:
- Around line 77-78: The test only checks non-null for creation timestamp;
update the GroupApiJsonTest to assert the exact parsed Date value from the
fixture by converting the fixture epoch string "1751210000" to the expected Date
and comparing it to firstRequest.getCreationTimestamp() (use the same
epoch-to-milliseconds conversion used in production) so the test verifies
correct epoch-to-Date conversion.
In `@src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java`:
- Around line 74-83: The test checkSuccessfulResponseWithGroupId currently
asserts contact mapping but omits verifying the messages payload; update this
test (method checkSuccessfulResponseWithGroupId) to also assert that
response.getMessages() is non-null, has the expected size (e.g., 1) and that the
first message's id matches the expected id from whatsapp/message-response-group
(use response.getMessages().get(0).getId()). This mirrors neighboring
successful-response tests and ensures message list/id mapping is validated
alongside contacts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5ded4890-8316-4d71-be8c-ad9c45bcacfa
📒 Files selected for processing (16)
src/main/lombok/com/restfb/types/webhook/ChangeValueFactory.javasrc/main/lombok/com/restfb/types/webhook/whatsapp/GroupParticipantsUpdateValue.javasrc/main/lombok/com/restfb/types/whatsapp/platform/Status.javasrc/main/lombok/com/restfb/types/whatsapp/platform/group/GroupInfo.javasrc/main/lombok/com/restfb/types/whatsapp/platform/group/GroupJoinRequest.javasrc/main/lombok/com/restfb/types/whatsapp/platform/group/GroupJoinRequests.javasrc/main/lombok/com/restfb/types/whatsapp/platform/group/GroupParticipant.javasrc/test/java/com/restfb/types/WebhookWhatsappGroupsTest.javasrc/test/java/com/restfb/types/WebhookWhatsappTest.javasrc/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.javasrc/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.javasrc/test/resources/json/whatsapp/group-info.jsonsrc/test/resources/json/whatsapp/group-join-requests.jsonsrc/test/resources/json/whatsapp/message-response-group.jsonsrc/test/resources/json/whatsapp/webhook-group-participants-update.jsonsrc/test/resources/json/whatsapp/webhook-incoming-message-status-group-bsuid.json
Summary
group_participants_updatewebhook support withChangeValueFactorymapping and resource-based webhook testsrecipient_typeand group-id response fixturesVerification
Summary by CodeRabbit
New Features
Tests