Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5151

Code in voidRelationship is not executed due to BaseVoidHandler

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Could
    • Resolution: Fixed
    • None
    • Core 2.6.0
    • None

    Description

      PersonServiceImpl.voidRelationship currently looks like

      		if (relationship.getVoided()) {
      			return relationship;
      		}
      		
      		relationship.setVoided(true);
      		if (relationship.getVoidedBy() == null) {
      			relationship.setVoidedBy(Context.getAuthenticatedUser());
      		}
      		if (voidReason != null) {
      			relationship.setVoidReason(voidReason);
      		}
      		relationship.setDateVoided(new Date());
      		
      		return Context.getPersonService().saveRelationship(relationship);
      

      due to the BaseVoidHandler which is being called via AOP the Relationship is already voided, therefore the guard clause at the top of the voidRelationship method exits.

      This also explains why the coverage of the method is low despite 3 tests aimed at testing the different branches in this method.

      I suggest we remove all the code except the return Context.getPersonService().saveRelationship(relationship). This would make the implementation equal to voidPersonAddress, voidPersonName. Remaining question, what if given null? voidPerson then returns null, the other two methods dont.

      Gliffy Diagrams

        Attachments

          Issue Links

            Activity

              People

                kimote kimote Hillary
                teleivo Ivo Ulrich
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: