diff --git a/gradle.properties b/gradle.properties index 7935b5a..6452a29 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureondemand=true -org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 - +org.gradle.jvmargs=-Dfile.encoding=UTF-8 \ No newline at end of file diff --git a/server/src/main/scala/com/lbs/server/actor/Book.scala b/server/src/main/scala/com/lbs/server/actor/Book.scala index be98f0b..9f0c77b 100644 --- a/server/src/main/scala/com/lbs/server/actor/Book.scala +++ b/server/src/main/scala/com/lbs/server/actor/Book.scala @@ -211,6 +211,7 @@ class Book(val userId: UserId, bot: Bot, apiService: ApiService, dataService: Da bot.sendMessage(userId.source, lang.appointmentIsConfirmed) stay() } + case _ => sys.error(s"Can not prepare reservation request using booking data $bookingData") } } diff --git a/server/src/main/scala/com/lbs/server/service/ApiService.scala b/server/src/main/scala/com/lbs/server/service/ApiService.scala index f195ae8..718b7ed 100644 --- a/server/src/main/scala/com/lbs/server/service/ApiService.scala +++ b/server/src/main/scala/com/lbs/server/service/ApiService.scala @@ -75,11 +75,13 @@ class ApiService extends SessionSupport { def getAvailableTerms(userId: Long, cityId: Long, clinicId: Option[Long], serviceId: Long, doctorId: Option[Long], fromDate: ZonedDateTime = ZonedDateTime.now(), toDate: Option[ZonedDateTime] = None, timeOfDay: Int = 0, languageId: Long = 10, findFirstFreeTerm: Boolean = false): Either[Throwable, List[AvailableVisitsTermPresentation]] = - getDefaultPayer(userId, cityId, clinicId, serviceId).flatMap { case Some(payerId) => - withSession(userId) { session => - LuxmedApi.availableTerms(session.accessToken, session.tokenType, payerId.id, cityId, clinicId, serviceId, doctorId, - fromDate, toDate, timeOfDay, languageId, findFirstFreeTerm).map(_.availableVisitsTermPresentation) - } + getDefaultPayer(userId, cityId, clinicId, serviceId).flatMap { + case Some(payerId) => + withSession(userId) { session => + LuxmedApi.availableTerms(session.accessToken, session.tokenType, payerId.id, cityId, clinicId, serviceId, doctorId, + fromDate, toDate, timeOfDay, languageId, findFirstFreeTerm).map(_.availableVisitsTermPresentation) + } + case None => sys.error(s"Can't determine payer id by user: $userId, city: $cityId, clinic: $clinicId, service: $serviceId") } diff --git a/server/src/test/scala/com/lbs/server/actor/AuthSpec.scala b/server/src/test/scala/com/lbs/server/actor/AuthSpec.scala index b9498cd..1f3b2a8 100644 --- a/server/src/test/scala/com/lbs/server/actor/AuthSpec.scala +++ b/server/src/test/scala/com/lbs/server/actor/AuthSpec.scala @@ -19,13 +19,13 @@ class AuthSpec extends AkkaTestKit { val unauthorizedHelpActor = TestProbe() val loginActor = TestProbe() val chatActor = TestProbe() - val unauthorizedHelpFactory: MessageSource => ActorRef = _ => unauthorizedHelpActor.ref - val loginActorFactory: (MessageSource, ActorRef) => ActorRef = (_, _) => loginActor.ref + val unauthorizedHelpFactory: ByMessageSourceActorFactory = _ => unauthorizedHelpActor.ref + val loginActorFactory: ByMessageSourceWithOriginatorActorFactory = (_, _) => loginActor.ref val chatActorFactory: UserId => ActorRef = _ => chatActor.ref val dataService = mock(classOf[DataService]) + when(dataService.findUserIdBySource(source)).thenReturn(None) val auth = system.actorOf(Auth.props(source, dataService, unauthorizedHelpFactory, loginActorFactory, chatActorFactory)) - when(dataService.findUserIdBySource(source)).thenReturn(None) "send english help on /start command" in { val cmd = Command(source, Message("1", Some("/start"))) @@ -75,13 +75,14 @@ class AuthSpec extends AkkaTestKit { val unauthorizedHelpActor = TestProbe() val loginActor = TestProbe() val chatActor = TestProbe() - val unauthorizedHelpFactory: MessageSource => ActorRef = _ => unauthorizedHelpActor.ref - val loginActorFactory: (MessageSource, ActorRef) => ActorRef = (_, _) => loginActor.ref + val unauthorizedHelpFactory: ByMessageSourceActorFactory = _ => unauthorizedHelpActor.ref + val loginActorFactory: ByMessageSourceWithOriginatorActorFactory = (_, _) => loginActor.ref val chatActorFactory: UserId => ActorRef = _ => chatActor.ref val dataService = mock(classOf[DataService]) + when(dataService.findUserIdBySource(source)).thenReturn(Some(userId.userId)) + val auth = system.actorOf(Auth.props(source, dataService, unauthorizedHelpFactory, loginActorFactory, chatActorFactory)) - when(dataService.findUserIdBySource(source)).thenReturn(Some(userId.userId)) "forward all commands to chat actor" in { val cmd = Command(source, Message("1", Some("any")))