<commit_before>package net.kencochrane.raven.event;

import net.kencochrane.raven.event.interfaces.SentryInterface;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.net.InetAddress;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class EventBuilderTest {
    private EventBuilder eventBuilder;

    @BeforeMethod
    public void setUp() throws Exception {
        eventBuilder = new EventBuilder();
    }

    @Test
    public void testMandatoryValuesAutomaticallySet() throws Exception {
        Event event = eventBuilder.build();

        assertThat(event.getId(), is(notNullValue()));
        assertThat(event.getTimestamp(), is(notNullValue()));
        assertThat(event.getPlatform(), is(EventBuilder.DEFAULT_PLATFORM));
        assertThat(event.getServerName(), is(InetAddress.getLocalHost().getCanonicalHostName()));
    }

    @Test
    public void testMandatoryValuesNotOverwritten() throws Exception {
        UUID uuid = UUID.randomUUID();
        Date timestamp = new Date();
        String platform = UUID.randomUUID().toString();
        String serverName = UUID.randomUUID().toString();

        Event event = new EventBuilder(uuid)
                .setTimestamp(timestamp)
                .setPlatform(platform)
                .setServerName(serverName)
                .build();

        assertThat(event.getId(), is(uuid));<commit_msg>Add a TODO due to an issue encountered during tests execution<commit_after>package net.kencochrane.raven.event;

import net.kencochrane.raven.event.interfaces.SentryInterface;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.net.InetAddress;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class EventBuilderTest {
    private EventBuilder eventBuilder;

    @BeforeMethod
    public void setUp() throws Exception {
        eventBuilder = new EventBuilder();
    }

    @Test
    public void testMandatoryValuesAutomaticallySet() throws Exception {
        Event event = eventBuilder.build();

        assertThat(event.getId(), is(notNullValue()));
        assertThat(event.getTimestamp(), is(notNullValue()));
        assertThat(event.getPlatform(), is(EventBuilder.DEFAULT_PLATFORM));
        //TODO: This test can fail if HostnameCache times out (happened once), mock InetAddress.getLocalHost().getCanonicalHostName() for instant reliable results)
        assertThat(event.getServerName(), is(InetAddress.getLocalHost().getCanonicalHostName()));
    }

    @Test
    public void testMandatoryValuesNotOverwritten() throws Exception {
        UUID uuid = UUID.randomUUID();
        Date timestamp = new Date();
        String platform = UUID.randomUUID().toString();
        String serverName = UUID.randomUUID().toString();

        Event event = new EventBuilder(uuid)
                .setTimestamp(timestamp)
                .setPlatform(platform)
                .setServerName(serverName)
                .build();

        assertThat(event.getId(), is(uuid));
{'fraction_non_alphanumeric': 0.10463071512309496, 'fraction_numerical': 0.0, 'mean_word_length': 3.5026385224274406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6615670', 'n_tokens_mistral': 931, 'n_tokens_neox': 925, 'n_words': 204}