<commit_before>/**
 * 
 */
package net.sf.plugfy.verifier.violations;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.*;
import static org.junit.Assert.assertThat;

import org.junit.Test;


/**
 * 
 * @author markus
 */
public class SpringViolationTest {
    
    /**
     * Test equals and hashCode
     * @throws Exception
     */
    @Test
    public void testEqualsAndHashCode() throws Exception {
        SpringViolation v1 = SpringViolation.create("f1", "b1", "bc1");
        SpringViolation v2 = SpringViolation.create("f1", "b1", "bc1");
        SpringViolation v3 = SpringViolation.create("f1", "b1", null);
        SpringViolation v4 = SpringViolation.create("f4", "b1", "bc1");
        SpringViolation v5 = SpringViolation.create("f1", "b2", "bc1");
        assertThat(v1, is(v1));
        assertThat(v1, is(v2));
        assertThat(Integer.valueOf(v1.hashCode()), is(Integer.valueOf(v2.hashCode())));
        assertThat(v2, is(v1));
        assertThat(Integer.valueOf(v2.hashCode()), is(Integer.valueOf(v1.hashCode())));
        assertThat(v1, not(is(v3)));
        assertThat(v3, not(is(v1)));
        assertThat(v1, not(is(v4)));
        
        assertThat(v1, not(is(v5)));
        assertThat(v5, not(is(v1)));
        
        assertThat(Boolean.valueOf(v1.equals(null)), is(Boolean.FALSE));
        assertThat(Boolean.valueOf(v1.equals("")), is(Boolean.FALSE));
        
    }
    
    /**
     * Test toString
     * 
     * @throws Exception
     */
    @Test
    public void testToString() throws Exception {
        SpringViolation v1 = SpringViolation.create("f1", "b1", "bc1");
        assertThat(v1.toString(), is("SpringViolation [sourceFile=f1, beanId=b1, beanClass=bc1]"));
        SpringViolation v3 = SpringViolation.create("f1", "b1", null);
        assertThat(v3.toString(), is("SpringViolation [sourceFile=f1, beanId=b1]"));
    }
    
    /**
     * Test compareTo
     * 
     * @throws Exception
     */
    @Test
    public void testCompareTo() throws Exception {
        SpringViolation v1 = SpringViolation.create("f1", "b1", "bc1");
        assertThat(Integer.valueOf(v1.compareTo(v1)), is(Integer.valueOf(0)));
    }

}<commit_msg>add factory method tests<commit_after>/**
 * 
 */
package net.sf.plugfy.verifier.violations;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;

import org.junit.Test;


/**
 * 
 * @author markus
 */
public class SpringViolationTest {

    /**
     * Test equals and hashCode
     * @throws Exception
     */
    @Test
    public void testEqualsAndHashCode() throws Exception {
        final SpringViolation v1 = SpringViolation.create("f1", "b1", "bc1");
        final SpringViolation v2 = SpringViolation.create("f1", "b1", "bc1");
        final SpringViolation v3 = SpringViolation.create("f1", "b1", null);
        final SpringViolation v4 = SpringViolation.create("f4", "b1", "bc1");
        final SpringViolation v5 = SpringViolation.create("f1", "b2", "bc1");
        assertThat(v1, is(v1));
        assertThat(v1, is(v2));
        assertThat(Integer.valueOf(v1.hashCode()), is(Integer.valueOf(v2.hashCode())));
        assertThat(v2, is(v1));
        assertThat(Integer.valueOf(v2.hashCode()), is(Integer.valueOf(v1.hashCode())));
        assertThat(v1, not(is(v3)));
        assertThat(v3, not(is(v1)));
        assertThat(v1, not(is(v4)));

        assertThat(v1, not(is(v5)));
        assertThat(v5, not(is(v1)));

        assertThat(Boolean.valueOf(v1.equals(null)), is(Boolean.FALSE));
        assertThat(Boolean.valueOf(v1.equals("")), is(Boolean.FALSE));

    }

    /**
     * Test toString
     * 
     * @throws Exception
     */
    @Test
    public void testToString() throws Exception {
        final SpringViolation v1 = SpringViolation.create("f1", "b1", "bc1");
        assertThat(v1.toString(), is("SpringViolation [sourceFile=f1, beanId=b1, beanClass=bc1]"));
        final SpringViolation v3 = SpringViolation.create("f1", "b1", null);
        assertThat(v3.toString(), is("SpringViolation [sourceFile=f1, beanId=b1]"));
    }

    /**
     * Test compareTo
     * 
     * @throws Exception
     */
    @Test
    public void testCompareTo() throws Exception {
        final SpringViolation v1 = SpringViolation.create("f1", "b1", "bc1");
        assertThat(Integer.valueOf(v1.compareTo(v1)), is(Integer.valueOf(0)));
    }

    /**
     * Test create
     * 
     * @throws Exception
     */
    @Test(expected = IllegalArgumentException.class)
    public void testCreate1() throws Exception {
        SpringViolation.create(null, "id", null);
    }

    /**
     * Test create
     * 
     * @throws Exception
     */
    @Test(expected = IllegalArgumentException.class)
    public void testCreate2() throws Exception {
        SpringViolation.create("file", null, null);
    }

}
{'fraction_non_alphanumeric': 0.15379939209726443, 'fraction_numerical': 0.02553191489361702, 'mean_word_length': 2.987075928917609, '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': '5629392', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1634, 'n_words': 294}