Question: Hi I need help with this program I need to test this programming using JUnit 4 testing in eclipse and I need to test all

Hi I need help with this program I need to test this programming using JUnit 4 testing in eclipse and I need to test all requirements can someone please help me thank you. Also, make sure to add the @Before statement to the testing file thank you. Also, provide me a screenshot of the output when it is running thank you. Please can someone please help me I really need it to be done fast thank you. PLEASE HELP ME ON THIS I NEED IT FAST. THANK YOU

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 patients; private List medicalRecords;

public static MedicalRescordService getReference() { return reference; }

MedicalRescordService() { this.patients = new ArrayList(); this.medicalRecords = 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 getAllPatients() { return patients; } public List getPatientsWithAllergies(String allergyName){ for(Patient patient : getAllPatients()){ if(getMedicalRecord(patient.getId()).getHistory().getAlergies().stream().filter(allergy -> allergy.getName().equals(allergyName)).findFirst().get() != null){ return Collections.singletonList(patient); } } return Collections.emptyList(); } }

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 Databases Questions!