View Javadoc

1   package org.itracker.model;
2   import static org.itracker.Assert.*;
3   import static org.junit.Assert.assertNotNull;
4   import static org.junit.Assert.assertTrue;
5   import static org.junit.Assert.fail;
6   
7   import org.junit.After;
8   import org.junit.Before;
9   import org.junit.Test;
10  
11  public class ProjectTest {
12  	private Project pro;
13  	
14  	@Test
15  	public void testSetName(){
16  		try{
17  			pro.setName(null);
18  			fail("did not throw IllegalArgumentException");
19  		} catch (IllegalArgumentException e){
20  			assertTrue(true);
21  		}
22  	}
23  	
24  	@Test
25  	public void testSetStatus(){
26  		try{
27  			pro.setStatus(null);
28  			fail("did not throw IllegalArgumentException");
29  		} catch (IllegalArgumentException e){
30  			assertTrue(true);
31  		}
32  	}
33  	
34  	@Test
35  	public void testToString(){
36  		assertNotNull("toString", pro.toString());
37  	}
38  	
39  	@Test
40  	public void testProjectComparator() {
41  		Project entityA = new Project("a");
42  		Project entityB = new Project("b");
43  
44  		assertEntityComparator("project comparator", Project.PROJECT_COMPARATOR, entityA, entityB);
45  		assertEntityComparator("project comparator", Project.PROJECT_COMPARATOR, entityA, null);
46  		assertEntityComparatorEquals("project comparator", Project.PROJECT_COMPARATOR, entityA, entityA);
47  		
48  		entityA.setName(entityB.getName());
49  		entityA.setId(1);
50  		entityB.setId(2);
51  
52  		assertEntityComparator("project comparator", Project.PROJECT_COMPARATOR, entityA, entityB);
53  		assertEntityComparator("project comparator", Project.PROJECT_COMPARATOR, entityA, null);
54  		
55  		entityB.setId(entityA.getId());
56  		assertEntityComparatorEquals("project comparator", Project.PROJECT_COMPARATOR, entityA, entityB);
57  		assertEntityComparatorEquals("project comparator", Project.PROJECT_COMPARATOR, entityA, entityA);
58  	}
59  	
60  	@Before
61      public void setUp() throws Exception {
62  		pro = new Project();
63      }
64  	
65  	@After
66  	public void tearDown() throws Exception {
67  		pro = null;
68  	}
69  
70  }