Hi everyone,
I have just created a custom ObservationByOrderSearchHandler
that retrieves observations by order.
It works just fine.
Now I am writing the unit tests for it, based on what has been done in the ‘LocationSearchHandlerTest’.
So when I extend the MainResourceControllerTest
class,
public class ObservationByOrderSearchHandlerTest extends MainResourceControllerTest {
I inherit of a bunch of other tests, among which the shouldGetAll
test.
But this test fails. See the failure trace:
org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException at org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.doGetAll(DelegatingCrudResource.java:225) at org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.getAll(DelegatingCrudResource.java:212) at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.get(MainResourceController.java:176) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest.handle(MainResourceControllerTest.java:155) at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest.shouldGetAll(MainResourceControllerTest.java:202) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) ...
Any idea why ?
After a bit of research, It seems to me that the DelegatingCrudResource
is looking for a doGetAll()
method implementation in the Observation resource.
However this method does not exist in ObsResource1_8 (unlike in some other resources like LocationResource1_8#doGetAll() for instance ),
But I am not really sure what to do now.
Thanks