-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added more test for patientService and patientTypeService #1301
base: develop
Are you sure you want to change the base?
Changes from all commits
a218619
44e2afe
0df93aa
9b44bf1
9d2cceb
4bf47c2
6d53ef7
b55b350
3133fe4
9ce03f9
503e1cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,6 @@ public void init() throws Exception { | |
patientService.deleteAll(patientService.getAll()); | ||
personService.deleteAll(personService.getAll()); | ||
patientTypeService.deleteAll(patientTypeService.getAll()); | ||
|
||
} | ||
|
||
@After | ||
|
@@ -62,41 +61,6 @@ public void tearDown() { | |
patientTypeService.deleteAll(patientTypeService.getAll()); | ||
} | ||
|
||
@Test | ||
public void createPatient_shouldCreateNewPatient() throws Exception { | ||
String firstName = "John"; | ||
String lastname = "Doe"; | ||
String dob = "12/12/1992"; | ||
String gender = "M"; | ||
Patient pat = createPatient(firstName, lastname, dob, gender); | ||
|
||
Assert.assertEquals(0, patientService.getAllPatients().size()); | ||
|
||
String patientId = patientService.insert(pat); | ||
Patient savedPatient = patientService.get(patientId); | ||
|
||
Assert.assertEquals(1, patientService.getAllPatients().size()); | ||
Assert.assertEquals(firstName, savedPatient.getPerson().getFirstName()); | ||
Assert.assertEquals(lastname, savedPatient.getPerson().getLastName()); | ||
Assert.assertEquals(gender, savedPatient.getGender()); | ||
} | ||
|
||
@Test | ||
public void getData_shouldCopyPropertiesFromDatabase() throws Exception { | ||
String firstName = "John"; | ||
String lastname = "Doe"; | ||
String dob = "12/12/1992"; | ||
String gender = "M"; | ||
Patient patient = createPatient(firstName, lastname, dob, gender); | ||
String patientId = patientService.insert(patient); | ||
|
||
Patient savedPatient = new Patient(); | ||
savedPatient.setId(patientId); | ||
patientService.getData(savedPatient); | ||
|
||
Assert.assertEquals(gender, savedPatient.getGender()); | ||
} | ||
|
||
@Test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @josephbate , why did you have to delete the existing tests ?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my local repository got corrupted and i didn't noticed it till when i pushed it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry was on a different branch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you never got rid of the chanes here |
||
public void getSubjectNumber_shouldReturnSubjectNumber() throws Exception { | ||
String firstName = "John"; | ||
|
@@ -504,6 +468,25 @@ public void getPatientForGuid_shouldReturnPatientForGuid() throws Exception { | |
Assert.assertEquals(gender, savedPatient.getGender()); | ||
} | ||
|
||
@Test | ||
public void createPatient_shouldCreateNewPatient() throws Exception { | ||
String firstName = "John"; | ||
String lastname = "Doe"; | ||
String dob = "12/12/1992"; | ||
String gender = "M"; | ||
Patient pat = createPatient(firstName, lastname, dob, gender); | ||
|
||
Assert.assertEquals(0, patientService.getAllPatients().size()); | ||
|
||
String patientId = patientService.insert(pat); | ||
Patient savedPatient = patientService.get(patientId); | ||
|
||
Assert.assertEquals(1, patientService.getAllPatients().size()); | ||
Assert.assertEquals(firstName, savedPatient.getPerson().getFirstName()); | ||
Assert.assertEquals(lastname, savedPatient.getPerson().getLastName()); | ||
Assert.assertEquals(gender, savedPatient.getGender()); | ||
} | ||
|
||
@Test | ||
public void getData_shouldCopyPropertiesFromDatabaseById() throws Exception { | ||
String firstName = "John"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
package org.openelisglobal.patient; | ||
|
||
import java.util.List; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openelisglobal.BaseWebContextSensitiveTest; | ||
import org.openelisglobal.common.util.ConfigurationProperties; | ||
import org.openelisglobal.patient.service.PatientTypeService; | ||
import org.openelisglobal.patienttype.valueholder.PatientType; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public class PatientTypeServiceTest extends BaseWebContextSensitiveTest { | ||
|
||
@Autowired | ||
PatientTypeService typeService; | ||
|
||
@Before | ||
public void init() { | ||
typeService.deleteAll(typeService.getAll()); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
typeService.deleteAll(typeService.getAll()); | ||
} | ||
|
||
@Test | ||
public void createPatientType_shouldCreateNewPatientType() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
Assert.assertEquals(0, typeService.getAllPatientTypes().size()); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.get(patientTypeId); | ||
|
||
Assert.assertEquals(1, typeService.getAllPatientTypes().size()); | ||
Assert.assertEquals("Test Type Description", savedPatientType.getDescription()); | ||
Assert.assertEquals("Test Type", savedPatientType.getType()); | ||
} | ||
|
||
@Test | ||
public void UpdatePatientType_shouldReturnUpdatedPatientType() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
Assert.assertEquals(0, typeService.getAllPatientTypes().size()); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.get(patientTypeId); | ||
savedPatientType.setType("Test2 Type"); | ||
typeService.save(savedPatientType); | ||
|
||
Assert.assertEquals(1, typeService.getAllPatientTypes().size()); | ||
Assert.assertEquals("Test Type Description", savedPatientType.getDescription()); | ||
Assert.assertEquals("Test2 Type", savedPatientType.getType()); | ||
} | ||
|
||
@Test | ||
public void deletePatientType_shouldDeletePatientType() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
Assert.assertEquals(0, typeService.getAllPatientTypes().size()); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.get(patientTypeId); | ||
typeService.delete(savedPatientType); | ||
|
||
Assert.assertEquals(0, typeService.getAllPatientTypes().size()); | ||
} | ||
|
||
@Test | ||
public void getallPatientTypes_shouldReturnPatientType() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
Assert.assertEquals(0, typeService.getAllPatientTypes().size()); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.get(patientTypeId); | ||
|
||
Assert.assertEquals(1, typeService.getAllPatientTypes().size()); | ||
} | ||
|
||
@Test | ||
public void getTotalPatientTypeCount_shouldReturnTotalPatientTypeCount() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
Assert.assertEquals(0, typeService.getAllPatientTypes().size()); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.get(patientTypeId); | ||
|
||
Assert.assertEquals(1, typeService.getTotalPatientTypeCount().longValue()); | ||
} | ||
|
||
@Test | ||
public void getPatientTypes_shouldReturnListOfFilteredPatientTypes() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.get(patientTypeId); | ||
|
||
PatientType patientType2 = new PatientType(); | ||
patientType2.setDescription("Test2 Type Description"); | ||
patientType2.setType("Test2 Type"); | ||
|
||
String patientTypeId2 = typeService.insert(patientType2); | ||
Assert.assertEquals(2, typeService.getAll().size()); | ||
|
||
List<PatientType> savedPatientTypes = typeService.getPatientTypes("Test2"); | ||
|
||
Assert.assertEquals(1, savedPatientTypes.size()); | ||
} | ||
|
||
@Test | ||
public void getPageOfPatientType_shouldReturnPatientTypes() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.get(patientTypeId); | ||
|
||
PatientType patientType2 = new PatientType(); | ||
patientType2.setDescription("Test2 Type Description"); | ||
patientType2.setType("Test2 Type"); | ||
|
||
String patientTypeId2 = typeService.insert(patientType2); | ||
Assert.assertEquals(2, typeService.getAll().size()); | ||
|
||
List<PatientType> patientTypesPage = typeService.getPageOfPatientType(1); | ||
|
||
int expectedPageSize = Integer | ||
.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize")); | ||
|
||
Assert.assertTrue(patientTypesPage.size() <= expectedPageSize); | ||
|
||
if (expectedPageSize >= 2) { | ||
Assert.assertTrue(patientTypesPage.stream().anyMatch(p -> p.getType().equals("Test Type"))); | ||
Assert.assertTrue(patientTypesPage.stream().anyMatch(p -> p.getType().equals("Test2 Type"))); | ||
} | ||
} | ||
|
||
@Test | ||
public void getData_shouldCopyPropertiesFromDatabase() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
|
||
PatientType patientType2 = new PatientType(); | ||
patientType2.setId(patientTypeId); | ||
typeService.getData(patientType2); | ||
|
||
Assert.assertEquals("Test Type", patientType2.getType()); | ||
} | ||
|
||
@Test | ||
public void getallPatientTypeByName_shouldReturnPatientType() throws Exception { | ||
PatientType patientType = new PatientType(); | ||
patientType.setDescription("Test Type Description"); | ||
patientType.setType("Test Type"); | ||
|
||
Assert.assertEquals(0, typeService.getAllPatientTypes().size()); | ||
|
||
String patientTypeId = typeService.insert(patientType); | ||
PatientType savedPatientType = typeService.getPatientTypeByName(patientType); | ||
|
||
Assert.assertEquals("Test Type", savedPatientType.getType()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also disacrd tis formating change here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont know what exactly you want me to do coz that was a chenge i made in the dao so that it can filter the patienttypes by string it cause before that it wascreating an error
do you want me to revert the changes? @mozzy11