Question
HI I have post the same question millions of times I need to test only this one program here is my model classes that is
HI I have post the same question millions of times I need to test only this one program here is my model classes that is included for this program. Please can someone help me with correct code with no errors and give me a screenshot of the output when testing in JUNIT 4 in eclipse thank you. Please I need it to be done asap I already got the reference part I just need help with the other codes thank you.
Program needs to be test:
package medical.com.medicalApplication.services;
import java.util.ArrayList; import java.util.Collections; import java.util.List;
import medical.com.medicalApplication.model.MedicalRecord; import medical.com.medicalApplication.model.Patient; /** * * This class uses a singleton pattern to mock a service instead of using dependency injection * * In addition, it stores data in memory only using Lists * */ public class MedicalRescordService { private static MedicalRescordService reference = new MedicalRescordService(); private List
public static MedicalRescordService getReference() { return reference; }
public MedicalRescordService() { this.patients = new ArrayList
public boolean addPatient(String name, String id) { boolean patientAdded = !patients.stream() .anyMatch(patient -> patient.getId().equals(id)); if (patientAdded) { Patient newPatient = new Patient(name, id); patients.add(newPatient); medicalRecords.add(new MedicalRecord(newPatient)); } return patientAdded; } public MedicalRecord getMedicalRecord(String patientId) { return medicalRecords.stream() .filter(medicalRecord -> medicalRecord.getPatient().getId().equals(patientId)).findFirst().get(); }
public Patient getPatient(String patientId) { return patients.stream().filter(person -> person.getId().equals(patientId)) .findFirst().get(); }
public List
Models classes that was included in the project.
package medical.com.medicalApplication.model; /** * This class represent the Allergy model in the application * */ public class Allergey { private String name;
public Allergey(String name) { this.name = name; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
@Override public String toString() { return "Allergy " + name; } }
package medical.com.medicalApplication.model; /** * * This class represents the Doctor data model in the system * */ public class Doctor { private String name; private String id; public Doctor(String name, String id) { super(); this.name = name; this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getId() { return id; } public void setId(String id) { this.id = id; } @Override public String toString() { return "Doctor Name:"+ name + " ID: "+id; }
}
package medical.com.medicalApplication.model; /** * * This class represents the employee model in the system * */ public class Employee { private String name; private String id; private String password; public Employee(String name, String id) { super(); this.name = name; this.id = id; this.password = "Open"; }
public String getName() { return name; }
public String getId() { return id; }
public String getPassword() { return password; } }
package medical.com.medicalApplication.model; /** * * * This class represents a medical record model in the system * */ public class MedicalRecord {
private Patient patient; private PatientHistory history; public MedicalRecord(Patient patient) { super(); this.patient = patient; this.history = new PatientHistory(); }
public Patient getPatient() { return patient; }
public PatientHistory getHistory() { return history; } }
package medical.com.medicalApplication.model; /** * * This class represents a patient model in the system * */ public class Patient { private String name; private String id; public Patient(String name, String id) { super(); this.name = name; this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getId() { return id; }
public void setId(String id) { this.id = id; }
@Override public String toString() { return "Patient Name: "+name+ " ID: "+id; } }
package medical.com.medicalApplication.model; /** * * This class represents a treatment model in the system. * */ public class Treatment { private String treatmentDate; private String diagnose; private String description;
public Treatment(String treatmentDate, String diagnose, String description) { super(); this.treatmentDate = treatmentDate; this.diagnose = diagnose; this.description = description; }
public String getTreatmentDate() { return treatmentDate; }
public void setTreatmentDate(String treatmentDate) { this.treatmentDate = treatmentDate; }
public String getDiagnose() { return diagnose; }
public void setDiagnose(String diagnose) { this.diagnose = diagnose; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
@Override public String toString() { return "Treatment: "+ " Date: "+ treatmentDate+ " Diagnose: " + diagnose; }
}
package medical.com.medicalApplication.model; /** * * This class represents a treatment model in the system. * */ public class Treatment { private String treatmentDate; private String diagnose; private String description;
public Treatment(String treatmentDate, String diagnose, String description) { super(); this.treatmentDate = treatmentDate; this.diagnose = diagnose; this.description = description; }
public String getTreatmentDate() { return treatmentDate; }
public void setTreatmentDate(String treatmentDate) { this.treatmentDate = treatmentDate; }
public String getDiagnose() { return diagnose; }
public void setDiagnose(String diagnose) { this.diagnose = diagnose; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
@Override public String toString() { return "Treatment: "+ " Date: "+ treatmentDate+ " Diagnose: " + diagnose; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started