Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kechpaja-at-gofore committed Nov 27, 2024
1 parent 60eecec commit c4e2485
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import fi.espoo.evaka.shared.dev.DevCareArea
import fi.espoo.evaka.shared.dev.DevDaycare
import fi.espoo.evaka.shared.dev.DevDaycareGroup
import fi.espoo.evaka.shared.dev.DevEmployee
import fi.espoo.evaka.shared.dev.DevMobileDevice
import fi.espoo.evaka.shared.dev.DevPerson
import fi.espoo.evaka.shared.dev.DevPreschoolTerm
import fi.espoo.evaka.shared.dev.insert
Expand Down Expand Up @@ -753,3 +754,6 @@ fun DevPerson.toEvakaUser(type: EvakaUserType) =
name = this.lastName + " " + this.firstName,
type = type,
)

fun DevMobileDevice.toEvakaUser() =
EvakaUser(id = EvakaUserId(this.id.raw), name = this.name, type = EvakaUserType.MOBILE_DEVICE)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import fi.espoo.evaka.placement.PlacementType
import fi.espoo.evaka.reservations.ReservationResponse
import fi.espoo.evaka.shared.ChildId
import fi.espoo.evaka.shared.DaycareId
import fi.espoo.evaka.shared.EmployeeId
import fi.espoo.evaka.shared.GroupId
import fi.espoo.evaka.shared.MobileDeviceId
import fi.espoo.evaka.shared.PlacementId
Expand All @@ -22,6 +23,7 @@ import fi.espoo.evaka.shared.dev.DevBackupCare
import fi.espoo.evaka.shared.dev.DevDaycareGroup
import fi.espoo.evaka.shared.dev.DevDaycareGroupPlacement
import fi.espoo.evaka.shared.dev.DevEmployee
import fi.espoo.evaka.shared.dev.DevMobileDevice
import fi.espoo.evaka.shared.dev.DevPersonType
import fi.espoo.evaka.shared.dev.DevPlacement
import fi.espoo.evaka.shared.dev.DevReservation
Expand Down Expand Up @@ -55,10 +57,8 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr

// TODO Re-write this a bit to use DevMobileDevice instead of what it actually does.

private val evakaUser2 = DevEmployee()
private val mobileUser = AuthenticatedUser.MobileDevice(MobileDeviceId(UUID.randomUUID()))
private val mobileUser2 =
AuthenticatedUser.MobileDevice(MobileDeviceId(UUID.randomUUID()), evakaUser2.id)
private val mobileUser2 = DevMobileDevice(unitId = testDaycare2.id)
private val groupId = GroupId(UUID.randomUUID())
private val groupId2 = GroupId(UUID.randomUUID())
private val groupName = "Testaajat"
Expand All @@ -67,6 +67,10 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
private val placementStart = now.toLocalDate().minusDays(30)
private val placementEnd = now.toLocalDate().plusDays(30)

private val user2 = mobileUser2.toEvakaUser()
private val employee2 =
DevEmployee(id = EmployeeId(user2.id.raw), lastName = user2.name, firstName = "")

@BeforeEach
fun beforeEach() {
db.transaction { tx ->
Expand Down Expand Up @@ -95,7 +99,8 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
)
)
tx.createMobileDeviceToUnit(mobileUser.id, testDaycare.id)
tx.createMobileDeviceToUnit(mobileUser2.id, testDaycare2.id)
tx.insert(employee2)
tx.insert(mobileUser2)
}
}

Expand Down Expand Up @@ -367,7 +372,7 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
departed = null,
)
}
val childInBackup = expectOneChildAttendance(backupUnitId, mobileUser2)
val childInBackup = expectOneChildAttendance(backupUnitId, mobileUser2.user)
assertEquals(AttendanceStatus.PRESENT, childInBackup.status)
assertNotNull(childInBackup.attendances)
assertNull(childInBackup.attendances[0].departed)
Expand Down Expand Up @@ -399,7 +404,7 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
departed = null,
)
}
val childInBackup = expectOneChildAttendance(backupUnitId, mobileUser2)
val childInBackup = expectOneChildAttendance(backupUnitId, mobileUser2.user)
assertEquals(AttendanceStatus.PRESENT, childInBackup.status)
assertNotNull(childInBackup.attendances)
assertNull(childInBackup.attendances[0].departed)
Expand All @@ -420,7 +425,7 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
startTime = reservationStart,
endTime = reservationEnd,
createdAt = now,
createdBy = mobileUser2.evakaUserId,
createdBy = mobileUser2.toEvakaUser().id,
)
)
}
Expand All @@ -431,7 +436,7 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
TimeRange(reservationStart, reservationEnd),
true,
now,
evakaUser2.toEvakaUser(),
mobileUser2.toEvakaUser(),
)
),
child.reservations,
Expand All @@ -447,13 +452,13 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
date = now.toLocalDate(),
startTime = null,
endTime = null,
createdBy = mobileUser2.evakaUserId,
createdBy = mobileUser2.toEvakaUser().id,
)
)
}
val child = expectOneChild()
assertEquals(
listOf(ReservationResponse.NoTimes(true, now, evakaUser2.toEvakaUser())),
listOf(ReservationResponse.NoTimes(true, now, mobileUser2.toEvakaUser())),
child.reservations,
)
}
Expand All @@ -478,18 +483,18 @@ class GetAttendancesIntegrationTest : FullApplicationTest(resetDbBeforeEach = tr
date = now.toLocalDate(),
startTime = reservationStart,
endTime = reservationEnd,
createdBy = mobileUser2.evakaUserId,
createdBy = mobileUser2.toEvakaUser().id,
)
)
}
val childInBackup = expectOneChild(backupUnitId, mobileUser2)
val childInBackup = expectOneChild(backupUnitId, mobileUser2.user)
assertEquals(
listOf(
ReservationResponse.Times(
TimeRange(reservationStart, reservationEnd),
true,
now,
evakaUser2.toEvakaUser(),
mobileUser2.toEvakaUser(),
)
),
childInBackup.reservations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1241,15 +1241,15 @@ class ReservationControllerCitizenIntegrationTest : FullApplicationTest(resetDbB
val area = DevCareArea()
val daycare =
DevDaycare(areaId = area.id, enabledPilotFeatures = setOf(PilotFeature.RESERVATIONS))
// val employee = DevEmployee()
// val employee = DevEmployee()

val adult = DevPerson()
val child = DevPerson()

db.transaction { tx ->
tx.insert(area)
tx.insert(daycare)
//tx.insert(employee)
// tx.insert(employee)

tx.insert(adult, DevPersonType.ADULT)
tx.insert(child, DevPersonType.CHILD)
Expand Down
5 changes: 4 additions & 1 deletion service/src/main/kotlin/fi/espoo/evaka/shared/dev/DevApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,10 @@ data class DevMobileDevice(
val name: String = "Laite",
val longTermToken: UUID? = null,
val pushNotificationCategories: Set<PushNotificationCategory> = emptySet(),
)
) {
val user: AuthenticatedUser.MobileDevice
@JsonIgnore get() = AuthenticatedUser.MobileDevice(id)
}

data class DevPersonalMobileDevice(
val id: MobileDeviceId = MobileDeviceId(UUID.randomUUID()),
Expand Down

0 comments on commit c4e2485

Please sign in to comment.