/**
 * 
 */
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)));
    }

}

@@ -149,43 +149,8 @@
 t;%0D%0A
-import static org.junit.Assert.*;%0D%0A
 impo
@@ -189,16 +189,16 @@
 tThat;%0D%0A
+
 %0D%0Aimport
@@ -289,22 +289,18 @@
 Test %7B%0D%0A
-    
 %0D%0A
+
     /**%0D
@@ -439,32 +439,38 @@
 tion %7B%0D%0A        
+final 
 SpringViolation 
@@ -518,32 +518,38 @@
 bc1%22);%0D%0A        
+final 
 SpringViolation 
@@ -597,32 +597,38 @@
 bc1%22);%0D%0A        
+final 
 SpringViolation 
@@ -675,32 +675,38 @@
 null);%0D%0A        
+final 
 SpringViolation 
@@ -754,32 +754,38 @@
 bc1%22);%0D%0A        
+final 
 SpringViolation 
@@ -1220,34 +1220,26 @@
 (is(v4)));%0D%0A
-        
 %0D%0A
+
         asse
@@ -1298,34 +1298,26 @@
 (is(v1)));%0D%0A
-        
 %0D%0A
+
         asse
@@ -1454,31 +1454,19 @@
 );%0D%0A
-        
 %0D%0A
+
     %7D%0D%0A
-    
 %0D%0A
+
     
@@ -1598,32 +1598,38 @@
 tion %7B%0D%0A        
+final 
 SpringViolation 
@@ -1778,32 +1778,38 @@
 1%5D%22));%0D%0A        
+final 
 SpringViolation 
@@ -1953,14 +1953,10 @@
  %7D%0D%0A
-    
 %0D%0A
+
     
@@ -2098,16 +2098,22 @@
         
+final 
 SpringVi
@@ -2258,11 +2258,487 @@
    %7D%0D%0A%0D%0A
+    /**%0D%0A     * Test create%0D%0A     * %0D%0A     * @throws Exception%0D%0A     */%0D%0A    @Test(expected = IllegalArgumentException.class)%0D%0A    public void testCreate1() throws Exception %7B%0D%0A        SpringViolation.create(null, %22id%22, null);%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Test create%0D%0A     * %0D%0A     * @throws Exception%0D%0A     */%0D%0A    @Test(expected = IllegalArgumentException.class)%0D%0A    public void testCreate2() throws Exception %7B%0D%0A        SpringViolation.create(%22file%22, null, null);%0D%0A    %7D%0D%0A%0D%0A
 %7D%0D%0A

add factory method tests