/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getRelationshipId(); }
/** * @see PersonService#getRelationshipByUuid(String) */ @Test public void getRelationshipByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "c18717dd-5d78-4a0e-84fc-ee62c5f0676a"; Relationship relationship = Context.getPersonService().getRelationshipByUuid(uuid); Assert.assertEquals(1, (int) relationship.getRelationshipId()); }
tmpRel.setPersonB(preferred); log.debug("Copying relationship " + rel.getRelationshipId() + " to " + preferred.getPatientId()); Relationship persisted = personService.saveRelationship(tmpRel); mergedData.addCreatedRelationship(persisted.getUuid()); + " was merged, relationship copied to #" + tmpRel.getRelationshipId());
/** * @see PersonService#saveRelationship(Relationship) */ @Test public void saveRelationship_shouldCreateNewObjectWhenRelationshipIdIsNull() throws Exception { PersonService personService = Context.getPersonService(); Relationship relationship = new Relationship(); relationship.setPersonA(personService.getPerson(1)); relationship.setPersonB(personService.getPerson(2)); relationship.setRelationshipType(personService.getRelationshipType(1)); Assert.assertNull(relationship.getRelationshipId()); Relationship savedRelationship = personService.saveRelationship(relationship); Assert.assertNotNull(savedRelationship.getRelationshipId()); }
/** * @see PersonService#saveRelationship(Relationship) */ @Test public void saveRelationship_shouldUpdateExistingObjectWhenRelationshipIdIsNotNull() throws Exception { PersonService personService = Context.getPersonService(); Relationship savedRelationship = personService.getRelationship(1); Assert.assertNotNull(savedRelationship.getRelationshipId()); savedRelationship.setRelationshipType(personService.getRelationshipType(2)); Relationship updatedRelationship = personService.saveRelationship(savedRelationship); Assert.assertEquals(personService.getRelationshipType(2), updatedRelationship.getRelationshipType()); }