mirror of
https://github.com/dyrkin/luxmed-bot.git
synced 2025-12-30 17:47:26 +01:00
add quicklens as dependency
This commit is contained in:
@@ -3,4 +3,5 @@ dependencies {
|
||||
|
||||
compile group: "org.scalaj", name: "scalaj-http_2.12", version: "2.4.1"
|
||||
compile group: "org.json4s", name: "json4s-jackson_2.12", version: "3.6.0-M3"
|
||||
compile group: "com.softwaremill.quicklens", name: "quicklens_2.12", version: "1.4.12"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.lbs
|
||||
|
||||
import com.lbs.api.json.model.{AvailableTermsResponse, ReservationFilterResponse, ReservedVisitsResponse, VisitsHistoryResponse}
|
||||
import com.softwaremill.quicklens._
|
||||
|
||||
import scala.util.matching.Regex
|
||||
|
||||
@@ -24,20 +25,19 @@ package object api {
|
||||
}
|
||||
|
||||
implicit val ReservedVisitsResponseMutator: ResponseMutator[ReservedVisitsResponse] = (response: ReservedVisitsResponse) => {
|
||||
response.copy(reservedVisits = response.reservedVisits.map(rv => rv.copy(doctorName = cleanupDoctorName(rv.doctorName))))
|
||||
response.modify(_.reservedVisits.each.doctorName).using(cleanupDoctorName)
|
||||
}
|
||||
|
||||
implicit val VisitsHistoryResponseMutator: ResponseMutator[VisitsHistoryResponse] = (response: VisitsHistoryResponse) => {
|
||||
response.copy(historicVisits = response.historicVisits.map(hv => hv.copy(doctorName = cleanupDoctorName(hv.doctorName))))
|
||||
response.modify(_.historicVisits.each.doctorName).using(cleanupDoctorName)
|
||||
}
|
||||
|
||||
implicit val ReservationFilterResponseMutator: ResponseMutator[ReservationFilterResponse] = (response: ReservationFilterResponse) => {
|
||||
response.copy(doctors = response.doctors.map(d => d.copy(name = cleanupDoctorName(d.name))))
|
||||
response.modify(_.doctors.each.name).using(cleanupDoctorName)
|
||||
}
|
||||
|
||||
implicit val AvailableTermsResponseMutator: ResponseMutator[AvailableTermsResponse] = (response: AvailableTermsResponse) => {
|
||||
response.copy(availableVisitsTermPresentation =
|
||||
response.availableVisitsTermPresentation.map(atp => atp.copy(doctor = atp.doctor.copy(name = cleanupDoctorName(atp.doctor.name)))))
|
||||
response.modify(_.availableVisitsTermPresentation.each.doctor.name).using(cleanupDoctorName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
86
api/src/test/scala/com/lbs/api/ApiResponseMutatorsSpec.scala
Normal file
86
api/src/test/scala/com/lbs/api/ApiResponseMutatorsSpec.scala
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.lbs.api
|
||||
|
||||
import com.lbs.api.json.model.{AvailableTermsResponse, AvailableVisitsTermPresentation, HistoricVisit, IdName, ReservationFilterResponse, ReservedVisit, ReservedVisitsResponse, VisitsHistoryResponse}
|
||||
import org.scalatest.{FunSuiteLike, Matchers}
|
||||
|
||||
class ApiResponseMutatorsSpec extends FunSuiteLike with Matchers {
|
||||
test("ReservationFilterResponseMutator") {
|
||||
val mutated =
|
||||
ApiResponseMutators.ReservationFilterResponseMutator.mutate(
|
||||
ReservationFilterResponse(
|
||||
cities = Nil,
|
||||
clinics = Nil,
|
||||
defaultPayer = None,
|
||||
doctors = List(IdName(1, "AGNIESZKA dr n. med.")),
|
||||
languages = Nil,
|
||||
payers = Nil,
|
||||
services = Nil
|
||||
)
|
||||
)
|
||||
|
||||
assert(mutated.doctors === List(IdName(1, "AGNIESZKA")))
|
||||
}
|
||||
|
||||
test("ReservedVisitsResponseMutator") {
|
||||
val mutated =
|
||||
ApiResponseMutators.ReservedVisitsResponseMutator.mutate(
|
||||
ReservedVisitsResponse(
|
||||
List(
|
||||
ReservedVisit(
|
||||
canBeCanceled = false,
|
||||
clinic = null,
|
||||
doctorName = "AGNIESZKA dr n. med.",
|
||||
reservationId = 1L,
|
||||
service = null,
|
||||
visitDate = null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
assert(mutated.reservedVisits.head.doctorName === "AGNIESZKA")
|
||||
}
|
||||
|
||||
test("VisitsHistoryResponseMutator") {
|
||||
val mutated =
|
||||
ApiResponseMutators.VisitsHistoryResponseMutator.mutate(
|
||||
VisitsHistoryResponse(
|
||||
areMoreVisits = false,
|
||||
historicVisits = List(
|
||||
HistoricVisit(
|
||||
clinicName = null,
|
||||
doctorName = "AGNIESZKA dr n. med.",
|
||||
reservationId = 1L,
|
||||
service = null,
|
||||
visitDate = null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
assert(mutated.historicVisits.head.doctorName === "AGNIESZKA")
|
||||
}
|
||||
|
||||
test("AvailableTermsResponseMutator") {
|
||||
val mutated =
|
||||
ApiResponseMutators.AvailableTermsResponseMutator.mutate(
|
||||
AvailableTermsResponse(
|
||||
availableVisitsTermPresentation = List(
|
||||
AvailableVisitsTermPresentation(
|
||||
clinic = null,
|
||||
doctor = IdName(1, "AGNIESZKA dr n. med."),
|
||||
payerDetailsList = Nil,
|
||||
referralRequiredByProduct = false,
|
||||
referralRequiredByService = false,
|
||||
roomId = 1L,
|
||||
scheduleId = 1L,
|
||||
serviceId = 1L,
|
||||
visitDate = null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
assert(mutated.availableVisitsTermPresentation.head.doctor === IdName(1, "AGNIESZKA"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user