statusLine = EasyMock.createMock(StatusLine.class);
}
@Test
public void testCanParseBoxServerError() throws BoxRestException, IllegalStateException, IOException, BoxJSONException {
BoxJSONParser jsonParser = new BoxJSONParser(new BoxResourceHub());
EasyMock.reset(boxResponse, response, entity);
inputStream = new ByteArrayInputStream(jsonParser.convertBoxObjectToJSONString(error).getBytes());
EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response);
EasyMock.expect(response.getEntity()).andStubReturn(entity);
EasyMock.expect(entity.getContent()).andStubReturn(inputStream);
EasyMock.expect(entity.isStreaming()).andStubReturn(false);
EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response);
EasyMock.expect(response.getStatusLine()).andStubReturn(statusLine);
EasyMock.expect(statusLine.getStatusCode()).andStubReturn(statusCode);
EasyMock.replay(boxResponse, response, entity, statusLine);
ErrorResponseParser parser = new ErrorResponseParser(jsonParser);
Object object = parser.parse(boxResponse);
Assert.assertEquals(BoxServerError.class, object.getClass());
Assert.assertEquals(jsonParser.convertBoxObjectToJSONString(error), jsonParser.convertBoxObjectToJSONString(object));
EasyMock.verify(boxResponse, response, entity, statusLine);
}