Added isModified method to Resource, Reservation.
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / dataschema / ResourceTest.java
CommitLineData
9a78ca13
MT
1/*\r
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.\r
3 *\r
4 * Project Smart Reservation System.\r
5 *\r
6 * Distributable under GPL license. See terms of license at gnu.org.\r
7 */\r
496127a5 8package ch.bfh.ti.srs.dataschema;\r
9a78ca13
MT
9\r
10import static org.junit.Assert.assertEquals;\r
912c75db 11import static org.junit.Assert.assertFalse;\r
a49c468f 12import static org.junit.Assert.assertNotEquals;\r
912c75db 13import static org.junit.Assert.assertTrue;\r
9a78ca13
MT
14\r
15import org.junit.Test;\r
16\r
17import ch.bfh.ti.srs.dataschema.Resource;\r
18\r
19public class ResourceTest {\r
20\r
21 @Test\r
22 public void createResurceTest() throws Exception {\r
23 Resource testResource = new Resource("N321", "class room");\r
a49c468f 24 assertNotEquals(null, testResource.getId());\r
9a78ca13
MT
25 assertEquals("N321", testResource.getName());\r
26 assertEquals("class room", testResource.getType());\r
27 }\r
28\r
66cc653d
D
29 @Test(expected = IllegalArgumentException.class)\r
30 public void createUserInvalidNameTest() throws Exception {\r
9a78ca13
MT
31 Resource testResource = new Resource(null, "class room");\r
32 }\r
66cc653d 33\r
9a78ca13
MT
34 @Test\r
35 public void setAndGetNameTest() throws Exception {\r
36 Resource testRessource = new Resource("N321", "class room");\r
37 testRessource.setName("N421");\r
38 assertEquals("N421", testRessource.getName());\r
39 testRessource.setName(null);\r
40 assertEquals(null, testRessource.getName());\r
41 }\r
42\r
43 @Test\r
44 public void setAndGetTypeTest() throws Exception {\r
45 Resource testRessource = new Resource("N321", "class room");\r
46 testRessource.setType("lecture hall");\r
47 assertEquals("lecture hall", testRessource.getType());\r
48 testRessource.setType(null);\r
49 assertEquals(null, testRessource.getType());\r
50 }\r
912c75db
MT
51 \r
52 @Test\r
53 public void isModifiedTest() throws Exception {\r
54 Resource testRessource = new Resource("N321", "class room");\r
55 Resource clonedTestRessource = testRessource.clone();\r
56 \r
57 assertFalse(testRessource.isModified(clonedTestRessource));\r
58 assertTrue(testRessource.isModified(null));\r
59 assertFalse(testRessource.isModified(testRessource));\r
60 clonedTestRessource.setName("N421");\r
61 assertTrue(testRessource.isModified(clonedTestRessource));\r
62 clonedTestRessource.setName("N321");\r
63 assertFalse(testRessource.isModified(clonedTestRessource));\r
64 clonedTestRessource.setType("lecture hall");\r
65 assertTrue(testRessource.isModified(clonedTestRessource));\r
66 }\r
9a78ca13 67}\r
912c75db 68\r