Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scalafmt-core to 3.0.0 #12

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version = 2.7.5
version = 3.0.0
preset = defaultWithAlign
maxColumn = 140
24 changes: 12 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ lazy val itkit =
project
.in(file("."))
.settings(
name := "itkit",
name := "itkit",
organization := "io.moia",
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0")),
scmInfo := Some(ScmInfo(url("https://github.com/moia-oss/itkit"), "scm:git@github.com:moia-oss/itkit.git")),
homepage := Some(url("https://github.com/moia-oss/itkit")),
scmInfo := Some(ScmInfo(url("https://github.com/moia-oss/itkit"), "scm:git@github.com:moia-oss/itkit.git")),
homepage := Some(url("https://github.com/moia-oss/itkit"))
)
.enablePlugins(
AutomateHeaderPlugin,
Expand Down Expand Up @@ -48,7 +48,7 @@ lazy val samples =
.settings(Defaults.itSettings: _*)
.settings(commonSettings)
.settings(
fork := true,
fork := true,
publishArtifact := false
)

Expand Down Expand Up @@ -98,8 +98,8 @@ lazy val commonSettings =

lazy val compilerSettings =
Seq(
scalaVersion := "2.13.5",
versionScheme := Some("early-semver"),
scalaVersion := "2.13.5",
versionScheme := Some("early-semver"),
Compile / packageBin / mappings += baseDirectory.value / "LICENSE" -> "LICENSE",
scalacOptions ++= Seq(
"-unchecked",
Expand All @@ -122,7 +122,7 @@ lazy val compilerSettings =
"1.8"
),
Compile / unmanagedSourceDirectories := Seq((Compile / scalaSource).value),
Test / unmanagedSourceDirectories := Seq((Test / scalaSource).value)
Test / unmanagedSourceDirectories := Seq((Test / scalaSource).value)
)

lazy val gitSettings = Seq(git.useGitDescribe := true)
Expand All @@ -141,9 +141,9 @@ lazy val licenseSettings =
lazy val sonatypeSettings = {
import xerial.sbt.Sonatype._
Seq(
publishTo := sonatypePublishTo.value,
sonatypeProfileName := organization.value,
publishMavenStyle := true,
publishTo := sonatypePublishTo.value,
sonatypeProfileName := organization.value,
publishMavenStyle := true,
sonatypeProjectHosting := Some(GitHubHosting("moia-oss", "itkit", "oss-support@moia.io")),
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credential")
)
Expand All @@ -158,8 +158,8 @@ lazy val scapegoatSettings = Seq(ThisBuild / scapegoatVersion := "1.4.9")
lazy val sbtVersionRegex = "v([0-9]+.[0-9]+.[0-9]+)-?(.*)?".r

lazy val sbtGitSettings = Seq(
git.useGitDescribe := true,
git.baseVersion := "0.0.0",
git.useGitDescribe := true,
git.baseVersion := "0.0.0",
git.uncommittedSignifier := None,
git.gitTagToVersionNumber := {
case sbtVersionRegex(v, "") => Some(v)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
// Formatting in scala
// See .scalafmt.conf for configuration details.
// Formatting takes place before the project is compiled.
addSbtPlugin( "org.scalameta" % "sbt-scalafmt" % "2.4.3")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")

// Static code analysis.
// sbt> scapegoat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import org.scalatest.wordspec.AsyncWordSpecLike
import scala.util.matching.Regex

class SampleProcessPerSuiteSpec extends AsyncWordSpecLike with Matchers with OneClientPerSuite with OneServerPerSuite {
override val portMessage: Regex = ".*port: ([0-9]+).*".r
override val mainClass = "io.moia.itkit.samples.Main"
override val mainSuccessMessage = "Application is started up."
override val portMessage: Regex = ".*port: ([0-9]+).*".r
override val mainClass = "io.moia.itkit.samples.Main"
override val mainSuccessMessage = "Application is started up."
override lazy val additionalSystemProperties: Map[String, String] = Map("akka.loglevel" -> "DEBUG")

"Sample server per suite" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ class SampleProcessPerTestSpec extends AsyncWordSpecLike with Matchers with OneS
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.util.matching.Regex

class SampleProcessPerTestSpec extends FixtureAsyncWordSpecLike with Matchers with OneServerPerTestWithClient {
override val portMessage: Regex = ".*port: ([0-9]+).*".r
override val mainClass = "io.moia.itkit.samples.Main"
override val mainClass = "io.moia.itkit.samples.Main"
override val mainSuccessMessage = "Application is started up."

"Sample server per test" should {
Expand All @@ -33,4 +33,4 @@ class SampleProcessPerTestSpec extends FixtureAsyncWordSpecLike with Matchers wi
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import io.moia.itkit.ProcessProvider

import scala.util.matching.Regex

/**
* An example of a `ProcessProvider` which can be directly used in the tests, if messages of your application
* match the regular expressions in this class.
/** An example of a `ProcessProvider` which can be directly used in the tests, if messages of your application match the regular expressions
* in this class.
*
* @param mainClass package path of the class to be used for starting the process. E.g. "io.moia.itkit.Main"#
* @param additionalSystemProperties configuration parametes to be added as -D params during start of the process

* @param mainClass
* package path of the class to be used for starting the process. E.g. "io.moia.itkit.Main"#
* @param additionalSystemProperties
* configuration parametes to be added as -D params during start of the process
*/
final case class SampleProcessProvider(mainClass: String, override val additionalSystemProperties: Map[String, String] = Map.empty)
extends ProcessProvider {
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/io/moia/itkit/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ package itkit
import com.typesafe.scalalogging
import org.slf4j.LoggerFactory

/** Defines `log` as a value initialized with an underlying `org.slf4j.Logger`
* named according to the class into which this trait is mixed.
/** Defines `log` as a value initialized with an underlying `org.slf4j.Logger` named according to the class into which this trait is mixed.
*/
trait Logger {

Expand Down
16 changes: 10 additions & 6 deletions src/main/scala/io/moia/itkit/OneServerPerSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ package itkit

import org.scalatest.{Args, AsyncTestSuite, AsyncTestSuiteMixin, Status}

/** Provides one process containing the server application for all tests using the same configuration.
* The process is destroyed upon termination of test suite.
/** Provides one process containing the server application for all tests using the same configuration. The process is destroyed upon
* termination of test suite.
*/
trait OneServerPerSuite extends AsyncTestSuiteMixin with ProcessProvider { this: AsyncTestSuite =>
// The process needs to be globally available for all tests, but lazily started when the first test tries to access it.
lazy val process: ServerProcess = runProcessBuilder(suiteName = suiteName)

/** Runs this suite of tests.
*
* @param testName an optional name of one test to execute. If <code>None</code>, all relevant tests should be executed.
* I.e., <code>None</code> acts like a wildcard that means execute all relevant tests in this <code>Suite</code>.
* @param args the <code>Args</code> for this run
* @return a <code>Status</code> object that indicates when all tests and nested suites started by this method have completed, and whether or not a failure occurred.
* @param testName
* an optional name of one test to execute. If <code>None</code>, all relevant tests should be executed.
* I.e., <code>None</code> acts like a wildcard that means execute all relevant tests in this <code>Suite</code>.
* @param args
* the <code>Args</code> for this run
* @return
* a <code>Status</code> object that indicates when all tests and nested suites started by this method have completed, and whether or
* not a failure occurred.
*/
@SuppressWarnings(Array("CatchException"))
abstract override def run(testName: Option[String], args: Args): Status = {
Expand Down
17 changes: 10 additions & 7 deletions src/main/scala/io/moia/itkit/OneServerPerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import org.scalatest.compatible.Assertion
import org.scalatest.{AsyncTestSuite, AsyncTestSuiteMixin}
import scala.concurrent.Future

/** Provides one process containing the server application per test using a dedicated configuration for each process.
* The process is destroyed upon termination of test suite.
/** Provides one process containing the server application per test using a dedicated configuration for each process. The process is
* destroyed upon termination of test suite.
*/
trait OneServerPerTest extends AsyncTestSuiteMixin { this: AsyncTestSuite =>
private val clientConfig = ConfigFactory.parseString("""
Expand All @@ -24,7 +24,7 @@ trait OneServerPerTest extends AsyncTestSuiteMixin { this: AsyncTestSuite =>
}
""")

private implicit val system: ActorSystem = ActorSystem(s"itkit-client-${suiteId.hashCode().toString}", ConfigFactory.load(clientConfig))
private implicit val system: ActorSystem = ActorSystem(s"itkit-client-${suiteId.hashCode().toString}", ConfigFactory.load(clientConfig))
protected implicit val materializer: Materializer = implicitly[Materializer]

private lazy val suiteHttp: HttpExt = Http()
Expand All @@ -35,10 +35,13 @@ trait OneServerPerTest extends AsyncTestSuiteMixin { this: AsyncTestSuite =>

/** Injects a `ServerProcess` instance into the test according to the configuration provided by process `provider`.
*
* @param provider Contains information about the process including package path of main class, port information,
* message which is yield upon the start of process.
* @param test test for the process to be injected into.
* @return the result of test application.
* @param provider
* Contains information about the process including package path of main class, port information, message which is yield upon the start
* of process.
* @param test
* test for the process to be injected into.
* @return
* the result of test application.
*/
def withProcess(provider: ProcessProvider)(test: ServerProcess => Future[Assertion]): Future[Assertion] = {
val process = createProcess(provider)
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/io/moia/itkit/ProcessLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ trait PortAwaitingLogger extends AwaitingLogger[Int] with Logger {

/** Provides a promise containing information encoded into logging messages of a process.
*
* @tparam A type of the information yielded by logging messages.
* @tparam A
* type of the information yielded by logging messages.
*/
trait AwaitingLogger[A] extends ProcessLogger {
def foundMatchedString: Future[A] = promise.future
Expand Down
6 changes: 4 additions & 2 deletions src/main/scala/io/moia/itkit/ProcessProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ trait ProcessProvider extends Logger {

/** Runs the process builder returning the started process.
*
* @param suiteName name of the suite which uses this trait.
* @return Started process.
* @param suiteName
* name of the suite which uses this trait.
* @return
* Started process.
*/
def runProcessBuilder(suiteName: String): ServerProcess = {

Expand Down
48 changes: 32 additions & 16 deletions src/main/scala/io/moia/itkit/TestClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ trait TestClient {

/** Wraps the `singleRequest` of http extension for the sake of shorter notation.
*
* @param method method to be used in the request, e.g. HttpMethods.GET or HttpMethods.POST
* @param path path to be used to send the request to.
* @param headers optional headers to be included in the request.
* @param entity optional entity to be attached to the request.
* @param protocol protocol to be used for the request.
* @return server response.
* @param method
* method to be used in the request, e.g. HttpMethods.GET or HttpMethods.POST
* @param path
* path to be used to send the request to.
* @param headers
* optional headers to be included in the request.
* @param entity
* optional entity to be attached to the request.
* @param protocol
* protocol to be used for the request.
* @return
* server response.
*/
def request(
method: HttpMethod,
Expand All @@ -48,11 +54,16 @@ trait TestClient {

/** Wraps a GET `singleRequest` of http extension for the sake of shorter notation.
*
* @param path path to be used to send the request to.
* @param headers optional headers to be included in the request.
* @param entity optional entity to be attached to the request.
* @param protocol protocol to be used for the request.
* @return server response.
* @param path
* path to be used to send the request to.
* @param headers
* optional headers to be included in the request.
* @param entity
* optional entity to be attached to the request.
* @param protocol
* protocol to be used for the request.
* @return
* server response.
*/
def getRequest(
path: String,
Expand All @@ -64,11 +75,16 @@ trait TestClient {

/** Wraps a POST `singleRequest` of http extension for the sake of shorter notation.
*
* @param path path to be used to send the request to.
* @param headers optional headers to be included in the request.
* @param entity optional entity to be attached to the request.
* @param protocol protocol to be used for the request.
* @return server response.
* @param path
* path to be used to send the request to.
* @param headers
* optional headers to be included in the request.
* @param entity
* optional entity to be attached to the request.
* @param protocol
* protocol to be used for the request.
* @return
* server response.
*/
def postRequest(
path: String,
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/io/moia/itkit/fixture/OneServerPerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package io.moia.itkit.fixture
import io.moia.itkit.{ProcessProvider, ServerProcess}
import org.scalatest.{AsyncTestSuiteMixin, FixtureAsyncTestSuite, FutureOutcome}

/** Provides one process containing the server application per test using the same configuration for each process.
* The process is destroyed upon termination of the test.
/** Provides one process containing the server application per test using the same configuration for each process. The process is destroyed
* upon termination of the test.
*/
trait OneServerPerTest extends AsyncTestSuiteMixin with ProcessProvider { this: FixtureAsyncTestSuite =>
protected type FixtureParam = ServerProcess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import com.typesafe.config.ConfigFactory
import io.moia.itkit._
import org.scalatest.{AsyncTestSuiteMixin, FixtureAsyncTestSuite, FutureOutcome}

/** Provides one process containing the server application per test using the same configuration for each process.
* The process is destroyed upon termination of the test.
/** Provides one process containing the server application per test using the same configuration for each process. The process is destroyed
* upon termination of the test.
*/
trait OneServerPerTestWithClient extends AsyncTestSuiteMixin with ProcessProvider { this: FixtureAsyncTestSuite =>

Expand Down