Skip to content

Commit

Permalink
1. Updated HealthInformation class and corresponding testings
Browse files Browse the repository at this point in the history
2. Changes the 3 fields of HealthInformation from public to private, as well as all other codes that is affected by this changed.
    Added more tests in JavaClassConfirmationTests for the HealthInformation class and also changes some of the tests to fit the new version of HealthInformation
3. All tests pass and no error occurred
  • Loading branch information
xxlalfredo99 committed Aug 9, 2021
1 parent 4b32163 commit 5b396bb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
String patientName = pat.getName();
String patUID = patient.getKey();
HealthInformation patientHI = pat.getHealthInformation();
String patientGender = patientHI.gender;
String patientGender = patientHI.getGender();
String patientDOB = null;
if(patientHI.dateOfBirth != null){
if(patientHI.getDateOfBirth() != null){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
patientDOB = dateFormat.format(patientHI.dateOfBirth);
patientDOB = dateFormat.format(patientHI.getDateOfBirth());
}
int patientWeight = patientHI.weight;
int patientWeight = patientHI.getWeight();
patientInfo.setText(patientName+": ");
if (patientGender != null)
patientInfo.append("\n Gender - "+patientHI.gender);
patientInfo.append("\n Gender - "+patientHI.getGender());
if (patientDOB != null)
patientInfo.append("\n Date of Birth - "+patientDOB);
if (patientWeight > 0)
patientInfo.append("\n weight - "+patientHI.weight);
patientInfo.append("\n weight - "+patientHI.getWeight());

getPastDoctors(pat, patUID, patientInfo, layout);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class HealthInformation implements Serializable {
* @param weight an int storing the weight of the patient in pounds
* @param gender a string storing the gender of the patient - either "Male" or "Female"
*/
public Date dateOfBirth;
public int weight;
public String gender;
private Date dateOfBirth;
private int weight;
private String gender;

public HealthInformation(){}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
if(patientProfile != null){
String name = patientProfile.name;
String email = patientProfile.email;
Date DOB = patientProfile.getHealthInformation().dateOfBirth;
int weight = patientProfile.getHealthInformation().weight;
String gender = patientProfile.getHealthInformation().gender;
Date DOB = patientProfile.getHealthInformation().getDateOfBirth();
int weight = patientProfile.getHealthInformation().getWeight();
String gender = patientProfile.getHealthInformation().getGender();

welcome.setText("Welcome " + name + "!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public void testPatientEmptyConstructor(){
@Test
public void testHealthInformationEmptyConstructor(){
HealthInformation healthInformation = new HealthInformation();
assertEquals(healthInformation.gender, null);
assertEquals(healthInformation.getGender(), null);
}

@Test
public void testPatientGetInfo(){
// when(patView.navigateToPatientSignup()).getMock();
Patient pat = new Patient("Patient1");
HealthInformation healthInformation = new HealthInformation(10,100,"Female");
HealthInformation healthInformation = new HealthInformation(new Date(100, 1 , 1),100,"Female");
pat.setHealthInformation(healthInformation);

// ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
Expand All @@ -52,31 +52,31 @@ public void testPatientGetInfo(){

@Test
public void testPatientToString(){
HealthInformation healthInformation = new HealthInformation(10,100,"Female");
HealthInformation healthInformation = new HealthInformation(new Date(100, 1 , 1),100,"Female");
Patient pat = new Patient("Patient1", "[email protected]", "password1", healthInformation);

assertEquals(pat.toString(), "{Patient name: Patient1}");
}

@Test
public void testPersonSetGetName(){
HealthInformation healthInformation = new HealthInformation(10,100,"Female");
HealthInformation healthInformation = new HealthInformation(new Date(100, 1 , 1),100,"Female");
Patient pat = new Patient("P1", "[email protected]", "password1", healthInformation);
pat.setName("Kevin");
assertEquals(pat.getName(), "Kevin");
}

@Test
public void testPersonSetGetEmail(){
HealthInformation healthInformation = new HealthInformation(10,100,"Female");
HealthInformation healthInformation = new HealthInformation(new Date(100, 1 , 1),100,"Female");
Patient pat = new Patient("P1", "[email protected]", "password1", healthInformation);
pat.setEmail("[email protected]");
assertEquals(pat.getEmail(), "[email protected]");
}

@Test
public void testPersonSetGetPassword(){
HealthInformation healthInformation = new HealthInformation(10,100,"Female");
HealthInformation healthInformation = new HealthInformation(new Date(100, 1 , 1),100,"Female");
Patient pat = new Patient("P1", "[email protected]", "password1", healthInformation);
pat.setPassword("dragonSlayer99");
assertEquals(pat.getPassword(), "dragonSlayer99");
Expand Down Expand Up @@ -173,5 +173,25 @@ public void testAppointmentSetGetDate(){
apt.setStartTime(newStart);
assertEquals(apt.getStartTime(), newStart);
}
@Test
public void testHealthInformationSetGetDate(){
Date birth = new Date(100, 1 , 1);
HealthInformation healthInformation = new HealthInformation(birth,100,"Female");
assertEquals(healthInformation.getDateOfBirth(), birth);
}

@Test
public void testHealthInformationSetGetGender(){
Date birth = new Date(100, 1 , 1);
HealthInformation healthInformation = new HealthInformation(birth,100,"Female");
assertEquals(healthInformation.getGender(), "Female");
}

@Test
public void testHealthInformationSetGetWeight(){
Date birth = new Date(100, 1 , 1);
HealthInformation healthInformation = new HealthInformation(birth,100,"Female");
assertEquals(healthInformation.getWeight(), 100);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,6 @@ public class MockitoPresenterTests {
// @Mock
// private String userID;

@Test
public void testPatientGetInfo(){
// when(patView.navigateToPatientSignup()).getMock();
Patient pat = new Patient("Patient1");
HealthInformation healthInformation = new HealthInformation(10,100,"Female");
pat.setHealthInformation(healthInformation);

// ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);

HealthInformation retreiveInfo = pat.getHealthInformation();
// verify(pat).
assertEquals(retreiveInfo, healthInformation);
}


@Test
public void testingGeneral(){
Expand Down

0 comments on commit 5b396bb

Please sign in to comment.