Merge /pub/main
[educational.data.git] / Dr.NO / src / drno / tests / EmployeeTest.java
blobdb7931d480bd4a45e2a8726f5d328b32c7bc1023
1 /*
2 * Oprettet Apr 26, 2005 af tobibobi
3 */
4 package drno.tests;
6 import drno.exception.ConsistanceException;
7 import drno.interfaces.IEmployee;
8 import drno.server.model.EmployeeImpl;
9 import junit.framework.TestCase;
11 /**
12 * @author tobibobi
14 public class EmployeeTest extends TestCase {
16 private EmployeeImpl emp;
17 /**
18 * Constructor for EmployeeTest.
19 * @param arg0
21 public EmployeeTest(String arg0) {
22 super(arg0);
23 emp = new EmployeeImpl();
26 public final void testSetEfternavn() {
27 try {
28 emp.setEfternavn("");
29 fail("zero length should throw drno.exception");
30 } catch (ConsistanceException e) {
31 // if it throws it was correct.
33 try {
34 String testval = "Hansen";
35 emp.setEfternavn(testval);
36 assertEquals(emp.getEfternavn(),testval);
37 } catch (ConsistanceException e) {
38 fail(e.toString());
42 public final void testSetFornavn() {
43 try {
44 emp.setFornavn("");
45 fail("zero length should throw drno.exception");
46 } catch (ConsistanceException e) {
47 // if it throws it was correct.
49 try {
50 String testval = "Hansen";
51 emp.setFornavn(testval);
52 assertEquals(emp.getFornavn(),testval);
53 } catch (ConsistanceException e) {
54 fail(e.toString());
58 public final void testSetLogin() {
59 try {
60 emp.setLogin("");
61 fail("zero length should throw drno.exception");
62 } catch (ConsistanceException e) {
63 // if it throws it was correct.
65 try {
66 String testval = "Hansen";
67 emp.setLogin(testval);
68 assertEquals(emp.getLogin(),testval);
69 } catch (ConsistanceException e) {
70 fail(e.toString());
74 public final void testSetPassword() {
75 try {
76 String phrase = "Alloal";
77 emp.setPassword(phrase);
78 assertFalse("The passphrase tester accepts true even if the object is in the database",emp.verify(phrase));
81 } catch(ConsistanceException e) {
82 fail(e.toString());
87 public final void testSetTelefonNummer() {
88 try {
89 emp.setTelefonNummer("1000");
90 fail("wrong format should throw drno.exception");
91 } catch (ConsistanceException e) {
92 // if it throws it was correct.
94 try {
95 String testval = "1212 12 12";
96 emp.setTelefonNummer(testval);
97 assertEquals(emp.getTelefonNummer(),testval);
98 } catch (ConsistanceException e) {
99 fail(e.toString());
103 public final void testSetTidsOpdeling() {
104 try {
105 emp.setTidsOpdeling(0);
106 fail("wrong format should throw drno.exception");
107 } catch (ConsistanceException e) {
108 // if it throws it was correct.
110 try {
111 int testval = 10;
112 emp.setTidsOpdeling(testval);
113 assertEquals(emp.getTidsOpdeling(),testval);
114 } catch (ConsistanceException e) {
115 fail(e.toString());
119 public final void testSetType() {
120 try {
121 emp.setType(1000);
122 fail("wrong format should throw drno.exception");
123 } catch (ConsistanceException e) {
124 // if it throws it was correct.
126 try {
127 int type = IEmployee.TYPE_DOCTOR;
128 emp.setType(type);
129 assertEquals(emp.getType(),type);
131 type = IEmployee.TYPE_NURSE;
132 emp.setType(type);
133 assertEquals(emp.getType(),type);
135 type = IEmployee.TYPE_SECRETARY;
136 emp.setType(type);
137 assertEquals(emp.getType(),type);
138 } catch (ConsistanceException e) {
139 fail(e.toString());
141 //TODO Implement setType().