use of org.openmrs.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationships3_shouldReturnEmptyListWhenNoRelationshipMatchingGivenParametersExist.
/**
* @see PersonService#getRelationships(Person,Person,RelationshipType,Date,Date)
*/
@Test
public void getRelationships3_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(), 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 getRelationshipTypeByUuid_shouldFindObjectGivenValidUuid.
/**
* @see PersonService#getRelationshipTypeByUuid(String)
*/
@Test
public void getRelationshipTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception {
String uuid = "6d9002ea-a96b-4889-af78-82d48c57a110";
RelationshipType relationshipType = Context.getPersonService().getRelationshipTypeByUuid(uuid);
Assert.assertEquals(1, (int) relationshipType.getRelationshipTypeId());
}
use of org.openmrs.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method saveRelationshipType_shouldCreateNewObjectWhenRelationshipTypeIdIsNull.
/**
* @see PersonService#saveRelationshipType(RelationshipType)
*/
@Test
public void saveRelationshipType_shouldCreateNewObjectWhenRelationshipTypeIdIsNull() throws Exception {
RelationshipType relationshipType = new RelationshipType();
relationshipType.setDescription("Test relationship");
relationshipType.setaIsToB("Sister");
relationshipType.setbIsToA("Brother");
Assert.assertNull(relationshipType.getRelationshipTypeId());
RelationshipType savedRelationshipType = personService.saveRelationshipType(relationshipType);
Assert.assertNotNull(savedRelationshipType.getRelationshipTypeId());
}
use of org.openmrs.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method unretireRelationshipType_shouldRetireGivenRelationshipType.
@Test
public void unretireRelationshipType_shouldRetireGivenRelationshipType() {
RelationshipType rt = personService.getRelationshipType(1);
personService.retireRelationshipType(rt, "reason");
assertTrue(rt.getRetired());
personService.unretireRelationshipType(rt);
assertFalse(rt.getRetired());
assertNull(rt.getRetiredBy());
assertNull(rt.getDateRetired());
assertNull(rt.getRetireReason());
}
use of org.openmrs.RelationshipType in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationships2_shouldFetchRelationshipsMatchingTheGivenRelType.
/**
* @see PersonService#getRelationships(Person,Person,RelationshipType,Date)
*/
@Test
public void getRelationships2_shouldFetchRelationshipsMatchingTheGivenRelType() throws Exception {
PersonService personService = Context.getPersonService();
RelationshipType relationshipType = personService.getRelationshipType(1);
List<Relationship> relationships = personService.getRelationships(null, null, relationshipType, new Date());
Assert.assertNotNull(relationships);
assertTrue("There should be relationship found given the relationship type", relationships.size() > 0);
}
Aggregations