-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle null researcher categories when updating a profile
Pass it separately so it can be annotated with @nullable.
- Loading branch information
Showing
5 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -573,7 +573,7 @@ public void updateUserProfileAndPublications_whenPublications_thenReplaceAll() { | |
} | ||
).collect( Collectors.toSet() ); | ||
|
||
User updatedUser = userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, user.getProfile(), newPublications, null, null, Locale.getDefault() ); | ||
User updatedUser = userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, user.getProfile(), null, newPublications, null, null, Locale.getDefault() ); | ||
|
||
assertThat( updatedUser.getProfile().getPublications() ).containsExactlyElementsOf( newPublications ); | ||
|
||
|
@@ -589,7 +589,7 @@ public void updateUserProfileAndPublication_whenOrgansIsEnabled_thenSaveOrgans() | |
.map( id -> createOrgan( id, null, null ) ) | ||
.collect( Collectors.toSet() ) ); | ||
Set<String> organUberonIds = Sets.newSet( "UBERON:00001", "UBERON:00002" ); | ||
user = userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, user.getProfile(), null, organUberonIds, null, Locale.getDefault() ); | ||
user = userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, user.getProfile(), null, null, organUberonIds, null, Locale.getDefault() ); | ||
verify( organInfoService ).findByUberonIdIn( organUberonIds ); | ||
assertThat( user.getUserOrgans().values() ) | ||
.extracting( "uberonId" ) | ||
|
@@ -601,7 +601,7 @@ public void updateUserProfileAndPublication_whenOrgansIsNotEnabled_thenIgnoreOrg | |
when( applicationSettings.getOrgans().isEnabled() ).thenReturn( false ); | ||
User user = createUser( 1 ); | ||
Set<String> organUberonIds = Sets.newSet( "UBERON:00001", "UBERON:00002" ); | ||
user = userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, user.getProfile(), null, organUberonIds, null, Locale.getDefault() ); | ||
user = userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, user.getProfile(), null, null, organUberonIds, null, Locale.getDefault() ); | ||
verifyNoInteractions( organInfoService ); | ||
assertThat( user.getUserOrgans() ).isEmpty(); | ||
} | ||
|
@@ -614,7 +614,7 @@ public void updateUserProfileAndPublicationsAndOrgans_whenPrivacyLevelChangeAndC | |
|
||
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.SHARED ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
|
||
assertThat( user.getProfile() ).hasFieldOrPropertyWithValue( "privacyLevel", PrivacyLevelType.PUBLIC ); | ||
} | ||
|
@@ -630,7 +630,7 @@ public void updateUserProfileAndPublicationsAndOrgans_whenPrivacyLevelChange_the | |
|
||
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.SHARED ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
|
||
assertThat( user.getProfile() ) | ||
.hasFieldOrPropertyWithValue( "privacyLevel", PrivacyLevelType.SHARED ); | ||
|
@@ -644,12 +644,12 @@ public void updateUserProfileAndPublicationsAndOrgans_whenContactEmailIsSet_then | |
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.PUBLIC ); | ||
profile.setContactEmail( "[email protected]" ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
verify( userListener ).onContactEmailUpdate( any( OnContactEmailUpdateEvent.class ) ); | ||
assertThat( user.getProfile().isContactEmailVerified() ).isFalse(); | ||
|
||
// make sure that if user update its profile later on, he doesn't get spammed | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
verifyNoMoreInteractions( userListener ); | ||
assertThat( user.getProfile().isContactEmailVerified() ).isFalse(); | ||
} | ||
|
@@ -660,7 +660,7 @@ public void updateUserProfileAndPublicationsAndOrgans_whenContactEmailIsEqualToU | |
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.PUBLIC ); | ||
profile.setContactEmail( user.getEmail() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
assertThat( user.getProfile().isContactEmailVerified() ).isTrue(); | ||
verifyNoInteractions( userListener ); | ||
} | ||
|
@@ -674,7 +674,7 @@ public void updateUserProfileAndPublicationsAndOrgans_whenContactEmailIsNull_the | |
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.PUBLIC ); | ||
profile.setContactEmail( null ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
assertThat( user.getProfile().getContactEmail() ).isNull(); | ||
assertThat( user.getProfile().isContactEmailVerified() ).isFalse(); | ||
assertThat( user.getProfile().getContactEmailVerifiedAt() ).isNull(); | ||
|
@@ -690,7 +690,7 @@ public void updateUserProfileAndPublicationsAndOrgans_whenContactEmailIsEmpty_th | |
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.PUBLIC ); | ||
profile.setContactEmail( "" ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
assertThat( user.getProfile().getContactEmail() ).isEmpty(); | ||
assertThat( user.getProfile().isContactEmailVerified() ).isFalse(); | ||
assertThat( user.getProfile().getContactEmailVerifiedAt() ).isNull(); | ||
|
@@ -704,7 +704,7 @@ public void updateUserProfileAndPublicationsAndOrgans_whenResearcherPositionIsSe | |
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.PUBLIC ); | ||
profile.setResearcherPosition( ResearcherPosition.PRINCIPAL_INVESTIGATOR ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, null, Locale.getDefault() ); | ||
assertThat( user.getProfile().getResearcherPosition() ).isEqualTo( ResearcherPosition.PRINCIPAL_INVESTIGATOR ); | ||
verify( profileSettings ).getEnabledResearcherPositions(); | ||
verify( userRepository ).save( user ); | ||
|
@@ -717,7 +717,7 @@ public void updateUserProfileAndPublicationsAndOrgans_whenResearcherCategoriesAr | |
Profile profile = new Profile(); | ||
profile.setPrivacyLevel( PrivacyLevelType.PUBLIC ); | ||
profile.getResearcherCategories().add( ResearcherCategory.IN_SILICO ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, null, null, null, Locale.getDefault() ); | ||
userService.updateUserProfileAndPublicationsAndOrgansAndOntologyTerms( user, profile, profile.getResearcherCategories(), null, null, null, Locale.getDefault() ); | ||
assertThat( user.getProfile().getResearcherCategories() ).containsExactly( ResearcherCategory.IN_SILICO ); | ||
verify( profileSettings ).getEnabledResearcherCategories(); | ||
verify( userRepository ).save( user ); | ||
|