Skip to content
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

issue 3804 fix (SelectableEntityFiltering when the fields specified is . character) #3812

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ public void testFilters() throws Exception {
assertThat(entity.getRegion(), nullValue());
}

/**
* Test empty (but valid) filters.
* Valid empty filters are:
* . ,. , .. .,
*
*
* result is empty object (nothing is returned) but Jersey will not throw any exception
*/
@Test
public void testEmptyFilters() throws Exception {
final Person entity = target("people").path("1234")
.queryParam("select", ".").request()
.get(Person.class);

// Null values (all elements).
assertThat(entity.getFamilyName(), nullValue());
assertThat(entity.getGivenName(), nullValue());
assertThat(entity.getAddresses(), nullValue());
assertThat(entity.getPhoneNumbers(), nullValue());
assertThat(entity.getRegion(), nullValue());
}

/**
* Test 2nd and 3rd level filters.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ private Set<String> getScopesForField(final String fieldName) {
final String[] fields = Tokenizer.tokenize(fieldName, ",");
for (final String field : fields) {
final String[] subfields = Tokenizer.tokenize(field, ".");
if (subfields.length == 0) {
continue;
}
// in case of nested path, add first level as stand-alone to ensure subgraph is added
scopes.add(SelectableScopeResolver.PREFIX + subfields[0]);
if (subfields.length > 1) {
Expand Down