-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDVDServiceTest.java
More file actions
135 lines (118 loc) · 3.52 KB
/
DVDServiceTest.java
File metadata and controls
135 lines (118 loc) · 3.52 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DVD.service;
import DVD.dao.AuditDao;
import DVD.dao.DVDAuditDaoStubImpl;
import DVD.dao.DVDDao;
import DVD.dao.DVDDaoStubImpl;
import DVD.dto.DVD;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* @author Kelsey
*/
public class DVDServiceTest {
DVDService service;
public DVDServiceTest() {
AuditDao audit = new DVDAuditDaoStubImpl();
DVDDao dao = new DVDDaoStubImpl();
service = new DVDSericeFileImpl(dao, audit);
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of createDVD method, of class DVDService.
*/
@Test
public void testCreateDVD() throws Exception {
DVD newDvd = new DVD("Troy");
newDvd.setReleaseDate("2009");
newDvd.setDirectorName("Jane");
newDvd.setMpaaRating("A");
newDvd.setStudio("Disney");
newDvd.setUserRating("Awesome");
service.createDVD(newDvd);
}
@Test
public void testduplicateTitle() throws Exception {
DVD newDvd1 = new DVD("Game");
newDvd1.setReleaseDate("2007");
newDvd1.setDirectorName("Jan");
newDvd1.setMpaaRating("A");
newDvd1.setStudio("Disney");
newDvd1.setUserRating("Awesome");
try {
service.createDVD(newDvd1);
fail("Exception not thrown");
} catch (DVDServiceDuplicateIdException e) {
}
}
@Test
public void testdataValidation() throws Exception {
DVD newDvd1 = new DVD("Thor");
newDvd1.setMpaaRating("A");
newDvd1.setReleaseDate("");
newDvd1.setDirectorName("Jan");
newDvd1.setStudio("Disney");
newDvd1.setUserRating("Awesome");
try {
service.createDVD(newDvd1);
fail("Exception not thrown");
} catch (DVDServiceDataValidationException e) {
}
}
/**
* Test of getAllDvds method, of class DVDService.
*/
@Test
public void testGetAllDvds() throws Exception {
assertEquals(1,service.getAllDvds().size());
}
/**
* Test of getDVD method, of class DVDService.
*/
@Test
public void testGetDVD() throws Exception {
DVD dvd=service.getDVD("Thor");
assertNotNull(dvd);
dvd=service.getDVD("June");
assertNull(dvd);
}
/**
* Test of removeVD method, of class DVDService.
*/
@Test
public void testRemoveVD() throws Exception {
DVD dvd=service.removeVD("Thor");
assertNotNull(dvd);
dvd=service.removeVD("June");
assertNull(dvd);
}
/**
* Test of editDVD method, of class DVDService.
*/
@Test
public void testEditDVD() throws Exception {
}
}