Skip to content
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

JN-1059 existing user import updates #898

Merged
merged 21 commits into from
May 21, 2024

Conversation

ssettipalli
Copy link
Contributor

@ssettipalli ssettipalli commented May 17, 2024

DESCRIPTION (include screenshots, and mobile screenshots for participant UX)

While importing check for participant existence and handle as update

    /** while importing handle update for existing import
     if same enrolle: update enrollee
     if same participant & same portal.. new enrollee & same profile
     if same participant & different portal.. new enrollee & new profile
     **/

TO TEST: (simple manual steps for confirming core behavior -- used for pre-release checks)

Use attached heartdemo -v1, v2 files and hearthive v1, v2 files for testing.
load hd-v1; make sure import looks good;
load hd-v2; import should go through and existing enrollees/participants should be updated; same profile

load hh-v1; import should go through; same participants (no new participants should be created; new enrollees should be created with new profile since diff portal;
load hh-v2; hh enrollees should be updated;
Dont have test files for same portal, same participant but different study.

2024-05-17-enrollees-hd-v1.csv
2024-05-17-enrollees-hd-v2.csv
2024-05-17-enrollees-hh-v1.csv
2024-05-17-enrollees-hh-v2.csv

@ssettipalli ssettipalli changed the title JN-1059 existing user updates JN-1059 existing user import updates May 17, 2024
@@ -73,23 +74,73 @@ public class EnrolleeImportServiceTests extends BaseSpringBootTest {
@Test
@Transactional
public void testImportEnrolleesCSV(TestInfo info) {
//tests new import and update import
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combined new import and then update test cases too.
Maybe they can be separated but didnt wanted to reuse already populated test portal/study env

Copy link
Collaborator

@devonbush devonbush May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I agree -- seems like this test is now too long. Could you pull the first part of the method into a helper method "setupImportTest()" And then have one test that tests a single import, and then an separate test that tests updates?

(sampath) separated out into 3 separate tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Devon, I don't think these should be combined- it feels like this is pushing past the limits of what could be considered a "unit" test

assertThat(userUpdated2.getId(), equalTo(user.getId()));
Assertions.assertNotEquals(enrollee.getId(), enrolleeUpdated2.getId());
Assertions.assertNotEquals(enrollee.getProfileId(), enrolleeUpdated2.getProfileId());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same portal, different study wasn't tested here as of now

@ssettipalli ssettipalli marked this pull request as ready for review May 17, 2024 17:52
Copy link
Collaborator

@devonbush devonbush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, you were right that the code could use some cleanup -- also consider some more general test helpers -- we'll be writing a lot of tests for this over the next month :)


}

private Import importAndVerify(StudyEnvironmentFactory.StudyEnvironmentBundle bundle, AdminUser admin, String csvString,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a long time to figure out what this method did. Consider renaming, adding a comment, and also renaming the "birthDate" parameter to clarify which birthdate

Copy link
Collaborator

@devonbush devonbush May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better yet, consider splitting out an "Import" helper method, and then a series of "verifyImportEnrollees" "verifyImportParticipantUsers" "verifySurveyResponses" methods. Each method would take as arguments an Import and an array of hamcrest Matchers. this should reduce the amount of hardcoded strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took care of most except "array of hamcrest Matchers" which I will look into separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored to pass objects rather than individual attributes so that it looks good with more attributes from ParticipantUser/Enrolle/Profile

@ssettipalli ssettipalli marked this pull request as draft May 18, 2024 21:02
@ssettipalli ssettipalli marked this pull request as ready for review May 20, 2024 02:42
Copy link
Collaborator

@devonbush devonbush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some test cleanups that would be nice, but not blocking

@@ -73,23 +74,73 @@ public class EnrolleeImportServiceTests extends BaseSpringBootTest {
@Test
@Transactional
public void testImportEnrolleesCSV(TestInfo info) {
//tests new import and update import
Copy link
Collaborator

@devonbush devonbush May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I agree -- seems like this test is now too long. Could you pull the first part of the method into a helper method "setupImportTest()" And then have one test that tests a single import, and then an separate test that tests updates?

(sampath) separated out into 3 separate tests.

Sampath K. Settipalli added 2 commits May 20, 2024 14:24
Copy link
Member

@MatthewBemis MatthewBemis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good pending resolution of latest comments 👍

@@ -73,23 +74,73 @@ public class EnrolleeImportServiceTests extends BaseSpringBootTest {
@Test
@Transactional
public void testImportEnrolleesCSV(TestInfo info) {
//tests new import and update import
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Devon, I don't think these should be combined- it feels like this is pushing past the limits of what could be considered a "unit" test

Copy link

sonarcloud bot commented May 21, 2024

@ssettipalli ssettipalli added this pull request to the merge queue May 21, 2024
Merged via the queue into development with commit c5b2698 May 21, 2024
12 checks passed
@ssettipalli ssettipalli deleted the JN-1059-existing-user-updates branch May 21, 2024 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants