-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDMO-65: fix bug to enable retrieving soft deleted observations. #310
Conversation
@@ -479,13 +481,19 @@ protected PageableResult doSearch(RequestContext context) { | |||
} | |||
|
|||
String encounterUuid = context.getRequest().getParameter("encounter"); | |||
boolean includeVoided = Boolean.parseBoolean(context.getRequest().getParameter("includeAll")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you try context.getIncludeAll()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been corrected
if (encounterUuid != null) { | ||
Encounter enc = ((EncounterResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( | ||
Encounter.class)).getByUniqueId(encounterUuid); | ||
if (enc == null) | ||
return new EmptySearchResult(); | ||
List<Obs> obs = new ArrayList<Obs>(enc.getAllObs()); | ||
return new NeedsPaging<Obs>(obs, context); | ||
if (includeVoided) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you refactor this, in way you may not need to use the if since you have already acquired the value of includeVoided
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been corrected
@@ -48,6 +48,8 @@ | |||
import org.openmrs.module.webservices.rest.web.response.IllegalRequestException; | |||
import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; | |||
import org.openmrs.module.webservices.rest.web.response.ResponseException; | |||
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterResource1_8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this?
@@ -48,6 +48,8 @@ | |||
import org.openmrs.module.webservices.rest.web.response.IllegalRequestException; | |||
import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; | |||
import org.openmrs.module.webservices.rest.web.response.ResponseException; | |||
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterResource1_8; | |||
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were mistakenly imported and have been removed.
43b945b
to
d9c493f
Compare
Good work @Ewanjiru |
MockHttpServletResponse allObsIncludingVoidedResponse = handle(getAllObsIncludingVoidedRequest); | ||
List<Object> allObsIncludingVoidedList = deserialize(allObsIncludingVoidedResponse).get("results"); | ||
|
||
assertEquals(allObsIncludingVoidedList.size(), 6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test does not assert that voided obs were retrieved, because AllNonVoidedObsList has the same size with allObsIncludingVoidedList. Can you fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By this I was confirming that the length is the same since before the fix it would only retrieve the non-voided observations hence length would be less but with above test it confirms that even after the delete request the length is still the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, just assert that AllNonVoidedObsList is now 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, well noted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamsdenniskariuki , @andela-cuchendu I have added the assert.
Thanks for the review.
@@ -479,12 +479,14 @@ protected PageableResult doSearch(RequestContext context) { | |||
} | |||
|
|||
String encounterUuid = context.getRequest().getParameter("encounter"); | |||
boolean includeVoided = context.getIncludeAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need the above local variable?
|
||
MockHttpServletRequest getAllNonVoidedObsRequest2 = newGetRequest(getURI()); | ||
getAllNonVoidedObsRequest2.addParameter("encounter", "62967e68-96bb-11e0-8d6b-9b9415a91465"); | ||
MockHttpServletResponse AllNonVoidedObsResponse2 = handle(getAllNonVoidedObsRequest2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you look at our conventions for variable names? https://wiki.openmrs.org/display/docs/Java+Conventions#JavaConventions-NamingConventions
The same applies to the above.
|
||
assertEquals(allObsIncludingVoidedList.size(), 6); | ||
|
||
MockHttpServletRequest getAllNonVoidedObsRequest2 = newGetRequest(getURI()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is getAllNonVoidedObsRequest2 a function or variable?
|
||
executeDataSet("encounterWithObsGroup1_9.xml"); | ||
|
||
MockHttpServletRequest getAllNonVoidedObsRequest = newGetRequest(getURI()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is getAllNonVoidedObsRequest a function or variable?
The same applies to the others.
d882b3a
to
bb5b947
Compare
@dkayiwa |
@@ -84,6 +87,38 @@ public void shouldGetAll() throws Exception { | |||
} | |||
|
|||
@Test | |||
public void shouldGetallIncludingVoidedObs() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test method name does not clearly state what you are testing. Can you look at this for an example? 191e0b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa
Working on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been corrected.
handle(deleteRequest); | ||
|
||
MockHttpServletRequest allObsIncludingVoidedRequest = newGetRequest(getURI()); | ||
allObsIncludingVoidedRequest.addParameter("encounter", "62967e68-96bb-11e0-8d6b-9b9415a91465"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you avoid using this uuid from more than one place 62967e68-96bb-11e0-8d6b-9b9415a91465?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa
I am not sure I follow what you mean since the uuids above are different;
62967e68-96bb-11e0-8d6b-9b9415a91465 is the encounter uuid
11de743c-96cd-11e0-8d6b-9b9415a91465 is the observation uuid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me put it this way, are you aware of the fact that you are using 62967e68-96bb-11e0-8d6b-9b9415a91465 in more than one place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been corrected by assigning the uuid to a variable.
|
||
executeDataSet("encounterWithObsGroup1_9.xml"); | ||
|
||
String encounterUuid = "62967e68-96bb-11e0-8d6b-9b9415a91465"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at our naming conventions in regards to the above line? https://wiki.openmrs.org/display/docs/Java+Conventions#JavaConventions-NamingConventions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa
This has been fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How have you fixed it?
16a798b
to
c978e25
Compare
@dkayiwa |
JIRA TICKET NAME:
RESTWS-683: [Enable retrieving soft deleted observations](https://issues.openmrs.org/browse/RESTWS-683
SUMMARY:
Fix bug in the webservice to enable retrieving soft deleted observations.