Question: APPOINTMENT JAVA import java.util.Date; public class Appointment { private String appointmentId; private Date appointmentDate; private String description; public Appointment ( String appointmentId, Date appointmentDate, String

APPOINTMENT JAVA
import java.util.Date;
public class Appointment {
private String appointmentId;
private Date appointmentDate;
private String description;
public Appointment(String appointmentId, Date appointmentDate, String description){
this.appointmentId = appointmentId;
this.appointmentDate = appointmentDate;
this.description = description;
}
// Getters and setters
public String getAppointmentId(){
return appointmentId;
}
public Date getAppointmentDate(){
return appointmentDate;
}
public String getDescription(){
return description;
}
}
APPOINTMENT SERVICE JAVA
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class AppointmentService {
private Map appointments = new HashMap<>();
public void addAppointment(Appointment appointment){
appointments.put(appointment.getAppointmentId(), appointment);
}
public void deleteAppointment(String appointmentId){
appointments.remove(appointmentId);
}
public void updateAppointment(Appointment updatedAppointment){
appointments.put(updatedAppointment.getAppointmentId(), updatedAppointment);
}
public Appointment getAppointmentById(String appointmentId){
return appointments.get(appointmentId);
}
}
APPOINTMENT SERVICE TEST JAVA
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import java.util.Date;
public class AppointmentServiceTest {
@Test
public void testAddAppointment(){
AppointmentService appointmentService = new AppointmentService();
Date currentDate = new Date();
Appointment appointment = new Appointment("A1", currentDate, "Meeting with client");
appointmentService.addAppointment(appointment);
assertNotNull(appointmentService.getAppointmentById("A1"));
}
}
APPOINTMENT TEST JAVA
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import java.util.Date;
public class AppointmentTest {
@Test
public void testAppointmentCreation(){
Date currentDate = new Date();
Appointment appointment = new Appointment("A1", currentDate, "Meeting with client");
assertEquals("A1", appointment.getAppointmentId());
assertEquals(currentDate, appointment.getAppointmentDate());
assertEquals("Meeting with client", appointment.getDescription());
}
}
------------------------------------------------
I need to redo them with the following corrections.
The appointment object shall have a required unique appointment ID string that cannot be longer than 10 characters. The appointment ID shall not be null and shall not be updatable.
I need to see a null test, test for an id =10 chars and >10 char and <10 char
The appointment object shall have a required appointment Date field. The appointment Date field cannot be in the past. The appointment Date field shall not be null.
Note: Use java.util.Date for the appointmentDate field and use before(new Date()) to check if the date is in the past.
I need to see a test for a date in the past
The appointment object shall have a required description String field that cannot be longer than 50 characters. The description field shall not be null.
I need to see a null test, test for description =50 chars, >50 chars, <50 chars
The appointment service shall be able to delete appointments per appointment ID.o redo them with the following corrections.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!