<commit_before>package org.forest.exception;

import org.forest.exceptions.ForestException;
import org.forest.exceptions.ForestHandlerException;
import org.forest.exceptions.ForestNetworkException;
import org.forest.exceptions.ForestRuntimeException;
import org.forest.http.ForestRequest;
import org.forest.http.ForestResponse;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.mock;

/**
 * @author gongjun[<EMAIL>]
 * @since 2017-05-18 12:33
 */
public class TestExceptions {

    @Test
    public void testForestException() {
        try {
            throw new ForestException("test exception");
        } catch (ForestException e) {
            assertEquals("test exception", e.getMessage());
        }
    }

    @Test
    public void testForestNetworkException() {
        try {
            throw new ForestNetworkException("test network exception", 500);
        } catch (ForestNetworkException e) {
            assertEquals("HTTP 500 Error: test network exception", e.getMessage());
            assertEquals(Integer.valueOf(500), e.getStatusCode());
        }
    }

    @Test
    public void testForestRuntimeException() {
        try {
            throw new Exception("first Exception");
        } catch (Exception e) {
            try {
                throw new ForestRuntimeException("second Exception", e);
            } catch (ForestRuntimeException fe) {
                assertEquals("second Exception", fe.getMessage());
                assertEquals(e, fe.getCause());
            }
        }

        try {
            throw new ForestRuntimeException("runtime exception");
        } catch (ForestRuntimeException fe) {
            assertEquals("runtime exception", fe.getMessage());
        }
    }

    @Test
    public void testForestHandlerException() {
        ForestRequest request = mock(ForestRequest.class);
        ForestResponse response = mock(ForestResponse.class);
        try {
            throw new ForestHandlerException("test", request, response);
        } catch (ForestHandlerException e) {
            assertEquals("test", e.getMessage());
            assertEquals(request, e.getRequest());
            assertEquals(response, e.getResponse());
        }
    }

}<commit_msg>test exceptions<commit_after>package org.forest.exception;

import org.forest.exceptions.ForestException;
import org.forest.exceptions.ForestHandlerException;
import org.forest.exceptions.ForestNetworkException;
import org.forest.exceptions.ForestRuntimeException;
import org.forest.http.ForestRequest;
import org.forest.http.ForestResponse;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.mock;

/**
 * @author gongjun[<EMAIL>]
 * @since 2017-05-18 12:33
 */
public class TestExceptions {

    @Test
    public void testForestException() {
        try {
            throw new ForestException("test exception");
        } catch (ForestException e) {
            assertEquals("test exception", e.getMessage());
        }
    }

    @Test
    public void testForestNetworkException() {
        try {
            throw new ForestNetworkException("test network exception", 500);
        } catch (ForestNetworkException e) {
            assertEquals("HTTP 500 Error: test network exception", e.getMessage());
            assertEquals(Integer.valueOf(500), e.getStatusCode());
        }
    }

    @Test
    public void testForestRuntimeException() {
        try {
            throw new Exception("first Exception");
        } catch (Exception e) {
            try {
                throw new ForestRuntimeException( e);
            } catch (ForestRuntimeException fe) {
                assertEquals(e, fe.getCause());
            }
        }

        try {
            throw new Exception("first Exception");
        } catch (Exception e) {
            try {
                throw new ForestRuntimeException("second Exception", e);
            } catch (ForestRuntimeException fe) {
                assertEquals("second Exception", fe.getMessage());
                assertEquals(e, fe.getCause());
            }
        }

        try {
            throw new ForestRuntimeException("runtime exception");
        } catch (ForestRuntimeException fe) {
            assertEquals("runtime exception", fe.getMessage());
        }
    }

    @Test
    public void testForestHandlerException() {
        ForestRequest request = mock(ForestRequest.class);
        ForestResponse response = mock(ForestResponse.class);
        try {
            throw new ForestHandlerException("test", request, response);
        } catch (ForestHandlerException e) {
            assertEquals("test", e.getMessage());
            assertEquals(request, e.getRequest());
            assertEquals(response, e.getResponse());
        }

        try {
            throw new Exception("first Exception");
        } catch (Exception e) {
            try {
                throw new ForestHandlerException("second Exception", e, request, response);
            } catch (ForestHandlerException fe) {
                assertEquals("second Exception", fe.getMessage());
                assertEquals(e, fe.getCause());
                assertEquals(request, fe.getRequest());
                assertEquals(response, fe.getResponse());
            }
        }

        try {
            throw new Exception("first Exception");
        } catch (Exception e) {
            try {
                throw new ForestHandlerException( e, request, response);
            } catch (ForestHandlerException fe) {
                assertEquals(e, fe.getCause());
                assertEquals(request, fe.getRequest());
                assertEquals(response, fe.getResponse());
            }
        }


    }

}
{'fraction_non_alphanumeric': 0.10326933056564608, 'fraction_numerical': 0.007265179034769071, 'mean_word_length': 2.257464788732394, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3402776', 'n_tokens_mistral': 1455, 'n_tokens_neox': 1388, 'n_words': 331}