DataSearchQueryBuilder { public String taggedWith() { Set<Tag> tags = dsf.getTagQuery(); if (tags == null) { return ""; } StringBuilder sb = new StringBuilder(); for (Tag it : tags) { sb.append(it.getId()); sb.append(","); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); } DataSearchQueryBuilder(DiskResourceQueryTemplate dsf, UserInfo userinfo); String buildFullQuery(); String taggedWith(); DataSearchQueryBuilder ownedBy(); DataSearchQueryBuilder createdWithin(); DataSearchQueryBuilder file(); DataSearchQueryBuilder fileSizeRange(); String getQuery(); DataSearchQueryBuilder metadataAttribute(); DataSearchQueryBuilder metadataValue(); DataSearchQueryBuilder modifiedWithin(); DataSearchQueryBuilder negatedFile(); DataSearchQueryBuilder sharedWith(); @Override String toString(); Splittable getSimpleQuery(String field, String userEntry); static final String METADATA_VALUE; static final String METADATA_ATTRIBUTE; static final String FIELDS; static final String QUERY_STRING; static final String LESSER; static final String GREATER; static final String RANGE2; static final String WILDCARD; static final String OR_OPERATOR; static final String DATE_MODIFIED; static final String QUERY2; static final String PATH; static final String METADATA2; static final String NESTED2; static final String HAS_CHILD; static final String FILE_SIZE; static final String LABEL; static final String DATE_CREATED; static final String BOOL; }
@Test public void testTaggedWith() { when(dsf.isIncludeTrashItems()).thenReturn(false); Set<Tag> tags = new LinkedHashSet<>(); final String expectedValue = setTaggedWithQuery(tags, dsf); assertEquals("", expectedValue); Tag mock1 = mock(Tag.class); mock1.setId("id1"); mock1.setValue("tag1"); when(mock1.getId()).thenReturn("id1"); Tag mock2 = mock(Tag.class); mock1.setId("id2"); mock1.setValue("tag2"); when(mock2.getId()).thenReturn("id2"); tags.add(mock1); final String expectedValue1 = setTaggedWithQuery(tags, dsf); assertEquals("id1", expectedValue1); tags.add(mock2); final String expectedValue2 = setTaggedWithQuery(tags, dsf); assertEquals("id1,id2", expectedValue2); }