<commit_before>package com.github.jrh3k5.flume.rest;

import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.net.URI;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.apache.flume.Event;
import org.apache.flume.event.SimpleEvent;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

/**
 * Unit tests for {@link FlumeSinkServerResource}.
 * 
 * @author <NAME>
 */

@RunWith(MockitoJUnitRunner.class)
public class FlumeSinkServerResourceTest {
    private final FlumeSinkServerResource resource = new FlumeSinkServerResource();
    private final URI baseUri = URI.create("http://localhost:8080");
    @Mock
    private UriInfo uriInfo;

    /**
     * Set up the {@link UriInfo} object for each test.
     */
    @Before
    public void setUpUriInfo() {
        when(uriInfo.getBaseUri()).thenReturn(baseUri);
    }

    /**
     * Test the deletion of events.
     * 
     * @throws Exception
     *             If any errors occur during the test run.
     */
    @Test
    public void testDeleteEvents() throws Exception {
        final SimpleEvent stored = mock(SimpleEvent.class);
        resource.storeEvents(new SimpleEvent[] { stored }, uriInfo);

        assertThat(resource.getEvents().getEntity()).isEqualTo(new Event[] { stored });
        resource.deleteEvents();
        assertThat((Event[]) resource.getEvents().getEntity()).isEmpty();
    }

    /**
     * Test the retrieval of events.
     * 
     * @throws Exception
     *             If any errors occur during the test run.
     */
    @Test
    public void testGetEvents() throws Exception {
        final SimpleEvent stored = mock(SimpleEvent.class);
        resource.storeEvents(new SimpleEvent[] { stored }, uriInfo);

        final Response getResponse = resource.getEvents();
        assertThat(getResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
        assertThat(getResponse.getEntity()).isEqualTo(new Event[] { stored });
    }

    /**
     * Test the storage of events.
     * 
     * @throws Exception
     *             If any errors occur during the test run.
     */
    @Test
    public void testStoreEvents() throws Exception {
        final SimpleEvent stored = mock(SimpleEvent.class);
        final Response postResponse = resource.storeEvents(new SimpleEvent[] { stored }, uriInfo);
        assertThat(postResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
        assertThat(postResponse.getLocation()).isEqualTo(Response.Status.CREATED.getStatusCode());
    }
}<commit_msg>Fix unit tests for FlumeSinkServerResource<commit_after>package com.github.jrh3k5.flume.rest;

import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.net.URI;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.apache.flume.Event;
import org.apache.flume.event.SimpleEvent;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

/**
 * Unit tests for {@link FlumeSinkServerResource}.
 * 
 * @author <NAME>
 */

@RunWith(MockitoJUnitRunner.class)
public class FlumeSinkServerResourceTest {
    private final FlumeSinkServerResource resource = new FlumeSinkServerResource();
    private final URI baseUri = URI.create("http://localhost:8080");
    @Mock
    private UriInfo uriInfo;

    /**
     * Set up the {@link UriInfo} object for each test.
     */
    @Before
    public void setUpUriInfo() {
        when(uriInfo.getBaseUri()).thenReturn(baseUri);
    }

    /**
     * Test the deletion of events.
     * 
     * @throws Exception
     *             If any errors occur during the test run.
     */
    @Test
    public void testDeleteEvents() throws Exception {
        final SimpleEvent stored = mock(SimpleEvent.class);
        resource.storeEvents(new SimpleEvent[] { stored }, uriInfo);

        assertThat(resource.getEvents().getEntity()).isEqualTo(new Event[] { stored });
        resource.deleteEvents();
        assertThat((Object[]) resource.getEvents().getEntity()).isEmpty();
    }

    /**
     * Test the retrieval of events.
     * 
     * @throws Exception
     *             If any errors occur during the test run.
     */
    @Test
    public void testGetEvents() throws Exception {
        final SimpleEvent stored = mock(SimpleEvent.class);
        resource.storeEvents(new SimpleEvent[] { stored }, uriInfo);

        final Response getResponse = resource.getEvents();
        assertThat(getResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
        assertThat(getResponse.getEntity()).isEqualTo(new Event[] { stored });
    }

    /**
     * Test the storage of events.
     * 
     * @throws Exception
     *             If any errors occur during the test run.
     */
    @Test
    public void testStoreEvents() throws Exception {
        final SimpleEvent stored = mock(SimpleEvent.class);
        final Response postResponse = resource.storeEvents(new SimpleEvent[] { stored }, uriInfo);
        assertThat(postResponse.getStatus()).isEqualTo(Response.Status.CREATED.getStatusCode());
        assertThat(postResponse.getLocation()).isEqualTo(baseUri.resolve("events"));
    }
}
{'fraction_non_alphanumeric': 0.11372334609075997, 'fraction_numerical': 0.002186987424822307, 'mean_word_length': 3.0985810306198656, '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': '5327888', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1525, 'n_words': 358}