use of com.linkedin.restli.client.testutils.MockRestliResponseExceptionBuilder in project rest.li by linkedin.
the class TestMockRestliResponseExceptionBuilder method testNullErrorResponse.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullErrorResponse() {
MockRestliResponseExceptionBuilder exceptionBuilder = new MockRestliResponseExceptionBuilder();
exceptionBuilder.setErrorResponse(null);
}
use of com.linkedin.restli.client.testutils.MockRestliResponseExceptionBuilder in project rest.li by linkedin.
the class TestMockRestliResponseExceptionBuilder method testOldProtocolVersion.
@Test
public void testOldProtocolVersion() {
ProtocolVersion expectedProtocolVersion = AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion();
RestLiResponseException exception = new MockRestliResponseExceptionBuilder().setProtocolVersion(expectedProtocolVersion).build();
RestResponse errorResponse = exception.getResponse();
assertEquals(errorResponse.getHeader(RestConstants.HEADER_LINKEDIN_ERROR_RESPONSE), "true");
assertEquals(errorResponse.getHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION), expectedProtocolVersion.toString());
}
use of com.linkedin.restli.client.testutils.MockRestliResponseExceptionBuilder in project rest.li by linkedin.
the class TestMockRestliResponseExceptionBuilder method testOverwriteStatus.
@Test
public void testOverwriteStatus() {
ErrorResponse noStatusErrorResponse = new ErrorResponse();
RestLiResponseException exception = new MockRestliResponseExceptionBuilder().setErrorResponse(noStatusErrorResponse).build();
assertEquals(exception.getStatus(), 500);
}
use of com.linkedin.restli.client.testutils.MockRestliResponseExceptionBuilder in project rest.li by linkedin.
the class TestMockRestliResponseExceptionBuilder method testSetStatus.
@Test
public void testSetStatus() {
RestLiResponseException exception = new MockRestliResponseExceptionBuilder().setStatus(HttpStatus.S_403_FORBIDDEN).build();
assertEquals(exception.getStatus(), 403);
}
use of com.linkedin.restli.client.testutils.MockRestliResponseExceptionBuilder in project rest.li by linkedin.
the class TestMockRestliResponseExceptionBuilder method testAddCookiesAndHeaders.
@Test
public void testAddCookiesAndHeaders() {
Map.Entry<String, String> expectedEntry = new AbstractMap.SimpleEntry<>("foo", "bar");
HttpCookie expectedCookie = new HttpCookie("bar", "foo");
Map<String, String> headers = new HashMap<>();
headers.put(expectedEntry.getKey(), expectedEntry.getValue());
List<HttpCookie> cookies = new ArrayList<>();
cookies.add(expectedCookie);
RestLiResponseException exception = new MockRestliResponseExceptionBuilder().setHeaders(headers).setCookies(cookies).build();
RestResponse errorResponse = exception.getResponse();
assertEquals(errorResponse.getHeader(expectedEntry.getKey()), expectedEntry.getValue());
assertEquals(errorResponse.getCookies().get(0), "bar=foo");
}
Aggregations