-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added Unit Test Cases for Wrapper and Helper Files #75
Conversation
WalkthroughThe changes introduce a suite of unit tests for various classes in the Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 8
Files selected for processing (7)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/MakeCompositeRequestTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java (1 hunks)
Files skipped from review due to trivial changes (2)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/MakeCompositeRequestTest.java
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java
Additional comments (Suppressed): 3
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1)
- 44-55: The test
testFetchAccessToken
is well written and covers the expected behavior of thefetchAccessToken
method. It checks that the method correctly decrypts the access token.src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java (2)
40-65: The test
testMakeRequest_Success
is well written and covers the success scenario of themakeRequest
method. It verifies that the correct methods are called with the expected parameters and that the response is as expected.95-123: The test
testMakeRequest_InternalServerErrorException
correctly simulates a server error by throwing aWebClientResponseException
with a 500 status code. It also correctly verifies that theupdateAndGetRefreshedAccessToken
method is not called in this scenario. Good job on covering this edge case.
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java
Outdated
Show resolved
Hide resolved
...com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java
Outdated
Show resolved
Hide resolved
...com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java
Outdated
Show resolved
Hide resolved
...est/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java
Outdated
Show resolved
Hide resolved
...est/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java
Outdated
Show resolved
Hide resolved
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.
Review Status
Actionable comments generated: 2
Files selected for processing (5)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java (1 hunks)
Files skipped from review due to trivial changes (3)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java
Outdated
Show resolved
Hide resolved
...est/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java
Outdated
Show resolved
Hide resolved
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.
Review Status
Actionable comments generated: 1
Files selected for processing (1)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1 hunks)
Additional comments (Suppressed): 1
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1)
- 44-55: The test
testFetchAccessToken
is well written and covers the expected behavior of thefetchAccessToken
method. It verifies that the method correctly decrypts the access token.
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java
Outdated
Show resolved
Hide resolved
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.
Review Status
Actionable comments generated: 0
Files selected for processing (1)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java (1 hunks)
Additional comments (Suppressed): 4
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java (4)
1-79: The test cases are well written and cover both the successful scenario and the exception handling scenario. The use of Mockito to mock dependencies and simulate HTTP responses is a good practice. It ensures that the tests are not dependent on the actual Salesforce service, making them more reliable and faster to run.
44-46: Ensure that the
timeoutMillis
method inSalesforceConstants
returns an appropriate timeout value for your use case. If the timeout is too short, it might cause unnecessary failures when the Salesforce service is slow to respond. If it's too long, it might cause the tests to hang for a long time when there's a problem with the Salesforce service.48-49: This line mocks the
makeRequest
method inSalesforceRequest
. Ensure that the second argument passed to this method (theSalesforceRequestInterface
instance) is constructed correctly in thegetNoteContent
method. This is important because themakeRequest
method will use this instance to construct the actual HTTP request sent to Salesforce.72-74: This line simulates an error by making the
makeRequest
method throw aRuntimeException
. This is a good way to test how thegetNoteContent
method handles errors. However, ensure that thegetNoteContent
method is designed to handle this specific type of exception. If it's not, this test case might give you a false sense of security.
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.
Review Status
Actionable comments generated: 9
Files selected for processing (7)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/MakeCompositeRequestTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java (1 hunks)
Files skipped from review due to trivial changes (2)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/MakeCompositeRequestTest.java
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java
Additional comments (Suppressed): 1
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1)
- 44-55: The
testFetchAccessToken()
method is well implemented. It correctly mocks the necessary dependencies and asserts the expected outcome.
...com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java
Outdated
Show resolved
Hide resolved
...com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java
Outdated
Show resolved
Hide resolved
...com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java
Outdated
Show resolved
Hide resolved
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.
Review Status
Actionable comments generated: 3
Files selected for processing (4)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java (1 hunks)
Files skipped from review due to trivial changes (1)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetRefreshedAccessTokenTest.java
Additional comments (Suppressed): 3
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java (2)
36-62: The test
testGetUserIdentity_Success()
is well written and covers the successful scenario of thegetUserIdentity()
method. It mocks the HttpClient'smakeGetRequest()
method, sets up expected headers, and verifies that the method was called with the correct arguments.64-97: The test
testGetUserIdentity_Exception()
effectively tests the exception handling in thegetUserIdentity()
method. It simulates a RuntimeException during the HTTP request and checks if it's correctly caught and wrapped into a CustomException with the expected error identifiers.src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java (1)
- 46-56: The test
testFetchAccessToken()
is well written and covers the expected behavior of thefetchAccessToken()
method. It correctly mocks the dependencies and verifies the result.
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetTokensTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceOAuthTokenTest.java
Show resolved
Hide resolved
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.
LGTM
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.
Review Status
Actionable comments generated: 2
Files selected for processing (4)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/helper/SalesforceRequestTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetNoteContentTest.java (1 hunks)
- src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceTokensTest.java (3 hunks)
Additional comments (Suppressed): 3
src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceGetIdentityTest.java (1)
- 1-99: The test cases for the
getUserIdentity
method in theSalesforceGetIdentity
class are well written. They cover both the successful scenario and the exception handling scenario. The use of Mockito to mock the HttpClient's static method is a good practice, as it isolates the unit under test from external dependencies. The assertions are also correctly checking the expected outcomes.src/test/java/com/salessparrow/api/unit/lib/salesforce/wrappers/SalesforceTokensTest.java (2)
74-99: The
testGetTokensSuccess()
method tests the successful scenario of getting tokens. It sets up a mock static method call toHttpClient.makePostRequest()
. The mock is configured to return a mock response when called with any arguments. ThegetTokens()
method of theSalesforceTokens
class is invoked with code and redirectUri parameters, and the expected response is compared with the actual response. This test ensures that thegetTokens()
method works as expected in the success scenario.101-132: The
testGetTokensException()
method tests the exception handling scenario of getting tokens. It sets up a mock static method call toHttpClient.makePostRequest()
. The mock is configured to throw aRuntimeException
when called with any arguments. The test asserts that invoking thegetTokens()
method with code and redirectUri parameters throws aCustomException
. This test ensures that thegetTokens()
method correctly handles exceptions and throws aCustomException
as expected.
Summary by CodeRabbit
com.salessparrow.api.unit.lib.salesforce.helper
andcom.salessparrow.api.unit.lib.salesforce.wrappers
packages. These tests cover methods related to Salesforce OAuth token management, HTTP request handling, and data retrieval from Salesforce.