Skip to content

Commit c00f939

Browse files
committed
lint
1 parent 0cb2474 commit c00f939

File tree

1 file changed

+46
-51
lines changed

1 file changed

+46
-51
lines changed

util/src/test/java/io/kubernetes/client/MetricsTest.java

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,71 +12,66 @@
1212
*/
1313
package io.kubernetes.client;
1414

15+
import static com.github.tomakehurst.wiremock.client.WireMock.*;
16+
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
17+
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.fail;
19+
1520
import com.github.tomakehurst.wiremock.junit.WireMockRule;
1621
import io.kubernetes.client.openapi.ApiClient;
1722
import io.kubernetes.client.openapi.ApiException;
1823
import io.kubernetes.client.util.ClientBuilder;
24+
import java.io.IOException;
1925
import org.junit.Before;
2026
import org.junit.Rule;
2127
import org.junit.Test;
2228

23-
import java.io.IOException;
24-
25-
import static com.github.tomakehurst.wiremock.client.WireMock.*;
26-
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
27-
import static org.junit.Assert.assertEquals;
28-
import static org.junit.Assert.fail;
29-
3029
public class MetricsTest {
3130

32-
private ApiClient client;
31+
private ApiClient client;
3332

34-
@Rule
35-
public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort());
33+
@Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort());
3634

37-
@Before
38-
public void setup() throws IOException {
39-
client = new ClientBuilder().setBasePath("http://localhost:" + wireMockRule.port()).build();
40-
}
35+
@Before
36+
public void setup() throws IOException {
37+
client = new ClientBuilder().setBasePath("http://localhost:" + wireMockRule.port()).build();
38+
}
4139

42-
@Test
43-
public void getPodMetricsThrowsAPIExceptionWhenServerReturnsError() {
44-
String namespace = "default";
45-
Metrics metrics = new Metrics(client);
46-
wireMockRule.stubFor(
47-
get(urlEqualTo("/apis/metrics.k8s.io/v1beta1/namespaces/" + namespace + "/pods?watch=false"))
48-
.willReturn(
49-
aResponse()
50-
.withStatus(503)
51-
.withHeader("Content-Type", "text/plain")
52-
.withBody("Service Unavailable")
53-
)
54-
);
55-
try {
56-
metrics.getPodMetrics(namespace);
57-
fail("Expected ApiException to be thrown");
58-
} catch (ApiException ex) {
59-
assertEquals(503, ex.getCode());
60-
}
40+
@Test
41+
public void getPodMetricsThrowsAPIExceptionWhenServerReturnsError() {
42+
String namespace = "default";
43+
Metrics metrics = new Metrics(client);
44+
wireMockRule.stubFor(
45+
get(urlEqualTo(
46+
"/apis/metrics.k8s.io/v1beta1/namespaces/" + namespace + "/pods?watch=false"))
47+
.willReturn(
48+
aResponse()
49+
.withStatus(503)
50+
.withHeader("Content-Type", "text/plain")
51+
.withBody("Service Unavailable")));
52+
try {
53+
metrics.getPodMetrics(namespace);
54+
fail("Expected ApiException to be thrown");
55+
} catch (ApiException ex) {
56+
assertEquals(503, ex.getCode());
6157
}
58+
}
6259

63-
@Test
64-
public void getNodeMetricsThrowsAPIExceptionWhenServerReturnsError() {
65-
Metrics metrics = new Metrics(client);
66-
wireMockRule.stubFor(
67-
get(urlEqualTo("/apis/metrics.k8s.io/v1beta1/nodes?watch=false"))
68-
.willReturn(
69-
aResponse()
70-
.withStatus(503)
71-
.withHeader("Content-Type", "text/plain")
72-
.withBody("Service Unavailable")
73-
)
74-
);
75-
try {
76-
metrics.getNodeMetrics();
77-
fail("Expected ApiException to be thrown");
78-
} catch (ApiException ex) {
79-
assertEquals(503, ex.getCode());
80-
}
60+
@Test
61+
public void getNodeMetricsThrowsAPIExceptionWhenServerReturnsError() {
62+
Metrics metrics = new Metrics(client);
63+
wireMockRule.stubFor(
64+
get(urlEqualTo("/apis/metrics.k8s.io/v1beta1/nodes?watch=false"))
65+
.willReturn(
66+
aResponse()
67+
.withStatus(503)
68+
.withHeader("Content-Type", "text/plain")
69+
.withBody("Service Unavailable")));
70+
try {
71+
metrics.getNodeMetrics();
72+
fail("Expected ApiException to be thrown");
73+
} catch (ApiException ex) {
74+
assertEquals(503, ex.getCode());
8175
}
76+
}
8277
}

0 commit comments

Comments
 (0)