Skip to content

Commit

Permalink
Merge pull request #3812 from senivam/3804
Browse files Browse the repository at this point in the history
issue 3804 fix (SelectableEntityFiltering when the fields specified is . character)
  • Loading branch information
jansupol authored Jun 12, 2018
2 parents 575b3b0 + 6b189b3 commit 02f2cb6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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

0 comments on commit 02f2cb6

Please sign in to comment.