/** @return the expected value */ private String setMetadataValueQuery(final String givenQuery) { when(dsf.getMetadataValueQuery()).thenReturn(givenQuery); DataSearchQueryBuilder uut = new DataSearchQueryBuilder(dsf, userInfoMock); return "{\"nested\":{\"query\":" + uut.getSimpleQuery(DataSearchQueryBuilder.METADATA_VALUE, givenQuery).getPayload() + ",\"path\":\"metadata\"}}"; }
@Test public void testApplyOROperator_case2() { DataSearchQueryBuilder uut = new DataSearchQueryBuilder(dsf, userInfoMock); String searchText = "one "; final String applyOROperator = uut.applyOROperator(searchText); final String expected = "one"; assertEquals("Verify OR operator applied", expected, applyOROperator); }
/** when string contains '*' */ @Test public void testApplyImplicitAsteriskSearchText_Case2() { DataSearchQueryBuilder uut = new DataSearchQueryBuilder(dsf, userInfoMock); String searchText = "one*" + DataSearchQueryBuilder.OR_OPERATOR + "two" + DataSearchQueryBuilder.OR_OPERATOR + "three"; final String applyImplicitAsteriskSearchText = uut.applyImplicitAsteriskSearchText(searchText); assertEquals( "Verify that implicit asterisk NOT applied", searchText, applyImplicitAsteriskSearchText); }
/** when asterisks needed */ @Test public void testApplyImplicitAsteriskSearchText_Case1() { DataSearchQueryBuilder uut = new DataSearchQueryBuilder(dsf, userInfoMock); String searchText = "one" + DataSearchQueryBuilder.OR_OPERATOR + "two" + DataSearchQueryBuilder.OR_OPERATOR + "three"; final String applyImplicitAsteriskSearchText = uut.applyImplicitAsteriskSearchText(searchText); final String expected = "*one*" + DataSearchQueryBuilder.OR_OPERATOR + "*two*" + DataSearchQueryBuilder.OR_OPERATOR + "*three*"; assertEquals( "Verify application of implicit asterisk(*)", expected, applyImplicitAsteriskSearchText); }
private String setTaggedWithQuery(final Set<Tag> tags, final DiskResourceQueryTemplate drqt) { when(dsf.getTagQuery()).thenReturn(tags); DataSearchQueryBuilder uut = new DataSearchQueryBuilder(dsf, userInfoMock); return uut.taggedWith(); }
/** @return the expected value */ private String setNegatedFileQuery(final String givenSearchTerms) { when(dsf.getNegatedFileQuery()).thenReturn(givenSearchTerms); DataSearchQueryBuilder uut = new DataSearchQueryBuilder(dsf, userInfoMock); return uut.getSimpleQuery(DataSearchQueryBuilder.LABEL, givenSearchTerms).getPayload(); }