Guest User

EventTest

a guest
Jun 16th, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.15 KB | None | 0 0
  1. package lapr.project.model;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import lapr.project.utils.Date;
  6. import org.junit.After;
  7. import org.junit.AfterClass;
  8.  
  9. import org.junit.Test;
  10. import static org.junit.Assert.*;
  11. import org.junit.Before;
  12. import org.junit.BeforeClass;
  13. import org.junit.Rule;
  14. import org.junit.rules.ExpectedException;
  15.  
  16. public class EventTest
  17. {
  18.  
  19. private EventCenter ec;
  20. User u1 = new User("Rui", "tostaman", "rui@gmail.com", "teste");
  21. User u2 = new User("Pedro", "tostapedro", "pedro@gmail.com", "teste");
  22. User u3 = new User("Filipe", "Felipe", "felipe@gmail.com", "teste");
  23. User u4 = new User("David", "DABIDE", "david@gmail.com", "teste");
  24. User u5 = new User("Ricardo", "Ric", "ricardo@gmail.com", "teste");
  25. User u6 = new User("Rui", "RuiB", "barbosa@gmail.com", "teste");
  26. List<Organiser> ol = new ArrayList<>();
  27. Organiser o1 = new Organiser(u2);
  28. Organiser o2 = new Organiser(u3);
  29. List<Keyword> k = new ArrayList<>();
  30. FuncionarioApoioEvento f = new FuncionarioApoioEvento(u4);
  31. FuncionarioApoioEventoRegister fr = new FuncionarioApoioEventoRegister();
  32. ParticipantRepresentant pr = new ParticipantRepresentant(u6);
  33. EventManager ev = new EventManager(u1);
  34. Date sDate = new Date(2017, 01, 01);
  35. Date eDate = new Date(2017, 01, 02);
  36. Assignment assign = new Assignment(f);
  37. Assignment assign1 = new Assignment(f);
  38. Event e = new Event("Default Title", "Default Descriptive Text", sDate, eDate, "Default Place", ol, fr, ev);
  39.  
  40. Application candidatura = new Application("MyCandidatura", "description", k, 20, 20,pr);
  41. Application a1 = new Application("Teste","testeDescription",k,30,30,pr);
  42. public EventTest()
  43. {
  44. }
  45.  
  46. @BeforeClass
  47. public static void setUpClass() throws Exception
  48. {
  49. }
  50.  
  51. @AfterClass
  52. public static void tearDownClass() throws Exception
  53. {
  54. }
  55.  
  56. @Before
  57. public void setUp() throws Exception
  58. {
  59. }
  60.  
  61. @After
  62. public void tearDown() throws Exception
  63. {
  64. }
  65. @Rule
  66. public ExpectedException thrown = ExpectedException.none();
  67.  
  68. /**
  69. * Test of GetApplicationListOfUser of the class event
  70. */
  71. @Test
  72. public void testeGetApplicationListOfUser(){
  73.  
  74. System.out.println("getApplicationListOfUser");
  75.  
  76. thrown.expect(Exception.class);
  77. thrown.expectMessage("The user is not a FAE in any event");
  78.  
  79. candidatura.addAssignment(assign);
  80. e.addApplication(candidatura);
  81. List<Application> expResult = new ArrayList<>();
  82. expResult.add(candidatura);
  83. assertEquals(expResult, e.getApplicationListOfUser(u4));
  84. a1.addAssignment(assign1);
  85. e.addApplication(a1);
  86. List<Application> result1 = e.getApplicationListOfUser(u5);
  87. assertEquals(thrown, result1);
  88. }
  89.  
  90. /**
  91. * Test of getTitle method, of class Event.
  92. */
  93. @org.junit.Test
  94. public void testGetTitle()
  95. {
  96. System.out.println("getTitle");
  97. String expResult = "Default Title";
  98. String result = e.getTitle();
  99. assertEquals(expResult, result);
  100.  
  101. }
  102.  
  103. /**
  104. * Test of getDescriptiveText method, of class Event.
  105. */
  106. @org.junit.Test
  107. public void testGetDescriptiveText()
  108. {
  109. System.out.println("getDescriptiveText");
  110. String expResult = "Default Descriptive Text";
  111. String result = e.getDescriptiveText();
  112. assertEquals(expResult, result);
  113. }
  114.  
  115. /**
  116. * Test of getPlace method, of class Event.
  117. */
  118. @org.junit.Test
  119. public void testGetPlace()
  120. {
  121. System.out.println("getPlace");
  122. String expResult = "Default Place";
  123. String result = e.getPlace();
  124. assertEquals(expResult, result);
  125.  
  126. }
  127.  
  128. /**
  129. * Test of getOragnisersList method, of class Event.
  130. */
  131. @org.junit.Test
  132. public void testGetOragnisersList()
  133. {
  134. System.out.println("getOrganisersList");
  135. Organiser o1 = new Organiser(u2);
  136. Organiser o2 = new Organiser(u3);
  137. ol.add(o2);
  138. ol.add(o1);
  139. e.addOrganiser(o1);
  140. e.addOrganiser(o2);
  141. List<Organiser> expResult = ol;
  142. List<Organiser> result = e.getOrganisersList();
  143. assertEquals(expResult, result);
  144.  
  145. }
  146.  
  147. /**
  148. * Test of getApplicationList method, of class Event.
  149. */
  150. @org.junit.Test
  151. public void testGetApplicationList()
  152. {
  153. System.out.println("getApplicationList");
  154. ApplicationList expResult = e.getApplicationList();
  155. assertEquals(expResult, e.getApplicationList());
  156.  
  157. }
  158.  
  159. /**
  160. * Test of setTitle method, of class Event.
  161. */
  162. @org.junit.Test
  163. public void testSetTitle()
  164. {
  165. System.out.println("setTitle");
  166. String title = "Default Title";
  167. e.setTitle(title);
  168.  
  169. }
  170.  
  171. /**
  172. * Test of setDescriptiveText method, of class Event.
  173. */
  174. @org.junit.Test
  175. public void testSetDescriptiveText()
  176. {
  177. System.out.println("setDescriptiveText");
  178. String descriptiveText = "Default Descriptive Text";
  179. e.setDescriptiveText(descriptiveText);
  180.  
  181. }
  182.  
  183. /**
  184. * Test of setPlace method, of class Event.
  185. */
  186. @org.junit.Test
  187. public void testSetPlace()
  188. {
  189. System.out.println("setPlace");
  190. String place = "Default Place";
  191. e.setPlace(place);
  192.  
  193. }
  194.  
  195. /**
  196. * Test of addOrganiser method, of class Event.
  197. */
  198. @org.junit.Test
  199. public void testAddOrganiser()
  200. {
  201. System.out.println("addOrganiser");
  202. Organiser o = new Organiser();
  203. boolean expResult = true;
  204. boolean result = e.addOrganiser(o);
  205. assertEquals(expResult, result);
  206.  
  207. }
  208.  
  209. /**
  210. * Test of addApplication method, of class Event.
  211. */
  212. @org.junit.Test
  213. public void testAddApplication()
  214. {
  215. System.out.println("addApplication");
  216. Application a = new Application();
  217. boolean expResult = true;
  218. boolean result = e.addApplication(a);
  219. assertEquals(expResult, result);
  220.  
  221. }
  222.  
  223. /**
  224. * Test of getAcceptedApplicationList method, of class Event.
  225. */
  226. @Test
  227. public void testGetAcceptedApplicationList()
  228. {
  229. System.out.println("getAcceptedApplicationList");
  230.  
  231. List<Application> expResult = new ArrayList<Application>();
  232. List<Application> result = e.getAcceptedApplicationList();
  233. assertEquals(expResult, result);
  234.  
  235. candidatura.setAccepted(true);
  236. e.addApplication(candidatura);
  237. List<Application> expResult1 = new ArrayList<Application>();
  238. expResult1.add(candidatura);
  239. List<Application> result1 = e.getAcceptedApplicationList();
  240. assertEquals(expResult1, result1);
  241.  
  242. }
  243.  
  244. /**
  245. * Test of registerApplication method, of class Event.
  246. */
  247. @Test
  248. public void testRegisterApplication()
  249. {
  250. System.out.println("registerApplication");
  251. Application a = new Application("MyCandidatura23", "description23", k, 201, 230,pr);
  252.  
  253. boolean expResult = true;
  254. boolean result = e.registerApplication(a);
  255. assertEquals(expResult,result);
  256. e.addApplication(candidatura);
  257. boolean expResult1 = false;
  258. boolean result1 = e.registerApplication(candidatura);
  259. assertEquals(expResult1,result1);
  260. }
  261.  
  262. /**
  263. * Test of getEventManager method, of class Event.
  264. */
  265. @Test
  266. public void testGetEventManager()
  267. {
  268. System.out.println("getEventManager");
  269. Event instance = e;
  270. EventManager expResult = ev;
  271. EventManager result = instance.getEventManager();
  272. assertEquals(expResult, result);
  273.  
  274. }
  275.  
  276. /**
  277. * Test of getFaeList method, of class Event.
  278. */
  279. @Test
  280. public void testGetFaeList()
  281. {
  282. System.out.println("getFaeList");
  283. Event instance = e;
  284. FuncionarioApoioEventoRegister expResult = fr;
  285. FuncionarioApoioEventoRegister result = instance.getFaeList();
  286. assertEquals(expResult, result);
  287. }
  288.  
  289. /**
  290. * Test of getStartDate method, of class Event.
  291. */
  292. @Test
  293. public void testGetStartDate()
  294. {
  295. System.out.println("getStartDate");
  296. Event instance = e;
  297. Date expResult = sDate;
  298. Date result = instance.getStartDate();
  299. assertEquals(expResult, result);
  300. }
  301.  
  302. /**
  303. * Test of getEndDate method, of class Event.
  304. */
  305. @Test
  306. public void testGetEndDate()
  307. {
  308. System.out.println("getEndDate");
  309. Event instance = e;
  310. Date expResult = eDate;
  311. Date result = instance.getEndDate();
  312. assertEquals(expResult, result);
  313. }
  314.  
  315. /**
  316. * Test of addFAE method, of class Event.
  317. */
  318. @Test
  319. public void testAddFAE()
  320. {
  321. System.out.println("addFAE");
  322. FuncionarioApoioEvento f = new FuncionarioApoioEvento(u1);
  323. boolean expResult = true;
  324. boolean result = e.addFAE(f);
  325. assertEquals(expResult, result);
  326. }
  327.  
  328. /**
  329. * Test of setStartDate method, of class Event.
  330. */
  331. @Test
  332. public void testSetStartDate()
  333. {
  334. System.out.println("setStartDate");
  335. Date startDate = sDate;
  336. Event instance = e;
  337. instance.setStartDate(startDate);
  338. Date expDate = sDate;
  339. assertEquals(expDate, instance.getStartDate());
  340. }
  341.  
  342. /**
  343. * Test of setEndDate method, of class Event.
  344. */
  345. @Test
  346. public void testSetEndDate()
  347. {
  348. System.out.println("setEndDate");
  349. Date endDate = eDate;
  350. Event instance = e;
  351. instance.setEndDate(endDate);
  352. Date expDate = eDate;
  353. assertEquals(expDate, instance.getEndDate());
  354. }
  355.  
  356. /**
  357. * Test of equals method, of class Event.
  358. */
  359. @Test
  360. public void testEquals()
  361. {
  362. System.out.println("equals");
  363. List<Organiser> ol1 = new ArrayList<>();
  364. ol1.add(o1);
  365. List<Keyword> k1 = new ArrayList<>();
  366. Keyword k = new Keyword("test");
  367. k1.add(k);
  368. FuncionarioApoioEventoRegister fr1 = new FuncionarioApoioEventoRegister();
  369. fr1.addFAE(f);
  370. EventManager ev1 = new EventManager(u2);
  371. Date sDate1 = new Date(2017, 02, 02);
  372. Date eDate1 = new Date(2017, 02, 03);
  373. Event e1 = new Event("Default Title1", "Default Descriptive Text", sDate, eDate, "Default Place", ol, fr, ev);
  374. Event e2= new Event("Default Title", "Default Descriptive Text1", sDate, eDate, "Default Place", ol, fr, ev);
  375. Event e3= new Event("Default Title", "Default Descriptive Text", sDate1, eDate, "Default Place", ol, fr, ev);
  376. Event e4= new Event("Default Title", "Default Descriptive Text", sDate, eDate1, "Default Place", ol, fr, ev);
  377. Event e5= new Event("Default Title", "Default Descriptive Text", sDate, eDate, "Default Place1", ol, fr, ev);
  378. Event e6= new Event("Default Title", "Default Descriptive Text", sDate, eDate, "Default Place", ol1, fr, ev);
  379. Event e7= new Event("Default Title", "Default Descriptive Text", sDate, eDate, "Default Place", ol, fr1, ev);
  380. Event e8= new Event("Default Title", "Default Descriptive Text", sDate, eDate, "Default Place", ol, fr, ev1);
  381. Event e9= new Event("Default Title", "Default Descriptive Text", sDate, eDate, "Default Place", ol, fr, ev);
  382. Event e10= new Event("Default Title", "Default Descriptive Text", sDate, eDate, "Default Place", ol, fr, ev);
  383.  
  384.  
  385. Object obj = null;
  386. boolean expResult = false;
  387. boolean result = e.equals(obj);
  388. assertEquals(expResult, result);
  389. boolean expResult1 = false;
  390. boolean result1 = e.equals(u1);
  391. assertEquals(expResult1, result1);
  392. boolean expResult2 = false;
  393. boolean result2 = e.equals(e1);
  394. assertEquals(expResult2, result2);
  395. boolean expResult3 = false;
  396. boolean result3 = e.equals(e2);
  397. assertEquals(expResult3, result3);
  398. boolean expResult4 = false;
  399. boolean result4 = e.equals(e3);
  400. assertEquals(expResult4, result4);
  401. boolean expResult5 = false;
  402. boolean result5 = e.equals(e4);
  403. assertEquals(expResult5, result5);
  404. boolean expResult6 = false;
  405. boolean result6 = e.equals(e5);
  406. assertEquals(expResult6, result6);
  407. boolean expResult7 = false;
  408. boolean result7 = e.equals(e6);
  409. assertEquals(expResult7, result7);
  410. boolean expResult8 = false;
  411. boolean result8 = e.equals(e7);
  412. assertEquals(expResult8, result8);
  413. boolean expResult9 = false;
  414. boolean result9 = e.equals(e8);
  415. assertEquals(expResult9, result9);
  416. boolean expResult10 = true;
  417. boolean result10 = e10.equals(e9);
  418. assertEquals(expResult10, result10);
  419. }
  420.  
  421.  
  422. /**
  423. * Test of getOrganisersList method, of class Event.
  424. */
  425. @Test
  426. public void testGetOrganisersList()
  427. {
  428. System.out.println("getOrganisersList");
  429. e.addOrganiser(o1);
  430. List<Organiser> expResult = new ArrayList<>();
  431. expResult.add(o1);
  432. List<Organiser> result = e.getOrganisersList();
  433. assertEquals(expResult, result);
  434.  
  435. }
  436.  
  437. /**
  438. * Test of getTotalKeywordList method, of class Event.
  439. */
  440. @Test
  441. public void testGetTotalKeywordList()
  442. {
  443. System.out.println("getTotalKeywordList");
  444. Keyword key1 = new Keyword("keyword");
  445. candidatura.addKeyword(key1);
  446. e.addApplication(candidatura);
  447. List<Keyword> expResult = new ArrayList<>();
  448. expResult.add(key1);
  449. List<Keyword> result = e.getTotalKeywordList();
  450. assertEquals(expResult, result);
  451. }
  452.  
  453. /**
  454. * Test of setEventManager method, of class Event.
  455. */
  456. @Test
  457. public void testSetEventManager()
  458. {
  459. System.out.println("setEventManager");
  460. EventManager ev = null;
  461. Event instance = new Event();
  462. instance.setEventManager(ev);
  463. }
  464.  
  465. /**
  466. * Test of setOrganiserList method, of class Event.
  467. */
  468. @Test
  469. public void testSetOrganiserList()
  470. {
  471. System.out.println("setOrganiserList");
  472. List<Organiser> ol = null;
  473. Event instance = new Event();
  474. instance.setOrganiserList(ol);
  475. }
  476.  
  477. /**
  478. * Test of setFAEList method, of class Event.
  479. */
  480. @Test
  481. public void testSetFAEList()
  482. {
  483. System.out.println("setFAEList");
  484. FuncionarioApoioEventoRegister fl = null;
  485. Event instance = new Event();
  486. instance.setFAEList(fl);
  487. }
  488.  
  489. /**
  490. * Test of addKeywords method, of class Event.
  491. */
  492. @Test
  493. public void testAddKeywords()
  494. {
  495. System.out.println("addKeywords");
  496. e.addKeywords();
  497. }
  498.  
  499. /**
  500. * Test of hashCode method, of class Event.
  501. */
  502. @Test
  503. public void testHashCode()
  504. {
  505. System.out.println("hashCode");
  506. Event ev1 = new Event();
  507. Event ev2 = new Event();
  508. int expResult = ev1.hashCode();
  509. int result = ev2.hashCode();
  510. assertEquals(expResult, result);
  511. }
  512.  
  513.  
  514.  
  515. }
Add Comment
Please, Sign In to add comment