Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am looking for some help creating some examples of JUnit tests. Using the below sections of code I am looking for 5 different JUnit

I am looking for some help creating some examples of JUnit tests. Using the below sections of code I am looking for 5 different JUnit test examples, and just a brief (sentence or 2) description of what is being tested.

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.prompts;

import java.util.Arrays;

import java.util.List;

import java.util.Scanner;

import medical.com.medicalApplication.model.Allergey;

import medical.com.medicalApplication.model.MedicalRecord;

import medical.com.medicalApplication.model.Medication;

import medical.com.medicalApplication.model.Patient;

import medical.com.medicalApplication.model.Treatment;

import medical.com.medicalApplication.services.MedicalRescordService;

/**

*

* This class creates the prompts for the medical application

*

*/

public class MedicalRecordPrompt {

private static List prompt = Arrays.asList("","Medical Record Menu", "1 Add a Treatment", "2 Add a Medication",

"3 Print Patient's Treatments", "4 Print Patient's Medications", "5 Add Allergy", "6 Print Allergies", "0 Main Menu");

public void mainPrompt(Scanner scanner) {

int input = -1;

System.out.println("Enter Patient ID:");

String patientId = scanner.next();

Patient patient = MedicalRescordService.getReference().getPatient(patientId);

if (patient != null) {

while (input != 0) {

System.out.println("Patient: " + patient.getName());

prompt.stream().forEach(System.out::println);

input = scanner.nextInt();

switch (input) {

case 1:

addTreatment(scanner, patient.getId());

break;

case 2:

addMedication(scanner, patient.getId());

break;

case 3:

MedicalRescordService.getReference().getMedicalRecord(patientId).getHistory().getAllTreatments()

.forEach(System.out::println);

break;

case 4:

MedicalRescordService.getReference().getMedicalRecord(patientId).getHistory().getAllMedications()

.forEach(System.out::println);

break;

case 5:

addAllergy(scanner, patient.getId());

break;

case 6:

MedicalRescordService.getReference().getMedicalRecord(patientId).getHistory().getAlergies()

.forEach(System.out::println);

break;

case 0:

break;

default:

break;

}

}

} else {

System.out.println("Patient with that ID could not be found");

}

}

private void addAllergy(Scanner scanner, String patientId) {

int input = -1;

while (input != 0) {

System.out.println("Enter Allergy:");

String allergyName = scanner.next();

Allergey allergy = new Allergey(allergyName);

MedicalRecord medicalRecord = MedicalRescordService.getReference().getMedicalRecord(patientId);

if (medicalRecord != null) {

medicalRecord.getHistory().addAllergy(allergy);

} else {

System.err.println("Error! Medical Record is null");

}

System.out.println(

"Would you like to add another Allergy? 1 for Yes 0 To return to the Medical Record Menu");

input = scanner.nextInt();

}

}

public void addTreatment(Scanner scanner, String patientId) {

int input = -1;

while (input != 0) {

System.out.println("Enter the treatment date:");

String treatmentDate = scanner.next();

System.out.println("Enter diagnose:");

String diagnose = scanner.next();

System.out.println("Enter description:");

String description = scanner.next();

Treatment treatment = new Treatment(treatmentDate, diagnose, description);

MedicalRecord medicalRecord = MedicalRescordService.getReference().getMedicalRecord(patientId);

if (medicalRecord != null) {

medicalRecord.getHistory().addTreatment(treatment);

} else {

System.err.println("Error! Medical Record is null");

}

System.out.println(

"Would you like to add another Treatment? 1 for Yes 0 To return to the Medical Record Menu");

input = scanner.nextInt();

}

}

public List findAllPatientsWithAllergy(Scanner scanner){

System.out.println("Enter Allergy:");

String allergy = scanner.next();

return MedicalRescordService.getReference().getPatientsWithAllergies(allergy);

}

public void addMedication(Scanner scanner, String patientId) {

int input = -1;

while (input != 0) {

System.out.println("Enter medication name:");

String name = scanner.next();

System.out.println("Enter startDate:");

String startDate = scanner.next();

System.out.println("Enter endDate:");

String endDate = scanner.next();

System.out.println("Enter dose:");

String dose = scanner.next();

Medication medication = new Medication(name, startDate, endDate, dose);

MedicalRecord medicalRecord = MedicalRescordService.getReference().getMedicalRecord(patientId);

if (medicalRecord != null) {

medicalRecord.getHistory().addMedication(medication);

} else {

System.err.println("Error! Medical Record is null");

}

System.out.println(

"Would you like to add another Medication? 1 for Yes 0 To return to the Medical Record Menu");

input = scanner.nextInt();

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago

Question

=+j Explain the litigation risks in international labor relations.

Answered: 1 week ago

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago