Skip to content

Commit

Permalink
update easyMock to mock in chime test (#815)
Browse files Browse the repository at this point in the history
* update easyMock to mock

Signed-off-by: rohan19a <[email protected]>

* ktlintFormat update

Signed-off-by: rohan19a <[email protected]>

* update easymock to mockk

Signed-off-by: rohan19a <[email protected]>

---------

Signed-off-by: rohan19a <[email protected]>
  • Loading branch information
rohan19a authored Nov 17, 2023
1 parent 62b7b4f commit 09d1c03
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.apache.hc.client5.http.classic.methods.HttpPost
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse
import org.apache.hc.core5.http.io.entity.StringEntity
import org.easymock.EasyMock
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
Expand Down Expand Up @@ -87,14 +86,13 @@ internal class ChimeDestinationTests {

@Test
fun `test chime message empty entity response`() {
val mockHttpClient: CloseableHttpClient = EasyMock.createMock(CloseableHttpClient::class.java)
val mockHttpClient = mockk<CloseableHttpClient>()
val expectedWebhookResponse = DestinationMessageResponse(RestStatus.OK.status, "{}")

val httpResponse = mockk<CloseableHttpResponse>()
EasyMock.expect(mockHttpClient.execute(EasyMock.anyObject(HttpPost::class.java))).andReturn(httpResponse)
every { mockHttpClient.execute(any<HttpPost>()) } returns httpResponse
every { httpResponse.code } returns RestStatus.OK.status
every { httpResponse.entity } returns StringEntity("")
EasyMock.replay(mockHttpClient)

val httpClient = DestinationHttpClient(mockHttpClient)
val webhookDestinationTransport = WebhookDestinationTransport(httpClient)
Expand All @@ -118,14 +116,13 @@ internal class ChimeDestinationTests {
@Test
fun `test chime message non-empty entity response`() {
val responseContent = "It worked!"
val mockHttpClient: CloseableHttpClient = EasyMock.createMock(CloseableHttpClient::class.java)
val mockHttpClient = mockk<CloseableHttpClient>()
val expectedWebhookResponse = DestinationMessageResponse(RestStatus.OK.status, responseContent)

val httpResponse = mockk<CloseableHttpResponse>()
EasyMock.expect(mockHttpClient.execute(EasyMock.anyObject(HttpPost::class.java))).andReturn(httpResponse)
every { mockHttpClient.execute(any<HttpPost>()) } returns httpResponse
every { httpResponse.code } returns RestStatus.OK.status
every { httpResponse.entity } returns StringEntity(responseContent)
EasyMock.replay(mockHttpClient)

val httpClient = DestinationHttpClient(mockHttpClient)
val webhookDestinationTransport = WebhookDestinationTransport(httpClient)
Expand Down

0 comments on commit 09d1c03

Please sign in to comment.