personService.voidRelationship(rel, "person " + (personAisNotPreferred ? "A" : "B") + " was merged to person " + (personAisPreferred ? "A" : "B")); } else if (existingRelationships.contains(relHash)) { personService.voidRelationship(rel, "person " + (personAisNotPreferred ? "A" : "B") + " was merged and a relationship already exists"); } else { mergedData.addCreatedRelationship(persisted.getUuid()); personService.voidRelationship(rel, "person " + (personAisNotPreferred ? "A" : "B") + " was merged, relationship copied to #" + tmpRel.getRelationshipId());
@Test public void voidRelationship_shouldVoidRelationshipIfGivenRelationshipIsNotVoided() { Relationship relationship = personService.getRelationship(1); assertFalse("We need an unvoided relationship to test the method", relationship.getVoided()); String voidReason = "Something"; // TODO - voiding is done by the BaseVoidHandler called via AOP before voidRelationship // is executed. Coverage of voidRelationship is low because relationship.getVoided() is true // when entering voidRelationship // Documented at TRUNK-5151 personService.voidRelationship(relationship, voidReason); Relationship voidedRelationship = personService.getRelationship(1); assertTrue(voidedRelationship.getVoided()); assertThat(voidedRelationship.getVoidReason(), is(voidReason)); assertNotNull(voidedRelationship.getDateVoided()); assertEquals(voidedRelationship.getVoidedBy(), Context.getAuthenticatedUser()); }
@Test public void voidRelationship_shouldVoidRelationshipWithVoidReasonNullIfGivenRelationshipIsNotVoided() { Relationship relationship = personService.getRelationship(1); assertFalse("We need an unvoided relationship to test the method", relationship.getVoided()); String voidReason = null; // TODO - voiding is done by the BaseVoidHandler called via AOP before voidRelationship // is executed. Coverage of voidRelationship is low because relationship.getVoided() is true // when entering voidRelationship // Documented at TRUNK-5151 personService.voidRelationship(relationship, voidReason); Relationship voidedRelationship = personService.getRelationship(1); assertTrue(voidedRelationship.getVoided()); assertThat(voidedRelationship.getVoidReason(), is(voidReason)); assertNotNull(voidedRelationship.getDateVoided()); assertEquals(voidedRelationship.getVoidedBy(), Context.getAuthenticatedUser()); }
@Test public void voidRelationship_shouldVoidRelationshipAndSetVoidedByToGivenUserIfGivenRelationshipIsNotVoided() { Relationship relationship = personService.getRelationship(1); assertFalse("We need an unvoided relationship to test the method", relationship.getVoided()); String voidReason = "Something"; User user = Context.getUserService().getUser(501); assertNotNull("need a user to void", user); relationship.setVoidedBy(user); // TODO - voiding is done by the BaseVoidHandler called via AOP before voidRelationship // is executed. Coverage of voidRelationship is low because relationship.getVoided() is true // when entering voidRelationship // Documented at TRUNK-5151 personService.voidRelationship(relationship, voidReason); Relationship voidedRelationship = personService.getRelationship(1); assertTrue(voidedRelationship.getVoided()); assertThat(voidedRelationship.getVoidReason(), is(voidReason)); assertNotNull(voidedRelationship.getDateVoided()); assertEquals(voidedRelationship.getVoidedBy(), user); }
@Override protected void delete(Relationship delegate, String reason, RequestContext context) throws ResponseException { if (delegate.isVoided()) { return; } Context.getPersonService().voidRelationship(delegate, reason); }
personService.voidRelationship(r, "Because of a JUnit test.");
/** * Voids the Mother-Child relationship * * @param childId Child's MOTECH Id * @return the voided Relationship of OpenMRS */ public Relationship voidRelationship(String childId) { Relationship relationship = getMotherRelationship(childId); relationship = personService.voidRelationship(relationship, REASON); return personService.saveRelationship(relationship); }
personService.voidRelationship(r, "Because of a JUnit test.");
/** * @see PersonService#unvoidRelationship(Relationship) */ @Test public void unvoidRelationship_shouldUnvoidVoidedRelationship() throws Exception { Relationship relationship = Context.getPersonService().getRelationship(1); Relationship voidedRelationship = Context.getPersonService().voidRelationship(relationship, "Test Voiding Relationship"); assertTrue(voidedRelationship.getVoided()); Assert.assertNotNull(voidedRelationship.getVoidedBy()); Assert.assertNotNull(voidedRelationship.getVoidReason()); Assert.assertNotNull(voidedRelationship.getDateVoided()); Relationship unvoidedRelationship = Context.getPersonService().unvoidRelationship(voidedRelationship); Assert.assertFalse(unvoidedRelationship.getVoided()); Assert.assertNull(unvoidedRelationship.getVoidedBy()); Assert.assertNull(unvoidedRelationship.getVoidReason()); Assert.assertNull(unvoidedRelationship.getDateVoided()); }
log.debug("voiding relationships" + r.getId()); Context.getPersonService().voidRelationship(r, "htmlformentry");