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

Code in voidRelationship is not executed due to BaseVoidHandler

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Code Review (Initial)
    • Priority: Could
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Complexity:
      Low

      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

                Assignee:
                jwnasambu Juliet Wamalwa
                Reporter:
                teleivo Ivo Ulrich
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated: