use of org.openmrs.test.SkipBaseSetup in project openmrs-core by openmrs.
the class UserServiceTest method getUserByUuid_shouldFetchUserWithGivenUuid.
@Test
@SkipBaseSetup
public void getUserByUuid_shouldFetchUserWithGivenUuid() throws SQLException {
initializeInMemoryDatabase();
executeDataSet(XML_FILENAME);
authenticate();
User user = userService.getUserByUuid("013c49c6-e132-11de-babe-001e378eb67e");
assertEquals("Did not fetch user with given uuid", user, userService.getUser(5505));
}
use of org.openmrs.test.SkipBaseSetup in project openmrs-core by openmrs.
the class PatientServiceTest method shouldGetPatientsByIdentifierAndIdentifierType.
/**
* Test the PatientService.getPatients(String, String, List) method with both an identifier and
* an identifiertype
*
* @throws Exception
*/
@Test
@SkipBaseSetup
public void shouldGetPatientsByIdentifierAndIdentifierType() throws Exception {
initializeInMemoryDatabase();
executeDataSet(FIND_PATIENTS_XML);
authenticate();
updateSearchIndex();
List<PatientIdentifierType> types = new ArrayList<>();
types.add(new PatientIdentifierType(1));
// make sure we get back only one patient
List<Patient> patients = patientService.getPatients("1234", null, types, false);
assertEquals(1, patients.size());
// make sure we get back only one patient
patients = patientService.getPatients("1234", null, null, false);
assertEquals(1, patients.size());
// make sure we can search a padded identifier
patients = patientService.getPatients("00000001234", null, null, false);
assertEquals(1, patients.size());
}
use of org.openmrs.test.SkipBaseSetup in project openmrs-core by openmrs.
the class PatientServiceTest method purgePatient_shouldDeletePatientFromDatabase.
@SkipBaseSetup
@Test
public void purgePatient_shouldDeletePatientFromDatabase() throws Exception {
initializeInMemoryDatabase();
executeDataSet(FIND_PATIENTS_XML);
authenticate();
// verify patient with ID 2 exists in database
Patient patientToPurge = patientService.getPatient(2);
assertNotNull(patientToPurge);
// purge the patient
patientService.purgePatient(patientToPurge);
// if the patient doesn't exist in the database, getPatient should
// return null now
assertNull(patientService.getPatient(2));
}
use of org.openmrs.test.SkipBaseSetup in project openmrs-core by openmrs.
the class UserServiceTest method createUser_shouldShouldCreateUserWhoIsPatientAlready.
@Test
@SkipBaseSetup
public void createUser_shouldShouldCreateUserWhoIsPatientAlready() throws SQLException {
// create the basic user and give it full rights
initializeInMemoryDatabase();
// authenticate to the temp database
authenticate();
assertTrue("The context needs to be correctly authenticated to by a user", Context.isAuthenticated());
// add in some basic data
executeDataSet(XML_FILENAME);
// the user should not exist yet
User preliminaryFetchedUser = userService.getUser(2);
assertNull(preliminaryFetchedUser);
// get the person object we'll make into a user
Person personToMakeUser = Context.getPersonService().getPerson(2);
// this avoids a lazy init exception, since we're going to clear the session
((Patient) personToMakeUser).getIdentifiers().size();
Context.clearSession();
// this is the user object we'll be saving
User user = new User(personToMakeUser);
user.setUsername("bwolfe");
user.setSystemId("asdf");
// included in xml file
user.addRole(new Role("Some Role", "This is a test role"));
// make sure everything was added to the user correctly
assertTrue(user.getUsername().equals("bwolfe"));
assertTrue(user.hasRole("Some Role"));
// do the actual creating of the user object
userService.createUser(user, "Openmr5xy");
Assert.assertNotNull("User was not created", userService.getUser(user.getUserId()));
Integer shouldCreateUserWhoIsPatientAlreadyTestUserIdCreated = user.getUserId();
Context.flushSession();
// get the same user we just created and make sure the user portion exists
User fetchedUser = userService.getUser(shouldCreateUserWhoIsPatientAlreadyTestUserIdCreated);
User fetchedUser3 = userService.getUser(3);
if (fetchedUser3 != null) {
throw new RuntimeException("There is a user with id #3");
}
assertNotNull("Uh oh, the user object was not created", fetchedUser);
assertNotNull("Uh oh, the username was not saved", fetchedUser.getUsername());
assertTrue("Uh oh, the username was not saved", fetchedUser.getUsername().equals("bwolfe"));
assertTrue("Uh oh, the role was not assigned", fetchedUser.hasRole("Some Role"));
Context.clearSession();
List<User> allUsers = userService.getAllUsers();
assertEquals(11, allUsers.size());
// there should still only be the one patient we created in the xml file
List<Patient> allPatientsSet = Context.getPatientService().getAllPatients();
assertEquals(1, allPatientsSet.size());
}
Aggregations