// Path: src/main/java/com/yelp/clientlib/exception/exceptions/BusinessUnavailable.java
// public class BusinessUnavailable extends YelpAPIError {
//     public BusinessUnavailable(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/main/java/com/yelp/clientlib/exception/exceptions/InternalError.java
// public class InternalError extends YelpAPIError {
//     public InternalError(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/main/java/com/yelp/clientlib/exception/exceptions/InvalidParameter.java
// public class InvalidParameter extends YelpAPIError {
//     public InvalidParameter(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/main/java/com/yelp/clientlib/exception/exceptions/UnexpectedAPIError.java
// public class UnexpectedAPIError extends YelpAPIError {
//     public UnexpectedAPIError(int code, String message) {
//         this(code, message, null, null);
//     }
// 
//     public UnexpectedAPIError(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/test/java/com/yelp/clientlib/utils/ErrorTestUtils.java
// public class ErrorTestUtils {
// 
//     /**
//      * Verify a {@link YelpAPIError} contains correct information.
//      *
//      * @param error         The YelpAPIError to be verified.
//      * @param expectCode    Expected error code.
//      * @param expectMessage Expected error message.
//      * @param expectId      Expected error Id.
//      * @param expectText    Expected error text.
//      */
//     public static void verifyErrorContent(
//             YelpAPIError error,
//             int expectCode,
//             String expectMessage,
//             String expectId,
//             String expectText
//     ) {
//         Assert.assertEquals(expectCode, error.getCode());
//         Assert.assertEquals(expectMessage, error.getMessage());
//         Assert.assertEquals(expectId, error.getErrorId());
//         Assert.assertEquals(expectText, error.getText());
//     }
// }


import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import com.yelp.clientlib.exception.exceptions.BusinessUnavailable;
import com.yelp.clientlib.exception.exceptions.InternalError;
import com.yelp.clientlib.exception.exceptions.InvalidParameter;
import com.yelp.clientlib.exception.exceptions.UnexpectedAPIError;
import com.yelp.clientlib.utils.ErrorTestUtils;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.IOException;
package com.yelp.clientlib.exception;




@RunWith(PowerMockRunner.class)
@PrepareForTest({Request.class, Response.class, Protocol.class})
public class ErrorHandlingInterceptorTest {

    Interceptor errorHandlingInterceptor;

    @Before
    public void setUp() {
        this.errorHandlingInterceptor = new ErrorHandlingInterceptor();
    }

    /**
     * Ensure the interceptor does nothing besides proceeding the request if the request is done successfully.
     */
    @Test
    public void testSuccessfulRequestNotDoingAnythingExceptProceedingRequests() throws IOException {
        Request mockRequest = PowerMock.createMock(Request.class);
        Response mockResponse = PowerMock.createMock(Response.class);
        Interceptor.Chain mockChain = PowerMock.createMock(Interceptor.Chain.class);

        EasyMock.expect(mockChain.request()).andReturn(mockRequest);
        EasyMock.expect(mockChain.proceed(mockRequest)).andReturn(mockResponse);
        EasyMock.expect(mockResponse.isSuccessful()).andReturn(true);

        PowerMock.replay(mockRequest, mockResponse, mockChain);

        Response returnedResponse = errorHandlingInterceptor.intercept(mockChain);

        PowerMock.verify(mockChain);
        Assert.assertEquals(mockResponse, returnedResponse);
    }

    @Test
    public void testParseNullResponseBody() throws IOException {
        int errorCode = 500;
        String errorMessage = "Internal Server Error";

        Interceptor.Chain mockChain = mockChainWithErrorResponse(errorCode, errorMessage, null);
        try {
            errorHandlingInterceptor.intercept(mockChain);
// Path: src/main/java/com/yelp/clientlib/exception/exceptions/BusinessUnavailable.java
// public class BusinessUnavailable extends YelpAPIError {
//     public BusinessUnavailable(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/main/java/com/yelp/clientlib/exception/exceptions/InternalError.java
// public class InternalError extends YelpAPIError {
//     public InternalError(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/main/java/com/yelp/clientlib/exception/exceptions/InvalidParameter.java
// public class InvalidParameter extends YelpAPIError {
//     public InvalidParameter(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/main/java/com/yelp/clientlib/exception/exceptions/UnexpectedAPIError.java
// public class UnexpectedAPIError extends YelpAPIError {
//     public UnexpectedAPIError(int code, String message) {
//         this(code, message, null, null);
//     }
// 
//     public UnexpectedAPIError(int code, String message, String id, String text) {
//         super(code, message, id, text);
//     }
// }
// 
// Path: src/test/java/com/yelp/clientlib/utils/ErrorTestUtils.java
// public class ErrorTestUtils {
// 
//     /**
//      * Verify a {@link YelpAPIError} contains correct information.
//      *
//      * @param error         The YelpAPIError to be verified.
//      * @param expectCode    Expected error code.
//      * @param expectMessage Expected error message.
//      * @param expectId      Expected error Id.
//      * @param expectText    Expected error text.
//      */
//     public static void verifyErrorContent(
//             YelpAPIError error,
//             int expectCode,
//             String expectMessage,
//             String expectId,
//             String expectText
//     ) {
//         Assert.assertEquals(expectCode, error.getCode());
//         Assert.assertEquals(expectMessage, error.getMessage());
//         Assert.assertEquals(expectId, error.getErrorId());
//         Assert.assertEquals(expectText, error.getText());
//     }
// }


// Path: src/test/java/com/yelp/clientlib/exception/ErrorHandlingInterceptorTest.java
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import com.yelp.clientlib.exception.exceptions.BusinessUnavailable;
import com.yelp.clientlib.exception.exceptions.InternalError;
import com.yelp.clientlib.exception.exceptions.InvalidParameter;
import com.yelp.clientlib.exception.exceptions.UnexpectedAPIError;
import com.yelp.clientlib.utils.ErrorTestUtils;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.IOException;

package com.yelp.clientlib.exception;




@RunWith(PowerMockRunner.class)
@PrepareForTest({Request.class, Response.class, Protocol.class})
public class ErrorHandlingInterceptorTest {

    Interceptor errorHandlingInterceptor;

    @Before
    public void setUp() {
        this.errorHandlingInterceptor = new ErrorHandlingInterceptor();
    }

    /**
     * Ensure the interceptor does nothing besides proceeding the request if the request is done successfully.
     */
    @Test
    public void testSuccessfulRequestNotDoingAnythingExceptProceedingRequests() throws IOException {
        Request mockRequest = PowerMock.createMock(Request.class);
        Response mockResponse = PowerMock.createMock(Response.class);
        Interceptor.Chain mockChain = PowerMock.createMock(Interceptor.Chain.class);

        EasyMock.expect(mockChain.request()).andReturn(mockRequest);
        EasyMock.expect(mockChain.proceed(mockRequest)).andReturn(mockResponse);
        EasyMock.expect(mockResponse.isSuccessful()).andReturn(true);

        PowerMock.replay(mockRequest, mockResponse, mockChain);

        Response returnedResponse = errorHandlingInterceptor.intercept(mockChain);

        PowerMock.verify(mockChain);
        Assert.assertEquals(mockResponse, returnedResponse);
    }

    @Test
    public void testParseNullResponseBody() throws IOException {
        int errorCode = 500;
        String errorMessage = "Internal Server Error";

        Interceptor.Chain mockChain = mockChainWithErrorResponse(errorCode, errorMessage, null);
        try {
            errorHandlingInterceptor.intercept(mockChain);
        } catch (UnexpectedAPIError error) {