BrowseAssetsSqlBuilder extends BrowseMetadataNodeSqlBuilderSupport { @Override protected String buildWhereClause(final List<String> bucketIds, final QueryOptions queryOptions) { List<String> whereClauses = new ArrayList<>(); if (!bucketIds.isEmpty()) { whereClauses.add("(" + bucketIds.stream() .map((bucket) -> MetadataNodeEntityAdapter.P_BUCKET + " = " + bucket) .collect(Collectors.joining(" OR ")) + ")"); } if (queryOptions.getContentAuth()) { whereClauses.add("contentAuth(@this.name, @this.format, :browsedRepository) == true"); } return whereClause(Joiner.on(" AND ").join(whereClauses), queryOptions.getFilter() != null, queryOptions.getLastId() != null); } @Inject  BrowseAssetsSqlBuilder(final AssetEntityAdapter assetEntityAdapter);   }
@Test public void whereWithAuth() throws Exception { String whereClause = underTest.buildWhereClause(emptyList(), queryOptions); assertThat(whereClause, is(equalTo(CONTENT_AUTH_WHERE))); }
@Test public void whereWithFilter() throws Exception { when(queryOptions.getFilter()).thenReturn("filter"); String whereClause = underTest.buildWhereClause(emptyList(), queryOptions); assertThat(whereClause, is(equalTo(CONTENT_AUTH_WHERE + " AND " + FILTER_WHERE))); }
@Test public void whereWithNoContentAuth() { when(queryOptions.getContentAuth()).thenReturn(false); assertThat(underTest.buildWhereClause(emptyList(), queryOptions), is(nullValue())); }
@Test public void whereWithNoConentAuthAndFilter() throws Exception { when(queryOptions.getContentAuth()).thenReturn(false); when(queryOptions.getFilter()).thenReturn("filter"); assertThat(underTest.buildWhereClause(emptyList(), queryOptions), is(equalTo(FILTER_WHERE))); }