mirror of
https://github.com/dyrkin/luxmed-bot.git
synced 2025-12-21 13:04:59 +01:00
use scala 2.13 and java 11 (#38)
This commit is contained in:
committed by
GitHub
parent
1b254f8ed5
commit
dc0fefcb53
@@ -8,7 +8,7 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: java:openjdk-8
|
image: amd64/openjdk:11-jdk-slim
|
||||||
environment:
|
environment:
|
||||||
GRADLE_USER_HOME: ~/.gradle
|
GRADLE_USER_HOME: ~/.gradle
|
||||||
commands:
|
commands:
|
||||||
@@ -59,7 +59,7 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: arm64v8/openjdk:8-slim
|
image: arm64v8/openjdk:11-jdk-slim
|
||||||
environment:
|
environment:
|
||||||
GRADLE_USER_HOME: ~/.gradle
|
GRADLE_USER_HOME: ~/.gradle
|
||||||
commands:
|
commands:
|
||||||
|
|||||||
@@ -2,6 +2,5 @@ dependencies {
|
|||||||
implementation project(':common')
|
implementation project(':common')
|
||||||
|
|
||||||
api "org.scalaj:scalaj-http_$scala:2.4.2"
|
api "org.scalaj:scalaj-http_$scala:2.4.2"
|
||||||
api "org.json4s:json4s-jackson_$scala:3.6.0-M3"
|
api "org.json4s:json4s-jackson_$scala:3.6.12"
|
||||||
api "com.softwaremill.quicklens:quicklens_$scala:1.4.12"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ package com.lbs.api.http
|
|||||||
import cats.instances.either._
|
import cats.instances.either._
|
||||||
import com.lbs.api.exception.GenericException
|
import com.lbs.api.exception.GenericException
|
||||||
import org.mockito.Mockito._
|
import org.mockito.Mockito._
|
||||||
import org.scalatest.mockito.MockitoSugar
|
import org.scalatest.BeforeAndAfterEach
|
||||||
import org.scalatest.{BeforeAndAfterEach, FunSuiteLike, Matchers}
|
import org.scalatest.funsuite.AnyFunSuite
|
||||||
|
import org.scalatest.matchers.should.Matchers
|
||||||
|
import org.scalatestplus.mockito.MockitoSugar
|
||||||
import scalaj.http.{HttpRequest, HttpResponse}
|
import scalaj.http.{HttpRequest, HttpResponse}
|
||||||
|
|
||||||
class ExtendedHttpRequestSpec extends FunSuiteLike with Matchers with MockitoSugar with BeforeAndAfterEach {
|
class ExtendedHttpRequestSpec extends AnyFunSuite with Matchers with MockitoSugar with BeforeAndAfterEach {
|
||||||
|
|
||||||
private val request = mock[HttpRequest]
|
private val request = mock[HttpRequest]
|
||||||
private type ThrowableOr[T] = Either[Throwable, T]
|
private type ThrowableOr[T] = Either[Throwable, T]
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ allprojects {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "org.scala-lang:scala-library:$scala.$scala_minor"
|
compileOnly "org.scala-lang:scala-library:$scala.$scala_minor"
|
||||||
|
|
||||||
testImplementation "org.scalatest:scalatest_$scala:3.0.4"
|
testImplementation "org.scalatest:scalatest_$scala:3.2.11"
|
||||||
|
testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.62.2' // version depends on scalatest dependency
|
||||||
|
|
||||||
testImplementation "org.mockito:mockito-core:2.13.0"
|
testImplementation "org.scalatestplus:mockito-4-2_$scala:3.2.11.0"
|
||||||
testImplementation "org.pegdown:pegdown:1.6.0"
|
testImplementation "org.pegdown:pegdown:1.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
api "org.slf4j:slf4j-api:1.7.25"
|
api "ch.qos.logback:logback-classic:1.2.11"
|
||||||
api "ch.qos.logback:logback-classic:1.2.3"
|
api "org.typelevel:cats-core_$scala:2.8.0"
|
||||||
api "org.typelevel:cats-core_$scala:2.0.0-M1"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
|
||||||
package com.lbs.common
|
package com.lbs.common
|
||||||
|
|
||||||
import scala.collection.TraversableLike
|
import scala.collection.{BuildFrom, IterableOps}
|
||||||
import scala.collection.generic.CanBuildFrom
|
import scala.language.implicitConversions
|
||||||
import scala.language.{higherKinds, implicitConversions}
|
|
||||||
|
|
||||||
trait ModelConverters {
|
trait ModelConverters {
|
||||||
|
|
||||||
@@ -15,9 +14,8 @@ trait ModelConverters {
|
|||||||
def mapTo[To](implicit converter: ObjectConverter[From, To]): To = converter.convert(anyRef)
|
def mapTo[To](implicit converter: ObjectConverter[From, To]): To = converter.convert(anyRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit def sequenceConverters[From, To, Col[+X] <: TraversableLike[X, Col[X]]]
|
implicit def sequenceConverters[From, To, Col[+X] <: IterableOps[X, Col, Col[X]]]
|
||||||
(implicit objectConverter: ObjectConverter[From, To], bf: CanBuildFrom[Col[From], To, Col[To]]): ObjectConverter[Col[From], Col[To]] = {
|
(implicit objectConverter: ObjectConverter[From, To]): ObjectConverter[Col[From], Col[To]] =
|
||||||
col: Col[From] => col.map(objectConverter.convert)
|
(col: Col[From]) => col.map(objectConverter.convert)
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM azul/zulu-openjdk-alpine:8u282-jre
|
FROM amd64/openjdk:11-jre-slim
|
||||||
|
|
||||||
RUN apk update && apk upgrade && apk add netcat-openbsd tzdata && apk add --no-cache nss
|
RUN apk update && apk upgrade && apk add netcat-openbsd tzdata && apk add --no-cache nss
|
||||||
RUN mkdir -p /app
|
RUN mkdir -p /app
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM arm64v8/openjdk:8-alpine
|
FROM arm64v8/openjdk:11-jre-slim
|
||||||
|
|
||||||
RUN apk update && apk upgrade && apk add netcat-openbsd tzdata && apk add --no-cache nss
|
RUN apk update && apk upgrade && apk add netcat-openbsd tzdata && apk add --no-cache nss
|
||||||
RUN mkdir -p /app
|
RUN mkdir -p /app
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ org.gradle.parallel=true
|
|||||||
org.gradle.configureondemand=true
|
org.gradle.configureondemand=true
|
||||||
org.gradle.jvmargs=-Dfile.encoding=UTF-8
|
org.gradle.jvmargs=-Dfile.encoding=UTF-8
|
||||||
|
|
||||||
scala=2.12
|
scala=2.13
|
||||||
scala_minor=16
|
scala_minor=8
|
||||||
@@ -6,14 +6,14 @@ dependencies {
|
|||||||
implementation project(":bot")
|
implementation project(":bot")
|
||||||
implementation project(":common")
|
implementation project(":common")
|
||||||
|
|
||||||
implementation "com.lihaoyi:sourcecode_$scala:0.1.4"
|
implementation "com.lihaoyi:sourcecode_$scala:0.3.0"
|
||||||
|
|
||||||
implementation "org.springframework.boot:spring-boot-starter"
|
implementation "org.springframework.boot:spring-boot-starter"
|
||||||
implementation "org.springframework.boot:spring-boot-starter-data-jpa"
|
implementation "org.springframework.boot:spring-boot-starter-data-jpa"
|
||||||
implementation "org.liquibase:liquibase-core"
|
implementation "org.liquibase:liquibase-core"
|
||||||
|
|
||||||
implementation "org.jasypt:jasypt:1.9.2"
|
implementation 'org.jasypt:jasypt:1.9.3'
|
||||||
implementation "org.postgresql:postgresql:42.2.26"
|
implementation 'org.postgresql:postgresql:42.3.6'
|
||||||
|
|
||||||
testImplementation "com.typesafe.akka:akka-testkit_$scala:2.6.19"
|
testImplementation "com.typesafe.akka:akka-testkit_$scala:2.6.19"
|
||||||
testImplementation "org.springframework.boot:spring-boot-starter-test"
|
testImplementation "org.springframework.boot:spring-boot-starter-test"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ object Lang {
|
|||||||
LangsMap.getOrElse(id, sys.error(s"Unknown language id $id"))
|
LangsMap.getOrElse(id, sys.error(s"Unknown language id $id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val version: String = Try(Source.fromFile("version").getLines.mkString).getOrElse("Unknown")
|
val version: String = Try(Source.fromFile("version").getLines().mkString).getOrElse("Unknown")
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Lang {
|
trait Lang {
|
||||||
@@ -35,7 +35,7 @@ trait Lang {
|
|||||||
protected def capitalizeFirstLetter(str: String): String = {
|
protected def capitalizeFirstLetter(str: String): String = {
|
||||||
if (str != null && str != "") {
|
if (str != null && str != "") {
|
||||||
val fistCapitalLetter = str.head.toTitleCase
|
val fistCapitalLetter = str.head.toTitleCase
|
||||||
fistCapitalLetter + str.tail.toLowerCase
|
s"$fistCapitalLetter${str.tail.toLowerCase}"
|
||||||
} else ""
|
} else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Repository
|
|||||||
|
|
||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
import javax.persistence.EntityManager
|
import javax.persistence.EntityManager
|
||||||
import scala.collection.JavaConverters._
|
import scala.jdk.CollectionConverters._
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class DataRepository(@Autowired em: EntityManager) {
|
class DataRepository(@Autowired em: EntityManager) {
|
||||||
@@ -21,7 +21,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
| order by city.time desc""".stripMargin, classOf[CityHistory])
|
| order by city.time desc""".stripMargin, classOf[CityHistory])
|
||||||
.setParameter("accountId", accountId)
|
.setParameter("accountId", accountId)
|
||||||
.setMaxResults(maxHistory)
|
.setMaxResults(maxHistory)
|
||||||
.getResultList.asScala
|
.getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def getClinicHistory(accountId: Long, cityId: Long): Seq[ClinicHistory] = {
|
def getClinicHistory(accountId: Long, cityId: Long): Seq[ClinicHistory] = {
|
||||||
@@ -32,7 +32,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
.setParameter("accountId", accountId)
|
.setParameter("accountId", accountId)
|
||||||
.setParameter("cityId", cityId)
|
.setParameter("cityId", cityId)
|
||||||
.setMaxResults(maxHistory)
|
.setMaxResults(maxHistory)
|
||||||
.getResultList.asScala
|
.getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def getServiceHistory(accountId: Long, cityId: Long, clinicId: Option[Long]): Seq[ServiceHistory] = {
|
def getServiceHistory(accountId: Long, cityId: Long, clinicId: Option[Long]): Seq[ServiceHistory] = {
|
||||||
@@ -45,7 +45,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
.setParameter("cityId", cityId)
|
.setParameter("cityId", cityId)
|
||||||
.setMaxResults(maxHistory)
|
.setMaxResults(maxHistory)
|
||||||
|
|
||||||
clinicId.map(id => query.setParameter("clinicId", id)).getOrElse(query).getResultList.asScala
|
clinicId.map(id => query.setParameter("clinicId", id)).getOrElse(query).getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def getDoctorHistory(accountId: Long, cityId: Long, clinicId: Option[Long], serviceId: Long): Seq[DoctorHistory] = {
|
def getDoctorHistory(accountId: Long, cityId: Long, clinicId: Option[Long], serviceId: Long): Seq[DoctorHistory] = {
|
||||||
@@ -60,7 +60,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
.setParameter("serviceId", serviceId)
|
.setParameter("serviceId", serviceId)
|
||||||
.setMaxResults(maxHistory)
|
.setMaxResults(maxHistory)
|
||||||
|
|
||||||
clinicId.map(id => query.setParameter("clinicId", id)).getOrElse(query).getResultList.asScala
|
clinicId.map(id => query.setParameter("clinicId", id)).getOrElse(query).getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def findCredentials(accountId: Long): Option[Credentials] = {
|
def findCredentials(accountId: Long): Option[Credentials] = {
|
||||||
@@ -73,7 +73,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
def getActiveMonitorings: Seq[Monitoring] = {
|
def getActiveMonitorings: Seq[Monitoring] = {
|
||||||
em.createQuery(
|
em.createQuery(
|
||||||
"""select monitoring from Monitoring monitoring where monitoring.active = true""".stripMargin, classOf[Monitoring])
|
"""select monitoring from Monitoring monitoring where monitoring.active = true""".stripMargin, classOf[Monitoring])
|
||||||
.getResultList.asScala
|
.getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def getActiveMonitoringsCount(accountId: Long): JLong = {
|
def getActiveMonitoringsCount(accountId: Long): JLong = {
|
||||||
@@ -89,7 +89,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
"""select monitoring from Monitoring monitoring where monitoring.active = true
|
"""select monitoring from Monitoring monitoring where monitoring.active = true
|
||||||
| and monitoring.accountId = :accountId order by monitoring.dateTo asc""".stripMargin, classOf[Monitoring])
|
| and monitoring.accountId = :accountId order by monitoring.dateTo asc""".stripMargin, classOf[Monitoring])
|
||||||
.setParameter("accountId", accountId)
|
.setParameter("accountId", accountId)
|
||||||
.getResultList.asScala
|
.getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def getAllMonitoringsCount(accountId: Long): JLong = {
|
def getAllMonitoringsCount(accountId: Long): JLong = {
|
||||||
@@ -107,7 +107,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
.setParameter("accountId", accountId)
|
.setParameter("accountId", accountId)
|
||||||
.setFirstResult(start)
|
.setFirstResult(start)
|
||||||
.setMaxResults(count)
|
.setMaxResults(count)
|
||||||
.getResultList.asScala
|
.getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
"""select monitoring from Monitoring monitoring where monitoring.active = true
|
"""select monitoring from Monitoring monitoring where monitoring.active = true
|
||||||
| and monitoring.created > :since""".stripMargin, classOf[Monitoring])
|
| and monitoring.created > :since""".stripMargin, classOf[Monitoring])
|
||||||
.setParameter("since", since)
|
.setParameter("since", since)
|
||||||
.getResultList.asScala
|
.getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def findMonitoring(accountId: Long, monitoringId: Long): Option[Monitoring] = {
|
def findMonitoring(accountId: Long, monitoringId: Long): Option[Monitoring] = {
|
||||||
@@ -206,7 +206,7 @@ class DataRepository(@Autowired em: EntityManager) {
|
|||||||
em.createQuery(
|
em.createQuery(
|
||||||
"select credentials from Credentials credentials where credentials.userId = :userId", classOf[Credentials])
|
"select credentials from Credentials credentials where credentials.userId = :userId", classOf[Credentials])
|
||||||
.setParameter("userId", userId)
|
.setParameter("userId", userId)
|
||||||
.getResultList.asScala
|
.getResultList.asScala.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def findUserCredentialsByUserIdAndAccountId(userId: Long, accountId: Long): Option[Credentials] = {
|
def findUserCredentialsByUserIdAndAccountId(userId: Long, accountId: Long): Option[Credentials] = {
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package com.lbs.server.conversation
|
|||||||
|
|
||||||
import akka.actor.ActorSystem
|
import akka.actor.ActorSystem
|
||||||
import akka.testkit.{ImplicitSender, TestKit}
|
import akka.testkit.{ImplicitSender, TestKit}
|
||||||
import org.scalatest.{BeforeAndAfterAll, WordSpecLike}
|
import org.scalatest.BeforeAndAfterAll
|
||||||
|
import org.scalatest.wordspec.AnyWordSpecLike
|
||||||
|
|
||||||
abstract class AkkaTestKit extends TestKit(ActorSystem()) with ImplicitSender with WordSpecLike with BeforeAndAfterAll {
|
abstract class AkkaTestKit extends TestKit(ActorSystem()) with ImplicitSender with AnyWordSpecLike with BeforeAndAfterAll {
|
||||||
override def afterAll(): Unit = {
|
override def afterAll(): Unit = {
|
||||||
TestKit.shutdownActorSystem(system)
|
TestKit.shutdownActorSystem(system)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ class AuthSpec extends AkkaTestKit {
|
|||||||
val cmd = Command(source, Message("1", Some("any")))
|
val cmd = Command(source, Message("1", Some("any")))
|
||||||
auth ! cmd
|
auth ! cmd
|
||||||
chatActor.expectMsg(cmd)
|
chatActor.expectMsg(cmd)
|
||||||
unauthorizedHelpActor.expectNoMsg()
|
unauthorizedHelpActor.expectNoMessage()
|
||||||
loginActor.expectNoMsg()
|
loginActor.expectNoMessage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,8 +85,8 @@ class AuthSpec extends AkkaTestKit {
|
|||||||
val cmd = Command(source, Message("1", Some("any")))
|
val cmd = Command(source, Message("1", Some("any")))
|
||||||
auth ! cmd
|
auth ! cmd
|
||||||
chatActor.expectMsg(cmd)
|
chatActor.expectMsg(cmd)
|
||||||
unauthorizedHelpActor.expectNoMsg()
|
unauthorizedHelpActor.expectNoMessage()
|
||||||
loginActor.expectNoMsg()
|
loginActor.expectNoMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
"initialize dialogue with login actor on /login command" in {
|
"initialize dialogue with login actor on /login command" in {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import akka.actor.ActorSystem
|
|||||||
import akka.testkit.TestProbe
|
import akka.testkit.TestProbe
|
||||||
import org.mockito.ArgumentMatchers._
|
import org.mockito.ArgumentMatchers._
|
||||||
import org.mockito.Mockito._
|
import org.mockito.Mockito._
|
||||||
import org.scalatest.mockito.MockitoSugar
|
import org.scalatestplus.mockito.MockitoSugar
|
||||||
|
|
||||||
import scala.reflect.ClassTag
|
import scala.reflect.ClassTag
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user