Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
Signed-off-by: Bendix Saeltz <bendix@saeltz.de>
  • Loading branch information
saeltz committed Feb 1, 2021
1 parent c9f5cee commit b099356
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is a wrapper around the akka-http-client that adds
## Usage

```sbt
libraryDependencies += "io.moia" %% "scala-http-client" % "4.0.0"
libraryDependencies += "io.moia" %% "scala-http-client" % "4.2.0"
```

```scala
Expand All @@ -31,7 +31,7 @@ val httpClient = new HttpClient(
// make a request
val response: Future[HttpClientResponse] = httpClient.request(
method = HttpMethods.POST,
entity = HttpEntity.apply("Example"),
entity = HttpEntity("Example"),
path = "/test",
headers = Seq.empty,
deadline = Deadline.now + 10.seconds
Expand Down Expand Up @@ -132,7 +132,7 @@ Then simply send them in the request:
```scala
val response: Future[HttpClientResponse] = httpClient.request(
method = HttpMethods.POST,
entity = HttpEntity.apply("Example"),
entity = HttpEntity("Example"),
path = "/test",
headers = Seq(new CustomHeader("foobar")),
deadline = Deadline.now + 10.seconds
Expand Down
2 changes: 1 addition & 1 deletion src/it/scala/io/moia/scalaHttpClient/HeaderExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object HeaderExample {
// make a request
val response: Future[HttpClientResponse] = httpClient.request(
method = HttpMethods.POST,
entity = HttpEntity.apply("Example"),
entity = HttpEntity("Example"),
path = "/test",
headers = Seq(new CustomHeader("foobar")),
deadline = Deadline.now + 10.seconds
Expand Down
2 changes: 1 addition & 1 deletion src/it/scala/io/moia/scalaHttpClient/SimpleExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object SimpleExample {
// make a request
val response: Future[HttpClientResponse] = httpClient.request(
method = HttpMethods.POST,
entity = HttpEntity.apply("Example"),
entity = HttpEntity("Example"),
path = "/test",
headers = Seq.empty,
deadline = Deadline.now + 10.seconds
Expand Down
17 changes: 6 additions & 11 deletions src/test/scala/io/moia/scalaHttpClient/HttpClientTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class HttpClientTest extends TestSetup with Inside with StrictLogging {
}

// when
val _ =
testHttpClient.request(HttpMethods.POST, HttpEntity.Empty, "/test", immutable.Seq.empty, Deadline.now + 10.seconds).futureValue
testHttpClient.request(HttpMethods.POST, HttpEntity.Empty, "/test", immutable.Seq.empty, Deadline.now + 10.seconds).futureValue

// then
(capturedRequest.future.futureValue.headers
Expand Down Expand Up @@ -63,10 +62,9 @@ class HttpClientTest extends TestSetup with Inside with StrictLogging {
}

// when
val _ =
testHttpClient
.request(HttpMethods.POST, HttpEntity.Empty, "/test", immutable.Seq(customerHeader), Deadline.now + 10.seconds)
.futureValue
testHttpClient
.request(HttpMethods.POST, HttpEntity.Empty, "/test", immutable.Seq(customerHeader), Deadline.now + 10.seconds)
.futureValue

// then
capturedRequest.future.futureValue.getHeader(CustomHeader.name).get.value should ===("foobar")
Expand All @@ -83,7 +81,6 @@ class HttpClientTest extends TestSetup with Inside with StrictLogging {
}

"return an HttpClientError on StatusCode 400 without an Entity" in {

val testHttpClient = new HttpClient(httpClientConfig, "TestGateway", httpMetrics, retryConfig, clock, None) {
override def sendRequest(req: HttpRequest): Future[HttpResponse] =
Future.successful(HttpResponse().withStatus(400).withEntity(HttpEntity.Empty))
Expand All @@ -98,7 +95,6 @@ class HttpClientTest extends TestSetup with Inside with StrictLogging {
}

"return a DomainError on StatusCode 400 with an Entity" in {

val testHttpClient = new HttpClient(httpClientConfig, "TestGateway", httpMetrics, retryConfig, clock, None) {
override def sendRequest(req: HttpRequest): Future[HttpResponse] =
Future.successful(HttpResponse().withStatus(400).withEntity(HttpEntity("Test")))
Expand All @@ -120,7 +116,7 @@ class HttpClientTest extends TestSetup with Inside with StrictLogging {
val capturedRequest2 = Promise[HttpRequest]()
val capturedRequest3 = Promise[HttpRequest]()

val entity = HttpEntity.apply("Example")
val entity = HttpEntity("Example")

val testHttpClient = new HttpClient(httpClientConfig, "TestGateway", httpMetrics, retryConfig, clock, None) {
override def sendRequest(req: HttpRequest): Future[HttpResponse] =
Expand All @@ -138,13 +134,12 @@ class HttpClientTest extends TestSetup with Inside with StrictLogging {
}

// when
val _ = testHttpClient.request(HttpMethods.POST, entity, "/test", immutable.Seq.empty, Deadline.now + 10.seconds).futureValue
testHttpClient.request(HttpMethods.POST, entity, "/test", immutable.Seq.empty, Deadline.now + 10.seconds).futureValue

// then
capturedRequest1.future.futureValue.entity should ===(entity)
capturedRequest2.future.futureValue.entity should ===(entity)
capturedRequest3.future.futureValue.entity should ===(entity)

}
}

Expand Down

0 comments on commit b099356

Please sign in to comment.