Skip to content

Commit

Permalink
Implement MockWebServersTest
Browse files Browse the repository at this point in the history
  • Loading branch information
sleberknight committed Jun 21, 2024
1 parent e7aeb37 commit 3dad0fd
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
package org.kiwiproject.test.okhttp3.mockwebserver;

import static org.assertj.core.api.Assertions.assertThat;

import okhttp3.mockwebserver.MockWebServer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.kiwiproject.io.KiwiIO;

import java.io.IOException;
import java.net.URI;

@DisplayName("MockWebServers")
class MockWebServersTest {

// TODO
private MockWebServer server;

@BeforeEach
void setUp() throws IOException {
server = new MockWebServer();
server.start();
}

@AfterEach
void tearDown() {
KiwiIO.closeQuietly(server);
}

@Nested
class UriMethod {

@ParameterizedTest
@ValueSource(strings = { "", "/", "/status", "/status/", "/users/active" })
void shouldCreateUri_WithPath(String path) {
var url = server.url(path).toString();
var expectedUri = URI.create(url);
assertThat(MockWebServers.uri(server, path)).isEqualTo(expectedUri);
}
}
}

0 comments on commit 3dad0fd

Please sign in to comment.