-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniversityTests.java
84 lines (73 loc) · 1.89 KB
/
UniversityTests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package tests;
import junit.framework.TestCase;
import models.Professor;
import models.UserFactory;
import models.UserType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class UniversityTests extends TestCase {
private Professor prof;
public UniversityTests(String name) {
super(name);
}
@Before
public void setUp() {
try {
this.prof = (Professor) UserFactory.createUser(UserType.PROFESSOR);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
@Test
public void testUniversityCorrect() {
try {
this.prof.setUniversity("ASE Bucuresti");
assertEquals("ASE Bucuresti", this.prof.getUniversity());
} catch (Exception ex) {
System.out.println(ex.getMessage());
fail(ex.getMessage());
}
}
@Test
public void testUniversityWrong1() {
try {
this.prof.setUniversity(null);
assertNull(this.prof.getUniversity());
} catch (Exception ex) {
System.out.println(ex.getMessage());
assertNull(this.prof.getUniversity());
}
}
@Test(expected = AssertionError.class)
public void testUniversityWrong2() {
try {
this.prof.setUniversity("AS");
} catch (Exception ex) {
System.out.println(ex.getMessage());
assertEquals("AS", this.prof.getUniversity());
}
}
@Test(expected = AssertionError.class)
public void testUniversityWrong3() {
try {
this.prof.setUniversity("Academia de Studii Economice din Bucuresti");
} catch (Exception ex) {
System.out.println(ex.getMessage());
assertEquals("Academia de Studii Economice din Bucuresti", this.prof.getUniversity());
}
}
@Test(expected = AssertionError.class)
public void testUniversityWrong4() {
try {
this.prof.setUniversity("ASE Bucuresti 123");
} catch (Exception ex) {
System.out.println(ex.getMessage());
assertEquals("ASE Bucuresti 123", this.prof.getUniversity());
}
}
@After
public void tearDown() {
this.prof = null;
}
}