View Javadoc

1   package org.itracker.model;
2   import static org.junit.Assert.assertEquals;
3   import static org.junit.Assert.assertFalse;
4   import static org.junit.Assert.assertNotNull;
5   import static org.junit.Assert.assertTrue;
6   import static org.junit.Assert.fail;
7   
8   import org.junit.After;
9   import org.junit.Before;
10  import org.junit.Test;
11  
12  public class ImportDataModelTest {
13  	private ImportDataModel idm;
14  	
15  	@Test
16  	public void testGetData(){		
17  		assertNotNull("data not null", idm.getData());
18  		AbstractEntity[] entities = new AbstractEntity[1];
19  		boolean[] existingModel = new boolean[1];
20  		idm.setData(entities, existingModel);
21  		assertEquals("data length is 1",1, idm.getData().length);
22  	}
23  	
24  	@Test
25  	public void testGetExistingModel(){		
26  		assertNotNull("existingModel not null", idm.getExistingModel());
27  		AbstractEntity[] entities = new AbstractEntity[1];
28  		boolean[] existingModel = new boolean[1];
29  		idm.setData(entities, existingModel);
30  		assertEquals("existingModel length is 1",1, idm.getExistingModel().length);
31  	}
32  	
33  	@Test
34  	public void testGetExistingModelByIndex(){		
35  		assertNotNull("existingModel not null", idm.getExistingModel());
36  		AbstractEntity[] entities = new AbstractEntity[1];
37  		boolean[] existingModel = new boolean[1];
38  		existingModel[0] = false;
39  		idm.setData(entities, existingModel);
40  		assertEquals("existingModel length is 1",1, idm.getExistingModel().length);
41  		assertFalse("existingModel index o value", idm.getExistingModel()[0]);
42  	}
43  	
44  	
45  	
46  	@Test
47  	public void testSetData(){		
48  		AbstractEntity[] entities = new AbstractEntity[1];
49  		boolean[] existingModel = new boolean[1];
50  		idm.setData(entities, existingModel);
51  		assertEquals("data length is 1",1, idm.getData().length);
52  				
53  		try{
54  			idm.setData(null, existingModel);
55  			fail("did not throw IllegalArgumentException");
56  		} catch (IllegalArgumentException e){
57  			assertTrue(true);
58  		}
59  		
60  		try{
61  			idm.setData(entities, null);
62  			fail("did not throw IllegalArgumentException");
63  		} catch (IllegalArgumentException e){
64  			assertTrue(true);
65  		}
66  		
67  		try{
68  			idm.setData(null, null);
69  			fail("did not throw IllegalArgumentException");
70  		} catch (IllegalArgumentException e){
71  			assertTrue(true);
72  		}
73  	}
74  	
75  	@Test
76  	public void testAddVerifyStatistic(){		
77  		idm.addVerifyStatistic(1,1);
78  		assertEquals("value is 1", 1, idm.getImportStatistics()[1][1]);
79  		try{
80  			idm.addVerifyStatistic(10, 3);
81  			fail("did not throw RuntimeException");
82  		} catch(RuntimeException e){
83  			assertTrue(true);
84  		}
85  	}
86  	
87  	@Test
88  	public void testStatsToString(){		
89  		idm.addVerifyStatistic(1,1);		
90  		assertEquals("stats string is ", 
91  				"0:[0, 0] 1:[0, 1] 2:[0, 0] 3:[0, 0] 4:[0, 0] 5:[0, 0] 6:[0, 0] ", 
92  				idm.statsToString());
93  	}
94  	
95  	
96  	@Test
97  	public void testToString(){		
98  		assertNotNull("toString", idm.toString());
99  		
100 	}
101 	
102 	
103 	@Before
104     public void setUp() throws Exception {
105 		idm = new ImportDataModel();
106     }
107 	
108 	@After
109 	public void tearDown() throws Exception {
110 		idm = null;
111 	}
112 
113 }