use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationships2_shouldReturnEmptyListWhenNoRelationshipMatchingGivenParametersExist.
/**
* @see PersonService#getRelationships(Person,Person,RelationshipType,Date)
*/
@Test
public void getRelationships2_shouldReturnEmptyListWhenNoRelationshipMatchingGivenParametersExist() throws Exception {
PersonService personService = Context.getPersonService();
Person firstPerson = personService.getPerson(501);
Person secondPerson = personService.getPerson(2);
RelationshipType relationshipType = personService.getRelationshipType(1);
List<Relationship> relationships = personService.getRelationships(firstPerson, secondPerson, relationshipType, new Date());
Assert.assertNotNull(relationships);
assertTrue("There should be no relationship found given the from person", relationships.isEmpty());
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method purgeRelationship_shouldDeleteRelationshipFromTheDatabase.
/**
* @see PersonService#purgeRelationship(Relationship)
*/
@Test
public void purgeRelationship_shouldDeleteRelationshipFromTheDatabase() throws Exception {
PersonService personService = Context.getPersonService();
Relationship relationship = personService.getRelationship(1);
personService.purgeRelationship(relationship);
Relationship deletedRelationship = personService.getRelationship(1);
Assert.assertNull(deletedRelationship);
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method saveRelationship_shouldThrowAPIException.
/**
* @see PersonService#saveRelationship(Relationship)
*/
@Test(expected = APIException.class)
public void saveRelationship_shouldThrowAPIException() {
Relationship relationship = new Relationship();
Person person = new Person();
relationship.setPersonA(person);
relationship.setPersonB(person);
personService.saveRelationship(relationship);
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationshipsByPerson_shouldFetchUnvoidedRelationshipsOnly.
/**
* @see PersonService#getRelationshipsByPerson(Person)
*/
@Test
public void getRelationshipsByPerson_shouldFetchUnvoidedRelationshipsOnly() throws Exception {
executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml");
PersonService personService = Context.getPersonService();
Person person = personService.getPerson(6);
List<Relationship> relationships = personService.getRelationshipsByPerson(person);
Assert.assertNotNull(relationships);
assertTrue("There should be no relationship found given the person", relationships.isEmpty());
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getAllRelationships_shouldReturnAllRelationshipIncludingVoidedWhenIncludeVoidedEqualsTrue.
/**
* @see PersonService#getAllRelationships(null)
*/
@Test
public void getAllRelationships_shouldReturnAllRelationshipIncludingVoidedWhenIncludeVoidedEqualsTrue() throws Exception {
executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml");
List<Relationship> relationships = Context.getPersonService().getAllRelationships(true);
assertTrue("At least one element, otherwise no checking for voided will take place", relationships.size() > 0);
boolean foundVoided = false;
for (Relationship relationship : relationships) {
if (relationship.getVoided()) {
foundVoided = true;
break;
}
}
assertTrue("There should be voided relationship here", foundVoided);
}
Aggregations