@@ -73,20 +73,20 @@ public void before() {
73
73
ped3 .setOrcid (ORCID_TWO );
74
74
ped3 .setVisibility (Visibility .PUBLIC .value ());
75
75
76
- when (profileEmailDomainDaoMock .findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN ))).thenReturn (ped1 );
77
- when (profileEmailDomainDaoMock .findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_TWO ))).thenReturn (ped2 );
78
- when (profileEmailDomainDaoMock .findByEmailDomain (eq (ORCID_TWO ), eq (EMAIL_DOMAIN ))).thenReturn (ped3 );
79
- when (profileEmailDomainDaoMock .findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_THREE ))).thenReturn (null );
76
+ when (profileEmailDomainDaoReadOnlyMock .findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN ))).thenReturn (ped1 );
77
+ when (profileEmailDomainDaoReadOnlyMock .findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_TWO ))).thenReturn (ped2 );
78
+ when (profileEmailDomainDaoReadOnlyMock .findByEmailDomain (eq (ORCID_TWO ), eq (EMAIL_DOMAIN ))).thenReturn (ped3 );
79
+ when (profileEmailDomainDaoReadOnlyMock .findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_THREE ))).thenReturn (null );
80
80
81
- when (profileEmailDomainDaoMock .findByOrcid (eq (ORCID ))).thenReturn (List .of (ped1 , ped2 ));
82
- when (profileEmailDomainDaoMock .findByOrcid (eq (ORCID_TWO ))).thenReturn (List .of (ped3 ));
81
+ when (profileEmailDomainDaoReadOnlyMock .findByOrcid (eq (ORCID ))).thenReturn (List .of (ped1 , ped2 ));
82
+ when (profileEmailDomainDaoReadOnlyMock .findByOrcid (eq (ORCID_TWO ))).thenReturn (List .of (ped3 ));
83
83
84
- when (profileEmailDomainDaoMock .findPublicEmailDomains (eq (ORCID ))).thenReturn (List .of (ped1 ));
85
- when (profileEmailDomainDaoMock .findPublicEmailDomains (eq (ORCID_TWO ))).thenReturn (List .of (ped2 ));
84
+ when (profileEmailDomainDaoReadOnlyMock .findPublicEmailDomains (eq (ORCID ))).thenReturn (List .of (ped1 ));
85
+ when (profileEmailDomainDaoReadOnlyMock .findPublicEmailDomains (eq (ORCID_TWO ))).thenReturn (List .of (ped2 ));
86
86
87
- when (profileEmailDomainDaoReadOnlyMock .addEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_TWO ), eq (Visibility .LIMITED .value ()))).thenReturn (ped2 );
87
+ when (profileEmailDomainDaoMock .addEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_TWO ), eq (Visibility .LIMITED .value ()))).thenReturn (ped2 );
88
88
89
- when (profileEmailDomainDaoReadOnlyMock .updateVisibility (eq (ORCID ), eq (EMAIL_DOMAIN_TWO ), eq (Visibility .LIMITED .value ()))).thenReturn (true );
89
+ when (profileEmailDomainDaoMock .updateVisibility (eq (ORCID ), eq (EMAIL_DOMAIN_TWO ), eq (Visibility .LIMITED .value ()))).thenReturn (true );
90
90
91
91
ProfileEntity profile = new ProfileEntity ();
92
92
profile .setActivitiesVisibilityDefault (Visibility .PUBLIC .value ());
@@ -110,15 +110,15 @@ public void processDomain_domainAlreadyAdded() {
110
110
professionalEmailDomain .setEmailDomain (EMAIL_DOMAIN );
111
111
when (emailDomainDaoMock .findByEmailDomain (eq (EMAIL_DOMAIN ))).thenReturn (List .of (professionalEmailDomain ));
112
112
pedm .
processDomain (
ORCID ,
"[email protected] " );
113
- verify (profileEmailDomainDaoMock , times (1 )).findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN ));
113
+ verify (profileEmailDomainDaoReadOnlyMock , times (1 )).findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN ));
114
114
verify (profileEmailDomainDaoMock , never ()).addEmailDomain (anyString (), anyString (), anyString ());
115
115
}
116
116
117
117
@ Test
118
118
public void processDomain_doNotAddUnknownDomain () {
119
119
when (emailDomainDaoMock .findByEmailDomain (eq (EMAIL_DOMAIN ))).thenReturn (null );
120
120
pedm .
processDomain (
ORCID ,
"[email protected] " );
121
- verify (profileEmailDomainDaoMock , never ()).findByEmailDomain (anyString (), anyString ());
121
+ verify (profileEmailDomainDaoReadOnlyMock , never ()).findByEmailDomain (anyString (), anyString ());
122
122
verify (profileEmailDomainDaoMock , never ()).addEmailDomain (anyString (), anyString (), anyString ());
123
123
}
124
124
@@ -129,7 +129,7 @@ public void processDomain_doNotAddPersonalDomain() {
129
129
professionalEmailDomain .setEmailDomain (EMAIL_DOMAIN );
130
130
when (emailDomainDaoMock .findByEmailDomain (eq (EMAIL_DOMAIN ))).thenReturn (List .of (professionalEmailDomain ));
131
131
pedm .
processDomain (
ORCID ,
"[email protected] " );
132
- verify (profileEmailDomainDaoMock , never ()).findByEmailDomain (anyString (), anyString ());
132
+ verify (profileEmailDomainDaoReadOnlyMock , never ()).findByEmailDomain (anyString (), anyString ());
133
133
verify (profileEmailDomainDaoMock , never ()).addEmailDomain (anyString (), anyString (), anyString ());
134
134
}
135
135
@@ -140,7 +140,7 @@ public void processDomain_addDomain() {
140
140
professionalEmailDomain .setEmailDomain (EMAIL_DOMAIN_THREE );
141
141
when (emailDomainDaoMock .findByEmailDomain (eq (EMAIL_DOMAIN_THREE ))).thenReturn (List .of (professionalEmailDomain ));
142
142
pedm .
processDomain (
ORCID ,
"[email protected] " );
143
- verify (profileEmailDomainDaoMock , times (1 )).findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_THREE ));
143
+ verify (profileEmailDomainDaoReadOnlyMock , times (1 )).findByEmailDomain (eq (ORCID ), eq (EMAIL_DOMAIN_THREE ));
144
144
verify (profileEmailDomainDaoMock , times (1 )).addEmailDomain (ORCID , EMAIL_DOMAIN_THREE , Visibility .PUBLIC .value ());
145
145
}
146
146
@@ -187,4 +187,16 @@ public void updateEmailDomains_removeDomain() {
187
187
verify (profileEmailDomainDaoMock , times (1 )).removeEmailDomain (ORCID , EMAIL_DOMAIN );
188
188
verify (profileEmailDomainDaoMock , times (1 )).removeEmailDomain (ORCID , EMAIL_DOMAIN_TWO );
189
189
}
190
+
191
+ @ Test
192
+ public void moveEmailDomainToAnotherAccount () {
193
+ pedm .moveEmailDomainToAnotherAccount (EMAIL_DOMAIN , ORCID , ORCID_TWO );
194
+ verify (profileEmailDomainDaoMock , never ()).moveEmailDomainToAnotherAccount (anyString (), anyString (), anyString ());
195
+ }
196
+
197
+ @ Test
198
+ public void moveEmailDomainToAnotherAccount_AlreadyExists () {
199
+ pedm .moveEmailDomainToAnotherAccount (EMAIL_DOMAIN_THREE , ORCID_TWO , ORCID );
200
+ verify (profileEmailDomainDaoMock , times (1 )).moveEmailDomainToAnotherAccount (EMAIL_DOMAIN_THREE , ORCID_TWO , ORCID );
201
+ }
190
202
}
0 commit comments