3636import de .symeda .sormas .api .infrastructure .country .CountryDto ;
3737import de .symeda .sormas .api .infrastructure .country .CountryReferenceDto ;
3838import de .symeda .sormas .api .infrastructure .facility .FacilityDto ;
39- import de .symeda .sormas .api .infrastructure .region .RegionFacade ;
4039import de .symeda .sormas .api .patch .*;
4140import de .symeda .sormas .api .person .*;
4241import de .symeda .sormas .api .symptoms .SymptomState ;
@@ -56,15 +55,12 @@ void patch_noErrorsReplaceAlways() {
5655
5756 String newLastname = "toto" ;
5857 String newSequelaeDetails = "Some very interesting sequelaeDetails" ;
59- String classificationDate = "2030-02-01" ;
6058 CaseDataPatchRequest request = new CaseDataPatchRequest ().setCaseUuid (originalCase .getUuid ())
6159 .setReplacementStrategy (DataReplacementStrategy .ALWAYS )
6260 .setPatchDictionary (
6361 Map .of (
6462 "Person.lastName" ,
6563 newLastname ,
66- "CaseData.classificationDate" ,
67- classificationDate ,
6864
6965 "CaseData.sequelaeDetails" ,
7066 newSequelaeDetails ));
@@ -73,7 +69,6 @@ void patch_noErrorsReplaceAlways() {
7369 DataPatchResponse response = victim ().patch (request );
7470
7571 // CHECK
76-
7772 CaseDataDto actualCase = getCaseFacade ().getByUuid (originalCase .getUuid ());
7873 PersonDto actualPerson = getPersonFacade ().getByUuid (originalCase .getPerson ().getUuid ());
7974
@@ -82,9 +77,6 @@ void patch_noErrorsReplaceAlways() {
8277 // PERSON
8378 () -> Assertions .assertEquals (newLastname , actualPerson .getLastName ()),
8479 // CASE
85- () -> Assertions .assertEquals (
86- Date .from (LocalDate .parse (classificationDate ).atStartOfDay (ZoneId .systemDefault ()).toInstant ()),
87- actualCase .getClassificationDate ()),
8880 () -> Assertions .assertEquals (newSequelaeDetails , actualCase .getSequelaeDetails ()));
8981 }
9082
@@ -411,34 +403,6 @@ void patch_customizableEnu_default_enum_other() {
411403 return e1 ;
412404 }
413405
414- @ Test
415- void patch_referenceData () {
416- // PREPARE
417- registerBeanForLookup (RegionFacade .class , getRegionFacade ());
418-
419- CaseDataDto originalCase = creator .createUnclassifiedCase (Disease .PERTUSSIS );
420-
421- FacilityDto healthFacility = getFacilityFacade ().getByUuid (originalCase .getHealthFacility ().getUuid ());
422- originalCase .setDistrict (healthFacility .getDistrict ());
423- getCaseFacade ().save (originalCase );
424-
425- // must be able to ignore accents - whitespaces - case
426- Map <String , Object > patchDictionary = Map .of ("CaseData.region" , " régIoN " );
427- CaseDataPatchRequest request = new CaseDataPatchRequest ().setCaseUuid (originalCase .getUuid ())
428- .setReplacementStrategy (DataReplacementStrategy .ALWAYS )
429- .setPatchDictionary (patchDictionary );
430-
431- // EXECUTE
432- DataPatchResponse response = victim ().patch (request );
433-
434- // CHECK
435-
436- Assertions .assertAll (
437- () -> Assertions .assertTrue (response .getFailures ().isEmpty (), "Failure found, but should be empty" ),
438-
439- () -> Assertions .assertEquals (patchDictionary , response .getValidPatchDictionary ()));
440- }
441-
442406 @ Test
443407 void patch_referenceData_country () {
444408 // PREPARE
@@ -767,21 +731,20 @@ void patch_ifNotAlreadyPresent_sameDayDifferentTime_noForbiddenValueOverride() {
767731 CaseDataDto originalCase = creator .createUnclassifiedCase (Disease .PERTUSSIS );
768732
769733 // Set classificationDate to 08:30 on 2024-06-15 — a non-midnight timestamp on the same calendar day that will be patched
770- java .util .Date existingDate = java .util .Date .from (LocalDateTime .of (2024 , 6 , 15 , 8 , 30 , 0 ).atZone (ZoneId .systemDefault ()).toInstant ());
771- originalCase .setClassificationDate (existingDate );
734+ java .util .Date existingDate = java .util .Date .from (LocalDateTime .of (2024 , 6 , 15 , 12 , 30 , 0 ).atZone (ZoneId .systemDefault ()).toInstant ());
735+ originalCase .setReportDate (existingDate );
772736 getCaseFacade ().save (originalCase );
773737
774738 // Patch with the same calendar day as a plain date string — DatePatchMapper resolves this to midnight (00:00:00),
775739 // which differs in time from existingDate. Without DateEqualityChecker this would trigger FORBIDDEN_VALUE_OVERRIDE.
776740 String patchDate = "2024-06-15" ;
777- CaseDataPatchRequest request =
778- new CaseDataPatchRequest (). setCaseUuid ( originalCase . getUuid ()). setPatchDictionary (Map .of ("CaseData.classificationDate" , patchDate ));
741+ CaseDataPatchRequest request = new CaseDataPatchRequest (). setCaseUuid ( originalCase . getUuid ())
742+ . setPatchDictionary (Map .of (toFieldName ( CaseDataDto . I18N_PREFIX , CaseDataDto . REPORT_DATE ) , patchDate ));
779743
780744 // EXECUTE
781745 DataPatchResponse response = victim ().patch (request );
782746
783747 // CHECK
784-
785748 Assertions .assertAll (
786749 () -> Assertions .assertTrue (response .getFailures ().isEmpty (), "FORBIDDEN_VALUE_OVERRIDE must not fire for same-day dates" ),
787750 () -> Assertions .assertTrue (response .isApplied ()));
0 commit comments