@@ -33,7 +33,6 @@ import java.time.LocalDate
33
33
import java.time.LocalDateTime
34
34
import java.util.UUID
35
35
import kotlin.test.assertEquals
36
- import kotlin.test.assertFalse
37
36
import kotlin.test.assertTrue
38
37
import org.junit.jupiter.api.BeforeEach
39
38
import org.junit.jupiter.api.Test
@@ -586,234 +585,8 @@ class PlacementServiceIntegrationTest : FullApplicationTest(resetDbBeforeEach =
586
585
)
587
586
}
588
587
589
- /*
590
- old XXXXX
591
- new yyy
592
- result Xyyy
593
- */
594
- @Test
595
- fun `old placement starts earlier, ends later and new placement type is CLUB` () {
596
- val newPlacement =
597
- db.transaction {
598
- createPlacements(
599
- tx = it,
600
- childId = childId,
601
- unitId = unitId,
602
- placementTypePeriods =
603
- listOf (
604
- FiniteDateRange (
605
- LocalDate .of(year, month, 11 ),
606
- LocalDate .of(year, month, 19 ),
607
- ) to PlacementType .CLUB
608
- ),
609
- cancelPlacementsAfterClub = true ,
610
- placeGuarantee = false ,
611
- now = now,
612
- userId = testDecisionMaker_1.evakaUserId,
613
- )
614
- }
615
- .first()
616
-
617
- val placements = db.read { it.getPlacementsForChild(childId) }
618
-
619
- assertEquals(2 , placements.size)
620
- assertTrue(placements.contains(newPlacement))
621
- assertTrue(
622
- placements.any {
623
- it.id == oldPlacement.id &&
624
- it.startDate.isEqual(oldPlacement.startDate) &&
625
- it.endDate.isEqual(newPlacement.startDate.minusDays(1 ))
626
- }
627
- )
628
- assertFalse(
629
- placements.any {
630
- it.id != oldPlacement.id &&
631
- it.id != newPlacement.id &&
632
- it.startDate.isEqual(newPlacement.endDate.plusDays(1 )) &&
633
- it.endDate.isEqual(oldPlacement.endDate)
634
- }
635
- )
636
- }
637
-
638
- /*
639
- old XXXXX
640
- new yyyy
641
- result yyyy
642
- */
643
- @Test
644
- fun `old placement ends later and new placement type is CLUB` () {
645
- val newPlacement =
646
- db.transaction {
647
- createPlacements(
648
- tx = it,
649
- childId = childId,
650
- unitId = unitId,
651
- placementTypePeriods =
652
- listOf (
653
- FiniteDateRange (
654
- LocalDate .of(year, month, 10 ),
655
- LocalDate .of(year, month, 19 ),
656
- ) to PlacementType .CLUB
657
- ),
658
- cancelPlacementsAfterClub = true ,
659
- placeGuarantee = false ,
660
- now = now,
661
- userId = testDecisionMaker_1.evakaUserId,
662
- )
663
- }
664
- .first()
665
-
666
- val placements = db.read { it.getPlacementsForChild(childId) }
667
-
668
- assertEquals(1 , placements.size)
669
- assertTrue(placements.contains(newPlacement))
670
- assertFalse(placements.any { it.id == oldPlacement.id })
671
- }
672
-
673
- /*
674
- old XXXXX
675
- new yyyyy
676
- result yyyyy
677
- */
678
588
@Test
679
- fun `old placement starts later, ends later and new placement type is CLUB` () {
680
- val newPlacement =
681
- db.transaction {
682
- createPlacements(
683
- tx = it,
684
- childId = childId,
685
- unitId = unitId,
686
- placementTypePeriods =
687
- listOf (
688
- FiniteDateRange (
689
- LocalDate .of(year, month, 9 ),
690
- LocalDate .of(year, month, 19 ),
691
- ) to PlacementType .CLUB
692
- ),
693
- cancelPlacementsAfterClub = true ,
694
- placeGuarantee = false ,
695
- now = now,
696
- userId = testDecisionMaker_1.evakaUserId,
697
- )
698
- }
699
- .first()
700
-
701
- val placements = db.read { it.getPlacementsForChild(childId) }
702
-
703
- assertEquals(1 , placements.size)
704
- assertTrue(placements.contains(newPlacement))
705
- assertFalse(placements.any { it.id == oldPlacement.id })
706
- }
707
-
708
- @Test
709
- fun `adding a new placement of type CLUB deletes future placements` () {
710
- val futurePlacement =
711
- db.transaction {
712
- it.insertPlacement(
713
- PlacementType .DAYCARE ,
714
- childId,
715
- unitId,
716
- LocalDate .of(year + 2 , 8 , 1 ),
717
- LocalDate .of(year + 2 , 12 , 1 ),
718
- false ,
719
- )
720
- }
721
-
722
- val newPlacement =
723
- db.transaction {
724
- createPlacements(
725
- tx = it,
726
- childId = childId,
727
- unitId = unitId,
728
- placementTypePeriods =
729
- listOf (
730
- FiniteDateRange (
731
- LocalDate .of(year, month, 9 ),
732
- LocalDate .of(year, month, 19 ),
733
- ) to PlacementType .CLUB
734
- ),
735
- cancelPlacementsAfterClub = true ,
736
- placeGuarantee = false ,
737
- now = now,
738
- userId = testDecisionMaker_1.evakaUserId,
739
- )
740
- }
741
- .first()
742
-
743
- val placements = db.read { it.getPlacementsForChild(childId) }
744
-
745
- assertEquals(1 , placements.size)
746
- assertTrue(placements.contains(newPlacement))
747
- assertFalse(placements.contains(futurePlacement))
748
- assertFalse(placements.any { it.id == oldPlacement.id })
749
- }
750
-
751
- @Test
752
- fun `adding a new placement of type CLUB does NOT delete future placements during a PRESCHOOL term` () {
753
- // insert a future PRESCHOOL placement
754
- val (futurePreschoolDaycare, futureDaycareInPreschoolTerm, futurePreschool) =
755
- db.transaction {
756
- listOf (
757
- it.insertPlacement(
758
- PlacementType .PRESCHOOL_DAYCARE ,
759
- childId,
760
- unitId,
761
- LocalDate .of(year + 1 , 8 , 1 ),
762
- LocalDate .of(year + 2 , 6 , 30 ),
763
- false ,
764
- ),
765
- it.insertPlacement(
766
- PlacementType .DAYCARE ,
767
- childId,
768
- unitId,
769
- LocalDate .of(year + 2 , 7 , 1 ),
770
- LocalDate .of(year + 2 , 7 , 31 ),
771
- false ,
772
- ),
773
- it.insertPlacement(
774
- PlacementType .PRESCHOOL ,
775
- childId,
776
- unitId,
777
- LocalDate .of(year + 2 , 9 , 1 ),
778
- LocalDate .of(year + 3 , 4 , 11 ),
779
- false ,
780
- ),
781
- )
782
- }
783
-
784
- val newPlacement =
785
- db.transaction {
786
- createPlacements(
787
- tx = it,
788
- childId = childId,
789
- unitId = unitId,
790
- placementTypePeriods =
791
- listOf (
792
- FiniteDateRange (
793
- LocalDate .of(year, month, 9 ),
794
- LocalDate .of(year, month, 19 ),
795
- ) to PlacementType .CLUB
796
- ),
797
- cancelPlacementsAfterClub = true ,
798
- placeGuarantee = false ,
799
- now = now,
800
- userId = testDecisionMaker_1.evakaUserId,
801
- )
802
- }
803
- .first()
804
-
805
- val placements = db.read { it.getPlacementsForChild(childId) }
806
-
807
- assertEquals(4 , placements.size)
808
- assertTrue(placements.contains(newPlacement))
809
- assertTrue(placements.contains(futurePreschoolDaycare))
810
- assertTrue(placements.contains(futureDaycareInPreschoolTerm))
811
- assertTrue(placements.contains(futurePreschool))
812
- assertFalse(placements.any { it.id == oldPlacement.id })
813
- }
814
-
815
- @Test
816
- fun `adding a new placement of type CLUB does NOT delete future PREPARATORY, PREPARATORY_DAYCARE placements` () {
589
+ fun `adding a new placement does not delete future placements` () {
817
590
// insert a future PRESCHOOL placement
818
591
val (futurePreparatoryDaycare, futureDaycareInPreparatoryTerm, futurePreparatory) =
819
592
db.transaction {
@@ -858,7 +631,6 @@ class PlacementServiceIntegrationTest : FullApplicationTest(resetDbBeforeEach =
858
631
LocalDate .of(year, month, 19 ),
859
632
) to PlacementType .CLUB
860
633
),
861
- cancelPlacementsAfterClub = true ,
862
634
placeGuarantee = false ,
863
635
now = now,
864
636
userId = testDecisionMaker_1.evakaUserId,
@@ -868,12 +640,18 @@ class PlacementServiceIntegrationTest : FullApplicationTest(resetDbBeforeEach =
868
640
869
641
val placements = db.read { it.getPlacementsForChild(childId) }
870
642
871
- assertEquals(4 , placements.size)
643
+ assertEquals(5 , placements.size)
872
644
assertTrue(placements.contains(newPlacement))
645
+ assertTrue(
646
+ placements.any { pl ->
647
+ pl.id == oldPlacement.id &&
648
+ pl.startDate == newPlacement.endDate.plusDays(1 ) &&
649
+ pl.endDate == oldPlacement.endDate
650
+ }
651
+ )
873
652
assertTrue(placements.contains(futurePreparatoryDaycare))
874
653
assertTrue(placements.contains(futureDaycareInPreparatoryTerm))
875
654
assertTrue(placements.contains(futurePreparatory))
876
- assertFalse(placements.any { it.id == oldPlacement.id })
877
655
}
878
656
879
657
@Test
0 commit comments