-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add segments and topics to sub services #77
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
Conversation
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.
4 issues found across 17 files
Prompt for AI agents (all 4 issues)
Understand the root cause of the following 4 issues and fix them.
<file name="src/test/java/com/resend/services/contacts/ContactTopicsTest.java">
<violation number="1" location="src/test/java/com/resend/services/contacts/ContactTopicsTest.java:26">
By replacing the ContactTopics under test with a Mockito mock, the subsequent assertions only validate stubbed behavior rather than the real implementation, so the tests provide no meaningful coverage. Please instantiate the real ContactTopics (or a properly configured test double) instead of mocking it here.</violation>
</file>
<file name="src/test/java/com/resend/services/contacts/ContactSegmentsTest.java">
<violation number="1" location="src/test/java/com/resend/services/contacts/ContactSegmentsTest.java:24">
These tests mock ContactSegments itself, so every add/remove/list call is intercepted by Mockito. The real service code (validation, HTTP call, mapping) never runs, making the suite a tautology that cannot catch regressions. Replace the mock with a real instance (with mocked dependencies) or cover behavior at a higher level.</violation>
</file>
<file name="src/main/java/com/resend/services/contacts/Contacts.java">
<violation number="1" location="src/main/java/com/resend/services/contacts/Contacts.java:55">
Rule violated: **API Key Permission Check SDK Methods**
New segments() / topics() accessors expose freshly added Resend segment & topic endpoints. Please confirm the production API key is provisioned with the required segment/topic scopes so these calls do not start failing after release.</violation>
</file>
<file name="src/main/java/com/resend/services/contacts/ContactSegments.java">
<violation number="1" location="src/main/java/com/resend/services/contacts/ContactSegments.java:4">
Rule violated: **Initialisms and Acronyms Naming Conventions**
Rename `URLHelper` to use camel-case for the acronym (e.g., `UrlHelper`) to comply with the Initialisms and Acronyms Naming Conventions rule.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| @BeforeEach | ||
| public void setUp() { | ||
| MockitoAnnotations.openMocks(this); | ||
| contactTopics = mock(ContactTopics.class); |
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.
By replacing the ContactTopics under test with a Mockito mock, the subsequent assertions only validate stubbed behavior rather than the real implementation, so the tests provide no meaningful coverage. Please instantiate the real ContactTopics (or a properly configured test double) instead of mocking it here.
Prompt for AI agents
Address the following comment on src/test/java/com/resend/services/contacts/ContactTopicsTest.java at line 26:
<comment>By replacing the ContactTopics under test with a Mockito mock, the subsequent assertions only validate stubbed behavior rather than the real implementation, so the tests provide no meaningful coverage. Please instantiate the real ContactTopics (or a properly configured test double) instead of mocking it here.</comment>
<file context>
@@ -0,0 +1,94 @@
+ @BeforeEach
+ public void setUp() {
+ MockitoAnnotations.openMocks(this);
+ contactTopics = mock(ContactTopics.class);
+ }
+
</file context>
| @BeforeEach | ||
| public void setUp() { | ||
| MockitoAnnotations.openMocks(this); | ||
| contactSegments = mock(ContactSegments.class); |
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.
These tests mock ContactSegments itself, so every add/remove/list call is intercepted by Mockito. The real service code (validation, HTTP call, mapping) never runs, making the suite a tautology that cannot catch regressions. Replace the mock with a real instance (with mocked dependencies) or cover behavior at a higher level.
Prompt for AI agents
Address the following comment on src/test/java/com/resend/services/contacts/ContactSegmentsTest.java at line 24:
<comment>These tests mock ContactSegments itself, so every add/remove/list call is intercepted by Mockito. The real service code (validation, HTTP call, mapping) never runs, making the suite a tautology that cannot catch regressions. Replace the mock with a real instance (with mocked dependencies) or cover behavior at a higher level.</comment>
<file context>
@@ -0,0 +1,145 @@
+ @BeforeEach
+ public void setUp() {
+ MockitoAnnotations.openMocks(this);
+ contactSegments = mock(ContactSegments.class);
+ }
+
</file context>
| * | ||
| * @return The ContactSegments service instance. | ||
| */ | ||
| public ContactSegments segments() { |
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.
Rule violated: API Key Permission Check SDK Methods
New segments() / topics() accessors expose freshly added Resend segment & topic endpoints. Please confirm the production API key is provisioned with the required segment/topic scopes so these calls do not start failing after release.
Prompt for AI agents
Address the following comment on src/main/java/com/resend/services/contacts/Contacts.java at line 55:
<comment>New segments() / topics() accessors expose freshly added Resend segment & topic endpoints. Please confirm the production API key is provisioned with the required segment/topic scopes so these calls do not start failing after release.</comment>
<file context>
@@ -24,22 +48,46 @@ public Contacts(final String apiKey) {
+ *
+ * @return The ContactSegments service instance.
+ */
+ public ContactSegments segments() {
+ if (this.contactSegments == null) {
+ this.contactSegments = new ContactSegments(this.apiKey);
</file context>
| package com.resend.services.contacts; | ||
|
|
||
| import com.resend.core.exception.ResendException; | ||
| import com.resend.core.helper.URLHelper; |
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.
Rule violated: Initialisms and Acronyms Naming Conventions
Rename URLHelper to use camel-case for the acronym (e.g., UrlHelper) to comply with the Initialisms and Acronyms Naming Conventions rule.
Prompt for AI agents
Address the following comment on src/main/java/com/resend/services/contacts/ContactSegments.java at line 4:
<comment>Rename `URLHelper` to use camel-case for the acronym (e.g., `UrlHelper`) to comply with the Initialisms and Acronyms Naming Conventions rule.</comment>
<file context>
@@ -0,0 +1,137 @@
+package com.resend.services.contacts;
+
+import com.resend.core.exception.ResendException;
+import com.resend.core.helper.URLHelper;
+import com.resend.core.net.AbstractHttpResponse;
+import com.resend.core.net.HttpMethod;
</file context>
Summary by cubic
Split segment and topic operations into dedicated sub-services under Contacts and made Contacts handle only global contacts. Adds APIs to manage contact segment membership and topic subscriptions, and deprecates segment/topic methods and fields in Contacts.
New Features
Migration
Written for commit 2393de5. Summary will update automatically on new commits.