@Override protected void delete(Relationship delegate, String reason, RequestContext context) throws ResponseException { if (delegate.isVoided()) { return; } Context.getPersonService().voidRelationship(delegate, reason); }
@Test public void shouldVoidARelationship() throws Exception { Relationship relationship = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); Assert.assertFalse(relationship.isVoided()); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason", "test reason"))); relationship = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); Assert.assertTrue(relationship.isVoided()); Assert.assertEquals("test reason", relationship.getVoidReason()); }
@Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropPresent("personA"); assertPropPresent("relationshipType"); assertPropPresent("personB"); assertPropPresent("startDate"); assertPropPresent("endDate"); assertPropEquals("voided", getObject().isVoided()); assertFalse("Should not expose the Patient subclass", findSelfLink((SimpleObject) getRepresentation().get("personA")).contains("/patient/")); assertFalse("Should not expose the Patient subclass", findSelfLink((SimpleObject) getRepresentation().get("personB")).contains("/patient/")); }
@Override public void validateFullRepresentation() throws Exception { super.validateFullRepresentation(); assertPropPresent("personA"); assertPropPresent("relationshipType"); assertPropPresent("personB"); assertPropPresent("startDate"); assertPropPresent("endDate"); assertPropEquals("voided", getObject().isVoided()); assertPropPresent("auditInfo"); assertFalse("Should not expose the Patient subclass", findSelfLink((SimpleObject) getRepresentation().get("personA")).contains("/patient/")); assertFalse("Should not expose the Patient subclass", findSelfLink((SimpleObject) getRepresentation().get("personB")).contains("/patient/")); }