44import java .util .Set ;
55
66import de .symeda .sormas .api .person .PersonContactDetailDto ;
7+ import de .symeda .sormas .api .person .PersonContactDetailType ;
78import org .junit .jupiter .api .Assertions ;
89import org .junit .jupiter .api .Test ;
910
@@ -113,8 +114,6 @@ void retrievePartial_german() {
113114 .setFieldsToRetrieve (Set .of (clinicalConfirmation , symptomsAbdominalPain )));
114115
115116 // CHECK
116- System .out .println ("actual = " + actual );
117-
118117 FieldInfo caseDiseaseFieldInfo = actual .getFieldInfoDictionary ().get (clinicalConfirmation );
119118 FieldInfo symptomsAbdominalPainFieldInfo = actual .getFieldInfoDictionary ().get (symptomsAbdominalPain );
120119 Assertions .assertAll (
@@ -145,8 +144,6 @@ void retrievePartial_person() {
145144 .retrievePartial (new PartialRetrievalRequest ().setCaseUuid (originalCase .getUuid ()).setFieldsToRetrieve (Set .of (personFirstNameFieldName )));
146145
147146 // CHECK
148- System .out .println ("actual = " + actual );
149-
150147 FieldInfo personFirstNameFieldInfo = actual .getFieldInfoDictionary ().get (personFirstNameFieldName );
151148 Assertions .assertAll (
152149 () -> Assertions .assertTrue (actual .getFailuresDictionary ().isEmpty ()),
@@ -167,8 +164,6 @@ void retrievePartial_null_value() {
167164 new PartialRetrievalRequest ().setCaseUuid (originalCase .getUuid ()).setFieldsToRetrieve (Set .of (caseClassificationDateFieldName )));
168165
169166 // CHECK
170- System .out .println ("actual = " + actual );
171-
172167 FieldInfo classificationDateFieldInfo = actual .getFieldInfoDictionary ().get (caseClassificationDateFieldName );
173168 Assertions .assertAll (
174169 () -> Assertions .assertTrue (actual .getFailuresDictionary ().isEmpty ()),
@@ -186,21 +181,70 @@ void retrieve_contact_details_phone() {
186181 PersonReferenceDto personRef = originalCase .getPerson ();
187182
188183 PersonDto person = getPersonFacade ().getByUuid (personRef .getUuid ());
184+ List <PersonContactDetailDto > contactDetails = person .getPersonContactDetails ();
185+
186+ PersonContactDetailDto primaryPhoneNumber = new PersonContactDetailDto ();
187+ primaryPhoneNumber .setContactInformation ("09876543" );
188+ primaryPhoneNumber .setPersonContactDetailType (PersonContactDetailType .PHONE );
189+ primaryPhoneNumber .setPrimaryContact (true );
190+ contactDetails .add (primaryPhoneNumber );
191+
192+ PersonContactDetailDto secondaryPhoneNumber = new PersonContactDetailDto ();
193+ secondaryPhoneNumber .setContactInformation ("12345678" );
194+ secondaryPhoneNumber .setPersonContactDetailType (PersonContactDetailType .PHONE );
195+ contactDetails .add (secondaryPhoneNumber );
196+
197+ getPersonFacade ().save (person );
189198
190199 // EXECUTE
191200 String personContactDetails = toFieldName (PersonContactDetailDto .I18N_PREFIX , PersonContactDetailDto .PHONE_NUMBER_TYPE );
192201 PartialRetrievalResponse actual = victim ()
193202 .retrievePartial (new PartialRetrievalRequest ().setCaseUuid (originalCase .getUuid ()).setFieldsToRetrieve (Set .of (personContactDetails )));
194203
195204 // CHECK
196- System .out .println ("actual = " + actual );
205+ FieldInfo personFirstNameFieldInfo = actual .getFieldInfoDictionary ().get (personContactDetails );
206+ Assertions .assertAll (
207+ () -> Assertions .assertTrue (actual .getFailuresDictionary ().isEmpty ()),
208+ () -> Assertions .assertTrue (actual .getFieldInfoDictionary ().containsKey (personContactDetails )),
209+ () -> Assertions .assertEquals ("Phone number type" , personFirstNameFieldInfo .getTranslatedFieldName ()),
210+ () -> Assertions .assertEquals ("09876543; 12345678" , personFirstNameFieldInfo .getFieldValue ()));
211+ }
197212
213+ @ Test
214+ void retrieve_contact_details_email () {
215+ // PREPARE
216+ Disease disease = Disease .RUBELLA ;
217+ CaseDataDto originalCase = creator .createUnclassifiedCase (disease );
218+
219+ PersonReferenceDto personRef = originalCase .getPerson ();
220+
221+ PersonDto person = getPersonFacade ().getByUuid (personRef .getUuid ());
222+ List <PersonContactDetailDto > contactDetails = person .getPersonContactDetails ();
223+
224+ PersonContactDetailDto emailContactDetail = new PersonContactDetailDto ();
225+ emailContactDetail .setContactInformation ("mail@mail.ch" );
226+ emailContactDetail .setPersonContactDetailType (PersonContactDetailType .EMAIL );
227+ contactDetails .add (emailContactDetail );
228+
229+ PersonContactDetailDto phoneContactDetail = new PersonContactDetailDto ();
230+ phoneContactDetail .setContactInformation ("MUST_NOT_BE_RETRIEVED" );
231+ phoneContactDetail .setPersonContactDetailType (PersonContactDetailType .PHONE );
232+ contactDetails .add (phoneContactDetail );
233+
234+ getPersonFacade ().save (person );
235+
236+ // EXECUTE
237+ String personContactDetails = toFieldName (PersonContactDetailDto .I18N_PREFIX , PersonContactDetailDto .CONTACT_INFORMATION );
238+ PartialRetrievalResponse actual = victim ()
239+ .retrievePartial (new PartialRetrievalRequest ().setCaseUuid (originalCase .getUuid ()).setFieldsToRetrieve (Set .of (personContactDetails )));
240+
241+ // CHECK
198242 FieldInfo personFirstNameFieldInfo = actual .getFieldInfoDictionary ().get (personContactDetails );
199243 Assertions .assertAll (
200244 () -> Assertions .assertTrue (actual .getFailuresDictionary ().isEmpty ()),
201245 () -> Assertions .assertTrue (actual .getFieldInfoDictionary ().containsKey (personContactDetails )),
202- () -> Assertions .assertEquals ("First name " , personFirstNameFieldInfo .getTranslatedFieldName ()),
203- () -> Assertions .assertEquals (person . getFirstName () , personFirstNameFieldInfo .getFieldValue ()));
246+ () -> Assertions .assertEquals ("Contact information " , personFirstNameFieldInfo .getTranslatedFieldName ()),
247+ () -> Assertions .assertEquals ("mail@mail.ch" , personFirstNameFieldInfo .getFieldValue ()));
204248 }
205249
206250 private static String toFieldName (String prefix , String fieldName ) {
0 commit comments