|
|
@ -17,6 +17,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
package com.tencent.cloud.polaris.circuitbreaker.instrument.resttemplate;
|
|
|
|
package com.tencent.cloud.polaris.circuitbreaker.instrument.resttemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
@ -35,7 +36,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
|
public class PolarisCircuitBreakerHttpResponseTest {
|
|
|
|
public class PolarisCircuitBreakerHttpResponseTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testConstructorWithCodeOnly() {
|
|
|
|
void testConstructorWithCodeOnly() throws IOException {
|
|
|
|
PolarisCircuitBreakerHttpResponse response = new PolarisCircuitBreakerHttpResponse(200);
|
|
|
|
PolarisCircuitBreakerHttpResponse response = new PolarisCircuitBreakerHttpResponse(200);
|
|
|
|
|
|
|
|
|
|
|
|
Assertions.assertEquals(200, response.getStatusCode().value());
|
|
|
|
Assertions.assertEquals(200, response.getStatusCode().value());
|
|
|
@ -45,7 +46,7 @@ public class PolarisCircuitBreakerHttpResponseTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testConstructorWithCodeAndBody() {
|
|
|
|
void testConstructorWithCodeAndBody() throws IOException {
|
|
|
|
String body = "test body";
|
|
|
|
String body = "test body";
|
|
|
|
PolarisCircuitBreakerHttpResponse response = new PolarisCircuitBreakerHttpResponse(200, body);
|
|
|
|
PolarisCircuitBreakerHttpResponse response = new PolarisCircuitBreakerHttpResponse(200, body);
|
|
|
|
|
|
|
|
|
|
|
@ -56,7 +57,7 @@ public class PolarisCircuitBreakerHttpResponseTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testConstructorWithCodeHeadersAndBody() {
|
|
|
|
void testConstructorWithCodeHeadersAndBody() throws IOException {
|
|
|
|
String body = "test body";
|
|
|
|
String body = "test body";
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
@ -73,7 +74,7 @@ public class PolarisCircuitBreakerHttpResponseTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testConstructorWithFallbackInfo() {
|
|
|
|
void testConstructorWithFallbackInfo() throws IOException {
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
|
CircuitBreakerStatus.FallbackInfo fallbackInfo = new CircuitBreakerStatus.FallbackInfo(200, headers, "test body");
|
|
|
|
CircuitBreakerStatus.FallbackInfo fallbackInfo = new CircuitBreakerStatus.FallbackInfo(200, headers, "test body");
|
|
|
|