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

Commit

Permalink
Check for initial logger message only once
Browse files Browse the repository at this point in the history
  • Loading branch information
DeanWay committed Jul 16, 2015
1 parent 925d60a commit 3c2fff4
Showing 1 changed file with 3 additions and 17 deletions.
Expand Up @@ -158,7 +158,6 @@ public void getPatientWithNoAccessReturnsForbiddenCode() throws ComponentLookupE
when(this.access.hasAccess(Right.VIEW, this.userReference, this.patientReference)).thenReturn(false);

Response response = this.component.getPatient(this.eid);
verify(this.logger).debug("Retrieving patient record with external ID [{}] via REST", this.eid);
verify(this.logger).debug("View access denied to user [{}] on patient record [{}]", this.user, this.patient.getId());

assertEquals(Response.Status.FORBIDDEN.getStatusCode(), response.getStatus());
Expand Down Expand Up @@ -216,7 +215,6 @@ public void updatePatientNoAccessReturnsForbiddenCode() throws ComponentLookupEx
when(this.access.hasAccess(Right.EDIT, this.userReference, this.patientReference)).thenReturn(false);

Response response = this.component.updatePatient("json", this.eid);
verify(this.logger).debug("Updating patient record with external ID [{}] via REST", this.eid);
verify(this.logger).debug("Edit access denied to user [{}] on patient record [{}]", null, this.patient.getId());
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), response.getStatus());

Expand Down Expand Up @@ -300,24 +298,12 @@ public void updatePatientFromJSONException() throws ComponentLookupException
@Test
public void updatePatientReturnsNoContentResponse() throws ComponentLookupException
{

Response response = this.component.updatePatient("{\"id\":\"id\"}", "eid");
String json = "{\"id\":\"id\"}";
Response response = this.component.updatePatient(json, this.eid);
verify(this.logger).debug("Updating patient record with external ID [{}] via REST with JSON: {}", this.eid, json);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}

@Test
public void deletePatientAlwaysSendsLoggerMessageOnRequest()
{
XWiki wiki = mock(XWiki.class);
doReturn(wiki).when(this.context).getWiki();
doReturn(true).when(this.access).hasAccess(Right.DELETE, null, null);
when(this.repository.getPatientByExternalId(this.eid)).thenReturn(this.patient);

this.component.deletePatient(this.eid);

verify(this.logger).debug("Deleting patient record with external ID [{}] via REST", this.eid);
}

@Test
public void checkForMultipleRecordsPerformsCorrectly() throws QueryException
{
Expand Down

0 comments on commit 3c2fff4

Please sign in to comment.