This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppointmentServiceTest.java
71 lines (60 loc) · 1.71 KB
/
AppointmentServiceTest.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
package test;
import static org.junit.jupiter.api.Assertions.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import services.Appointment;
import services.AppointmentService;
/**
*
* @author Eric Slutz
*
* SNHU CS-320
* Module 5 Milestone
*
*/
class AppointmentServiceTest {
private AppointmentService testApptService;
private Date testApptDate;
/**
* Setup of AppointmentService for use with the tests.
*/
@BeforeEach
void setUp() {
try {
testApptDate = new SimpleDateFormat("yyyy-MM-dd").parse("2024-01-01");
} catch (ParseException ex) {
System.out.println(ex.getMessage());
}
testApptService = new AppointmentService();
testApptService.addAppointment(new Appointment("1", testApptDate, "description1"));
testApptService.addAppointment(new Appointment("2", testApptDate, "description2"));
}
@Test
void testAddAppointment() {
assertAll(
() -> assertTrue(testApptService.addAppointment(new Appointment("3", testApptDate, "description3"))),
() -> assertTrue(testApptService.getAppointments().size() == 3)
);
}
@Test
void testAddAppointmentThatAlreadyExists() {
assertFalse(testApptService.addAppointment(new Appointment("2", testApptDate, "description2")));
}
@Test
void testDeleteAppointmentWithValidId() {
assertAll(
() -> assertTrue(testApptService.deleteAppointment("2")),
() -> assertTrue(testApptService.getAppointments().size() == 1)
);
}
@Test
void testDeleteAppointmentWithInvalidId() {
assertAll(
() -> assertFalse(testApptService.deleteAppointment("5")),
() -> assertTrue(testApptService.getAppointments().size() == 2)
);
}
}