use of org.openmrs.RelationshipType 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.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method saveRelationshipType_shouldUpdateExistingObjectWhenRelationshipTypeIdIsNotNull.
/**
* @see PersonService#saveRelationshipType(RelationshipType)
*/
@Test
public void saveRelationshipType_shouldUpdateExistingObjectWhenRelationshipTypeIdIsNotNull() throws Exception {
RelationshipType savedRelationshipType = Context.getPersonService().getRelationshipType(1);
Assert.assertNotNull(savedRelationshipType.getRelationshipTypeId());
savedRelationshipType.setPreferred(true);
RelationshipType updatedRelationshipType = personService.saveRelationshipType(savedRelationshipType);
Assert.assertEquals(true, updatedRelationshipType.getPreferred());
}
use of org.openmrs.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method purgeRelationshipType_shouldDeleteRelationshipTypeFromTheDatabase.
/**
* @see PersonService#purgeRelationshipType(RelationshipType)
*/
@Test
public void purgeRelationshipType_shouldDeleteRelationshipTypeFromTheDatabase() throws Exception {
PersonService personService = Context.getPersonService();
RelationshipType relationshipType = new RelationshipType();
relationshipType.setDescription("Test relationship");
relationshipType.setaIsToB("Sister");
relationshipType.setbIsToA("Brother");
relationshipType = personService.saveRelationshipType(relationshipType);
assertNotNull(relationshipType.getId());
personService.purgeRelationshipType(relationshipType);
RelationshipType deletedRelationshipType = personService.getRelationshipType(relationshipType.getId());
Assert.assertNull(deletedRelationshipType);
}
use of org.openmrs.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationships_shouldFetchRelationshipsMatchingTheGivenRelType.
/**
* @see PersonService#getRelationships(Person,Person,RelationshipType)
*/
@Test
public void getRelationships_shouldFetchRelationshipsMatchingTheGivenRelType() throws Exception {
PersonService personService = Context.getPersonService();
RelationshipType relationshipType = personService.getRelationshipType(1);
List<Relationship> relationships = personService.getRelationships(null, null, relationshipType);
Assert.assertNotNull(relationships);
assertTrue("There should be relationship found given the relationship type", relationships.size() > 0);
}
use of org.openmrs.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method retireRelationshipType_shouldRetireGivenRelationshipType.
@Test
public void retireRelationshipType_shouldRetireGivenRelationshipType() {
RelationshipType rt = personService.getRelationshipType(1);
assertFalse(rt.getRetired());
String reason = "reason";
personService.retireRelationshipType(rt, reason);
assertTrue(rt.getRetired());
assertThat(rt.getRetiredBy(), is(Context.getAuthenticatedUser()));
assertNotNull(rt.getDateRetired());
assertThat(rt.getRetireReason(), is(reason));
}
Aggregations