DATAREST-517 - Null query results are now translated into 404.
We now explicitly handle null query execution results by returning 404 Not Found.
This commit is contained in:
@@ -100,11 +100,13 @@ class AbstractRepositoryRestController {
|
||||
|
||||
if (source instanceof Iterable) {
|
||||
return toResources((Iterable<?>) source, assembler, baseLink);
|
||||
} else if (source == null || ClassUtils.isPrimitiveOrWrapper(source.getClass())) {
|
||||
} else if (source == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
} else if (ClassUtils.isPrimitiveOrWrapper(source.getClass())) {
|
||||
return source;
|
||||
} else {
|
||||
return assembler.toFullResource(source);
|
||||
}
|
||||
|
||||
return assembler.toFullResource(source);
|
||||
}
|
||||
|
||||
protected Resources<? extends Resource<Object>> entitiesToResources(Page<Object> page,
|
||||
|
||||
@@ -315,4 +315,16 @@ public class MongoWebTests extends CommonWebTests {
|
||||
mvc.perform(get(link.expand(profile.getId()).getHref())).//
|
||||
andExpect(status().isOk());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-517
|
||||
*/
|
||||
@Test
|
||||
public void returnsNotFoundIfQueryExecutionDoesNotReturnResult() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique("profiles", "search", "findById");
|
||||
|
||||
mvc.perform(get(link.expand("").getHref())).//
|
||||
andExpect(status().isNotFound());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user