View Javadoc

1   package org.itracker.model;
2   import static org.junit.Assert.assertEquals;
3   import static org.junit.Assert.assertTrue;
4   import static org.junit.Assert.fail;
5   
6   import org.junit.After;
7   import org.junit.Before;
8   import org.junit.Test;
9   
10  public class PermissionTypeTest {
11  	
12  	@Test
13  	public void testFromCode(){
14  		try{
15  			PermissionType.fromCode(0);
16  			fail("did not throw IllegalArgumentException");
17  		} catch (IllegalArgumentException e){
18  			assertTrue(true);
19  		}
20  		try{
21  			PermissionType.fromCode(-2);
22  			fail("did not throw IllegalArgumentException");
23  		} catch (IllegalArgumentException e){
24  			assertTrue(true);
25  		}
26  		try{
27  			PermissionType.fromCode(14);
28  			fail("did not throw IllegalArgumentException");
29  		} catch (IllegalArgumentException e){
30  			assertTrue(true);
31  		}
32  		assertEquals("code 1",PermissionType.PRODUCT_ADMIN, PermissionType.fromCode(1));
33  		assertEquals("code 5",PermissionType.ISSUE_ASSIGN_SELF,PermissionType.fromCode(5));
34  		assertEquals("code -1",PermissionType.USER_ADMIN,PermissionType.fromCode(-1));
35  	}
36  	
37  	
38  	
39  	@Before
40      public void setUp() throws Exception {
41      }
42  	
43  	@After
44  	public void tearDown() throws Exception {
45  	}
46  
47  }