From 09d1c03a2411c057bc73543562cc166cb0944c8d Mon Sep 17 00:00:00 2001 From: rohan19a <46227014+rohan19a@users.noreply.github.com> Date: Thu, 16 Nov 2023 19:42:20 -0800 Subject: [PATCH] update easyMock to mock in chime test (#815) * update easyMock to mock Signed-off-by: rohan19a <46227014+rohan19a@users.noreply.github.com> * ktlintFormat update Signed-off-by: rohan19a <46227014+rohan19a@users.noreply.github.com> * update easymock to mockk Signed-off-by: rohan19a <46227014+rohan19a@users.noreply.github.com> --------- Signed-off-by: rohan19a <46227014+rohan19a@users.noreply.github.com> --- .../core/destinations/ChimeDestinationTests.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt index aebcde92..1a036ad5 100644 --- a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt +++ b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt @@ -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 @@ -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() val expectedWebhookResponse = DestinationMessageResponse(RestStatus.OK.status, "{}") val httpResponse = mockk() - EasyMock.expect(mockHttpClient.execute(EasyMock.anyObject(HttpPost::class.java))).andReturn(httpResponse) + every { mockHttpClient.execute(any()) } 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) @@ -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() val expectedWebhookResponse = DestinationMessageResponse(RestStatus.OK.status, responseContent) val httpResponse = mockk() - EasyMock.expect(mockHttpClient.execute(EasyMock.anyObject(HttpPost::class.java))).andReturn(httpResponse) + every { mockHttpClient.execute(any()) } 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)