Skip to content

Commit 08b817f

Browse files
committed
fix failing tests
1 parent bcaf91a commit 08b817f

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

omod-2.0/src/test/java/org/openmrs/module/webservices/rest/resource/SubDetailsResource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
6464
return new DelegatingResourceDescription();
6565
}
6666

67+
@Override
68+
public DelegatingResourceDescription getCreatableProperties() throws ResourceDoesNotSupportOperationException {
69+
return new DelegatingResourceDescription();
70+
}
71+
6772
@Override
6873
public SubDetails newDelegate() {
6974
return new SubDetails();

omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/SwaggerGenerationUtil.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.Set;
4242
import java.util.UUID;
4343

44+
import static org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl.resourcesBySupportedClasses;
4445
import static org.openmrs.module.webservices.rest.web.representation.Representation.DEFAULT;
4546
import static org.openmrs.module.webservices.rest.web.representation.Representation.FULL;
4647
import static org.openmrs.module.webservices.rest.web.representation.Representation.REF;
@@ -284,7 +285,7 @@ public static String getResourceNameBySupportedClass(Class<?> supportedClass) {
284285
}
285286

286287
public static String getSubResourceNameBySupportedClass(Class<?> supportedClass) {
287-
org.openmrs.module.webservices.rest.web.resource.api.Resource resourceHandler = Context.getService(RestService.class).getResourceHandlerForSupportedClass(supportedClass);
288+
org.openmrs.module.webservices.rest.web.resource.api.Resource resourceHandler = getResourceHandlerForSupportedClass(supportedClass);
288289

289290
if (resourceHandler == null) {
290291
return null;
@@ -397,4 +398,15 @@ public static Class<?> getGenericType(Class<?> resourceHandlerClass) {
397398

398399
return null;
399400
}
401+
402+
/**
403+
* <strong>Should</strong> return search resources for given resource class
404+
* @param resourceClass the resource class e.g. PatientIdentifier
405+
*/
406+
public static org.openmrs.module.webservices.rest.web.resource.api.Resource getResourceHandlerForSupportedClass(Class<?> resourceClass) {
407+
if (resourcesBySupportedClasses == null) {
408+
Context.getService(RestService.class).initializeResources();
409+
}
410+
return resourcesBySupportedClasses.get(resourceClass);
411+
}
400412
}

omod-common/src/main/java/org/openmrs/module/webservices/rest/web/api/RestService.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
* Database related methods for the Rest Web Services
2424
*/
2525
public interface RestService {
26-
26+
27+
void initializeResources();
28+
2729
/**
2830
* Parses a representation requested by the client via the http request
2931
*
@@ -74,13 +76,6 @@ public interface RestService {
7476
*/
7577
public List<DelegatingResourceHandler<?>> getResourceHandlers() throws APIException;
7678

77-
78-
/**
79-
* @param resourceClass the resource class e.g PatientIdentifier.class
80-
* @return the resource handler for the provided class e.g PatientIdentifierResource1_8
81-
*/
82-
Resource getResourceHandlerForSupportedClass(Class<?> resourceClass);
83-
8479
/**
8580
* Initializes all Resources and Search handlers for use; called after module startup
8681
*/

omod-common/src/main/java/org/openmrs/module/webservices/rest/web/api/impl/RestServiceImpl.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class RestServiceImpl implements RestService {
4949

5050
volatile Map<String, ResourceDefinition> resourceDefinitionsByNames;
5151

52-
volatile Map<Class<?>, Resource> resourcesBySupportedClasses;
52+
public static volatile Map<Class<?>, Resource> resourcesBySupportedClasses;
5353

5454
private volatile Map<CompositeSearchHandlerKeyValue, Set<SearchHandler>> searchHandlersByParameter;
5555

@@ -144,8 +144,9 @@ public int hashCode() {
144144
return result;
145145
}
146146
}
147-
148-
private void initializeResources() {
147+
148+
@Override
149+
public void initializeResources() {
149150
if (resourceDefinitionsByNames != null) {
150151
return;
151152
}
@@ -689,19 +690,6 @@ public Set<SearchHandler> getSearchHandlers(String resourceName) {
689690
}
690691
return searchHandlersByResource.get(resourceName);
691692
}
692-
693-
/**
694-
* @see RestService#getResourceHandlerForSupportedClass(Class)
695-
* <strong>Should</strong> return search resources for given resource class
696-
* @param resourceClass the resource class e.g. PatientIdentifier
697-
*/
698-
@Override
699-
public Resource getResourceHandlerForSupportedClass(Class<?> resourceClass) {
700-
if (resourcesBySupportedClasses == null) {
701-
initializeResources();
702-
}
703-
return resourcesBySupportedClasses.get(resourceClass);
704-
}
705693

706694
/**
707695
* @see RestService#initialize()

0 commit comments

Comments
 (0)