-
Notifications
You must be signed in to change notification settings - Fork 1
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
483/shav-mailjet-stage-segments #329
base: main
Are you sure you want to change the base?
Conversation
src/main/java/uk/ac/cam/cl/dtg/util/email/MailJetApiClientWrapper.java
Outdated
Show resolved
Hide resolved
- Extend updateUserProperties method to include stage parameter - Add stage to the JSON data sent in Mailjet API request - Ensure consistent formatting and error handling This change allows for updating user stage information in Mailjet.
- Verify ExternalAccountManager throws ExternalAccountSynchronisationException when MailjetException occurs during account retrieval - Test covers scenario of Mailjet API communication failure - Ensures proper error propagation in synchroniseChangedUsers method
src/test/java/uk/ac/cam/cl/dtg/util/email/MailJetApiClientWrapperTest.java
Outdated
Show resolved
Hide resolved
src/test/java/uk/ac/cam/cl/dtg/util/email/MailJetApiClientWrapperTest.java
Outdated
Show resolved
Hide resolved
- Implement tests for getAccountByIdOrEmail and addNewUserOrGetUserIfExists methods - Use EasyMock for mocking MailjetClient and MailjetResponse - Include test for handling null email input - Set up test environment with mock injection in setUp method
- Add new utility method `invokePrivateMethod` to ReflectionUtils - Extend ReflectionUtilsTest with additional test cases - Improve test coverage for getClasses and getSubTypes methods - Ensure consistent naming and structure across test methods - Update documentation for ReflectionUtils class This commit enhances the capabilities of our reflection utilities and strengthens our test suite, improving overall code quality and maintainability.
- Create PgExternalAccountPersistenceManagerTest class - Implement test for buildUserExternalAccountChanges method - Use ReflectionUtils to access private method for testing - Mock ResultSet to simulate database interaction - Verify correct creation of UserExternalAccountChanges object This commit improves test coverage for the PgExternalAccountPersistenceManager class, ensuring the correct handling of user account data from the database.
src/test/java/uk/ac/cam/cl/dtg/segue/api/managers/ExternalAccountManagerTest.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
void synchroniseChangedUsers_existingUser() throws SegueDatabaseException, MailjetException, ExternalAccountSynchronisationException { |
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.
I'm struggling a little to see what the difference in behaviour between the existing and newuser cases are. Could you insert a comment or something in the test data to make that clearer?
@@ -102,6 +103,9 @@ public void updateExternalAccount(final Long userId, final String providerUserId | |||
} | |||
|
|||
private UserExternalAccountChanges buildUserExternalAccountChanges(final ResultSet results) throws SQLException { | |||
String registeredContextsJson = results.getString("registered_contexts"); |
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.
Is this all working OK in your local database? It looks like it requires db schema changes to include the registered contexts.
I might be wrong - I don't remember how that information was stored when we looked at it
- Updated test expectations in PgExternalAccountPersistenceManagerTest to align with method behavior - Correctly mock ResultSet to handle registered_contexts JSON data - Added assertions to verify proper JSON parsing and stage extraction - Removed invalid expectations for ResultSet.getString() calls - Improved test readability and ensured consistency with the method logic These changes resolve mismatched expectations and improve the accuracy of the tests, ensuring proper handling of registered_contexts JSON data
|
Description:
This PR introduces a new
invokePrivateMethod
utility in ourReflectionUtils
class, enabling safer testing of private methods. I demonstrated its use by implementing comprehensive unit tests forPgExternalAccountPersistenceManager
, focusing on thebuildUserExternalAccountChanges
method. Then, I updated this method to properly parse JSON data for registered contexts, improving our handling of user account information. The changes include new test methods inReflectionUtilsTest
and a complete test suite forPgExternalAccountPersistenceManager
. These enhancements could significantly improve our test coverage and ensure more robust processing of user data from the database.Ticket: https://github.com/isaaccomputerscience/isaac-cs-issues/issues/483
Media Attachement(s):
![Screenshot 2025-02-04 at 11 02 49](https://private-user-images.githubusercontent.com/82041490/409524791-d8eb17fa-5bd0-462b-b848-ed530df7993a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTMxNTIsIm5iZiI6MTczOTUxMjg1MiwicGF0aCI6Ii84MjA0MTQ5MC80MDk1MjQ3OTEtZDhlYjE3ZmEtNWJkMC00NjJiLWI4NDgtZWQ1MzBkZjc5OTNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDA2MDA1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU5OTc0NWIzYTk2M2Y4ZDY5NjQxM2EyNTJjZGFjM2YyMjY5OGQ0M2UzMjE0MDU3MmMxMDQzMTVjNTZkNWZhZjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.hE8Pv5HxQuq8A_WvFPZpxRhyAP_YeHKTUCgQD1XcUHM)
Screenshot of all of the unit test suite passing
A screen recording demonstrating the steps from the Mailjet Documentation on how to create separate segments for A-Level and GCSE students and setting up distinct segments using the
"stage"
property..Screen.Recording.2025-01-03.at.12.03.08.mov