// Path: upload-parser-core/src/main/java/com/github/elopteryx/upload/errors/PartSizeException.java
// public class PartSizeException extends UploadSizeException {
// 
//     /**
//      * Public constructor.
//      * @param message The message of the exception
//      * @param actual The known size at the time of the exception
//      * @param permitted The maximum permitted size
//      */
//     public PartSizeException(final String message, final long actual, final long permitted) {
//         super(message, actual, permitted);
//     }
// }
// 
// Path: upload-parser-core/src/main/java/com/github/elopteryx/upload/errors/RequestSizeException.java
// public class RequestSizeException extends UploadSizeException {
// 
//     /**
//      * Public constructor.
//      * @param message The message of the exception
//      * @param actual The known size at the time of the exception in bytes
//      * @param permitted The maximum permitted size in bytes
//      */
//     public RequestSizeException(final String message, final long actual, final long permitted) {
//         super(message, actual, permitted);
//     }
// }
// 
// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/util/Servlets.java
// public final class Servlets {
// 
//     private Servlets() {
//         // No need to instantiate
//     }
// 
//     /**
//      * Creates a new mock servlet request.
//      * @return The mocked request.
//      * @throws Exception If an error occurred
//      */
//     public static HttpServletRequest newRequest() throws Exception {
//         final var request = mock(HttpServletRequest.class);
// 
//         when(request.getMethod()).thenReturn("POST");
//         when(request.getContentType()).thenReturn("multipart/");
//         when(request.getContentLengthLong()).thenReturn(1024 * 1024L);
//         when(request.getInputStream()).thenReturn(new MockServletInputStream());
//         when(request.isAsyncSupported()).thenReturn(true);
// 
//         return request;
//     }
// 
//     /**
//      * Creates a new mock servlet response.
//      * @return The mocked response.
//      */
//     public static HttpServletResponse newResponse() {
//         final var response = mock(HttpServletResponse.class);
// 
//         when(response.getStatus()).thenReturn(200);
// 
//         return response;
//     }
// }


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import com.github.elopteryx.upload.errors.PartSizeException;
import com.github.elopteryx.upload.errors.RequestSizeException;
import com.github.elopteryx.upload.util.Servlets;
import org.junit.jupiter.api.Test;

    @Test
    void setup_should_work_if_lesser() throws Exception {
        runSetupForSize(SIZE - 1, SIZE, -1);
    }

    @Test
    void setup_should_work_if_equals() throws Exception {
        runSetupForSize(SIZE, SIZE, -1);
    }

    @Test
    void setup_should_throw_size_exception_if_greater() {
        assertThrows(RequestSizeException.class, () -> runSetupForSize(SIZE + 1, SIZE, -1));
    }

    @Test
    void parser_should_throw_exception_for_request_size() {
        final var exception = assertThrows(RequestSizeException.class, () -> {
            final var parser = runSetupForSize(0, SMALL_SIZE, -1);
            for (var i = 0; i < 11; i++) {
                parser.checkRequestSize(100);
            }
        });
        assertEquals(exception.getPermittedSize(), SMALL_SIZE);
        assertTrue(exception.getActualSize() > SMALL_SIZE);
    }

    @Test
    void parser_should_throw_exception_for_part_size() {
// Path: upload-parser-core/src/main/java/com/github/elopteryx/upload/errors/PartSizeException.java
// public class PartSizeException extends UploadSizeException {
// 
//     /**
//      * Public constructor.
//      * @param message The message of the exception
//      * @param actual The known size at the time of the exception
//      * @param permitted The maximum permitted size
//      */
//     public PartSizeException(final String message, final long actual, final long permitted) {
//         super(message, actual, permitted);
//     }
// }
// 
// Path: upload-parser-core/src/main/java/com/github/elopteryx/upload/errors/RequestSizeException.java
// public class RequestSizeException extends UploadSizeException {
// 
//     /**
//      * Public constructor.
//      * @param message The message of the exception
//      * @param actual The known size at the time of the exception in bytes
//      * @param permitted The maximum permitted size in bytes
//      */
//     public RequestSizeException(final String message, final long actual, final long permitted) {
//         super(message, actual, permitted);
//     }
// }
// 
// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/util/Servlets.java
// public final class Servlets {
// 
//     private Servlets() {
//         // No need to instantiate
//     }
// 
//     /**
//      * Creates a new mock servlet request.
//      * @return The mocked request.
//      * @throws Exception If an error occurred
//      */
//     public static HttpServletRequest newRequest() throws Exception {
//         final var request = mock(HttpServletRequest.class);
// 
//         when(request.getMethod()).thenReturn("POST");
//         when(request.getContentType()).thenReturn("multipart/");
//         when(request.getContentLengthLong()).thenReturn(1024 * 1024L);
//         when(request.getInputStream()).thenReturn(new MockServletInputStream());
//         when(request.isAsyncSupported()).thenReturn(true);
// 
//         return request;
//     }
// 
//     /**
//      * Creates a new mock servlet response.
//      * @return The mocked response.
//      */
//     public static HttpServletResponse newResponse() {
//         final var response = mock(HttpServletResponse.class);
// 
//         when(response.getStatus()).thenReturn(200);
// 
//         return response;
//     }
// }


// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/internal/AbstractUploadParserTest.java
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import com.github.elopteryx.upload.errors.PartSizeException;
import com.github.elopteryx.upload.errors.RequestSizeException;
import com.github.elopteryx.upload.util.Servlets;
import org.junit.jupiter.api.Test;


    @Test
    void setup_should_work_if_lesser() throws Exception {
        runSetupForSize(SIZE - 1, SIZE, -1);
    }

    @Test
    void setup_should_work_if_equals() throws Exception {
        runSetupForSize(SIZE, SIZE, -1);
    }

    @Test
    void setup_should_throw_size_exception_if_greater() {
        assertThrows(RequestSizeException.class, () -> runSetupForSize(SIZE + 1, SIZE, -1));
    }

    @Test
    void parser_should_throw_exception_for_request_size() {
        final var exception = assertThrows(RequestSizeException.class, () -> {
            final var parser = runSetupForSize(0, SMALL_SIZE, -1);
            for (var i = 0; i < 11; i++) {
                parser.checkRequestSize(100);
            }
        });
        assertEquals(exception.getPermittedSize(), SMALL_SIZE);
        assertTrue(exception.getActualSize() > SMALL_SIZE);
    }

    @Test
    void parser_should_throw_exception_for_part_size() {
        final var exception = assertThrows(PartSizeException.class, () -> {