Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
test for throwing exception while updating from json
Browse files Browse the repository at this point in the history
  • Loading branch information
JKereliuk committed Jul 9, 2015
1 parent 6a05865 commit 564bd9e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ public void updatePatientWrongJSONId() throws ComponentLookupException, XWikiRes
this.mocker.getComponentUnderTest().updatePatient("{\"id\":\"notid\"}", "eid");
}

@Test(expected=Exception.class)
public void updatePatientFromJSONException() throws ComponentLookupException, XWikiRestException
{
when(this.repository.getPatientByExternalId("eid")).thenReturn(this.patient);
when(this.access.hasAccess(Right.EDIT, null, null)).thenReturn(true);
doThrow(Exception.class).when(this.patient).updateFromJSON(Matchers.any(JSONObject.class));

this.mocker.getComponentUnderTest().updatePatient("{\"id\":\"id\"}", "eid");
verify(this.logger).debug("Failed to update patient [{}] from JSON: {}. Source JSON was: {}",
"id", "{\"id\":\"id\"}");
}



}

0 comments on commit 564bd9e

Please sign in to comment.