Skip to content

Commit

Permalink
Trying to fix OP-1370
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed Nov 29, 2024
1 parent dfe86f2 commit 790a80a
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
package org.isf.generaldata.configProvider;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -67,12 +69,15 @@ public void stopServer() {
void testGetTestParamsDataDefaultVersion() throws Exception {
// Set up the mock server to respond with the desired JSON
mockServer.when(request().withMethod("GET").withPath("/test")).respond(response().withStatusCode(200)
.withContentType(MediaType.APPLICATION_JSON)
.withBody(CONFIG_JSON));
.withContentType(MediaType.APPLICATION_JSON)
.withBody(CONFIG_JSON));

// Await until the mock server has started
await().atMost(5, SECONDS).until(() -> mockServer.hasStarted());

// Use MockedStatic to mock GeneralData
try (MockedStatic<GeneralData> mockedGeneralData = mockStatic(GeneralData.class);
MockedStatic<Version> mockedVersion = Mockito.mockStatic(Version.class)) {
MockedStatic<Version> mockedVersion = Mockito.mockStatic(Version.class)) {

// Mock the Version.getVersion() method to return a specific version
Version mockVersion = mock(Version.class);
Expand Down Expand Up @@ -100,12 +105,15 @@ void testGetTestParamsDataDefaultVersion() throws Exception {
void testGetTestParamsDataWithVersion() throws Exception {
// Set up the mock server to respond with the desired JSON
mockServer.when(request().withMethod("GET").withPath("/test")).respond(response().withStatusCode(200)
.withContentType(MediaType.APPLICATION_JSON)
.withBody(CONFIG_JSON));
.withContentType(MediaType.APPLICATION_JSON)
.withBody(CONFIG_JSON));

// Await until the mock server has started
await().atMost(5, SECONDS).until(() -> mockServer.hasStarted());

// Use MockedStatic to mock GeneralData
try (MockedStatic<GeneralData> mockedGeneralData = mockStatic(GeneralData.class);
MockedStatic<Version> mockedVersion = Mockito.mockStatic(Version.class)) {
MockedStatic<Version> mockedVersion = Mockito.mockStatic(Version.class)) {

// Mock the Version.getVersion() method to return a specific version
Version mockVersion = mock(Version.class);
Expand Down

0 comments on commit 790a80a

Please sign in to comment.