Skip to content

Commit 92592fd

Browse files
committed
a reformat code
1 parent 3e5db39 commit 92592fd

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

approvaltests-util-tests/src/test/java/com/spun/util/io/NetUtilsTest.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,20 @@ void testReadWebPageReturnsPageContent()
5959
Approvals.verify(s);
6060
}
6161
@Test
62-
void testLoadWebPageWithQueryParams() throws InterruptedException {
62+
void testLoadWebPageWithQueryParams() throws InterruptedException
63+
{
6364
MockWebServer server = new MockWebServer();
6465
server.enqueue(new MockResponse().setBody("hello, world!"));
65-
6666
NetUtils.loadWebPage(server.url("/api").toString(), "query=param");
67-
6867
RecordedRequest recordedRequest = server.takeRequest();
6968
assertEquals("/api?query=param", recordedRequest.getPath());
7069
}
7170
@Test
72-
void testReadWebPageWithoutQueryParams() throws InterruptedException {
71+
void testReadWebPageWithoutQueryParams() throws InterruptedException
72+
{
7373
MockWebServer server = new MockWebServer();
7474
server.enqueue(new MockResponse().setBody("hello, world!"));
75-
7675
NetUtils.readWebpage(server.url("/api").toString());
77-
7876
RecordedRequest recordedRequest = server.takeRequest();
7977
assertEquals("/api", recordedRequest.getPath());
8078
}

approvaltests-util/src/main/java/com/spun/util/io/NetUtils.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ public static String loadWebPage(String url, String parameters)
2626
connection = (HttpURLConnection) urlObj.openConnection();
2727
connection.setRequestMethod("GET");
2828
connection.connect();
29-
3029
int responseCode = connection.getResponseCode();
3130
if (responseCode != HttpURLConnection.HTTP_OK)
32-
{
33-
throw new RuntimeException("Failed to load web page, response code: " + responseCode);
34-
}
35-
31+
{ throw new RuntimeException("Failed to load web page, response code: " + responseCode); }
3632
InputStream inputStream = connection.getInputStream();
3733
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
3834
StringBuilder html = new StringBuilder();
@@ -56,7 +52,6 @@ public static String loadWebPage(String url, String parameters)
5652
}
5753
}
5854
}
59-
6055
public static String readWebpage(String query)
6156
{
6257
HttpURLConnection connection = null;
@@ -66,13 +61,9 @@ public static String readWebpage(String query)
6661
connection = (HttpURLConnection) url.openConnection();
6762
connection.setRequestMethod("GET");
6863
connection.connect();
69-
7064
int responseCode = connection.getResponseCode();
7165
if (responseCode != HttpURLConnection.HTTP_OK)
72-
{
73-
throw new RuntimeException("Failed to read web page, response code: " + responseCode);
74-
}
75-
66+
{ throw new RuntimeException("Failed to read web page, response code: " + responseCode); }
7667
InputStream inputStream = connection.getInputStream();
7768
return FileUtils.readStream(inputStream);
7869
}

0 commit comments

Comments
 (0)