Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Looking for some JUnit test case examples using the below sections of code. One

ID: 3754116 • Letter: L

Question

Looking for some JUnit test case examples using the below sections of code. One per each section section please and thank you!

1. Allergy.java

package medical.com.medicalApplication.model;

/**

* This class represent the Allergy model in the application

*

*/

public class Allergy {

private String name;

public Allergy(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;

}

}

2. Doctor.java

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;

}

}

3. Employee.java

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;

}

}

4. MedicalRecord.java

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;

}

}

5. Medication.java

package medical.com.medicalApplication.model;

/**

*

* This class represents the mediation model in the system

*

*/

public class Medication {

private String name;

private String startDate;

private String endDate;

private String dose;

public Medication(String name, String startDate, String endDate, String dose) {

super();

this.name = name;

this.startDate = startDate;

this.endDate = endDate;

this.dose = dose;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getStartDate() {

return startDate;

}

public void setStartDate(String startDate) {

this.startDate = startDate;

}

public String getEndDate() {

return endDate;

}

public void setEndDate(String endDate) {

this.endDate = endDate;

}

public String getDose() {

return dose;

}

public void setDose(String dose) {

this.dose = dose;

}

@Override

public String toString() {

return "Medication:"+name + " Start Date: " + startDate + " End Date: "+endDate+ " Dose: "+dose;

}

}

6. Patient.java

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;

}

}

7. PatientHistory.java

package medical.com.medicalApplication.model;

import java.util.ArrayList;

import java.util.List;

/**

*

* This class represents a patient history model in the system

*

*/

public class PatientHistory {

private List<Treatment> treatments;

private List<Medication> medications;

private List<Allergey> allergy;

public PatientHistory() {

this.treatments = new ArrayList<Treatment>();

this.medications = new ArrayList<Medication>();

this.allergy = new ArrayList<Allergey>();

}

public void addTreatment(Treatment treatment) {

treatments.add(treatment);

}

public void addAllergy(Allergey allegry) {

allergy.add(allegry);

}

public void addMedication(Medication medication) {

if(treatments != null){

medications.add(medication);

}

}

public List<Allergey> getAlergies() {

return allergy;

}

public List<Treatment> getAllTreatments() {

return treatments;

}

public List<Medication> getAllMedications() {

return medications;

}

}

8. Treatment.java

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;

}

}

Explanation / Answer

According to the Java Classes you provide the test cases for them as follows:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote