use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.
the class ConfluenceSourceTest method testAttributeOverrides.
@Test
public void testAttributeOverrides() throws Exception {
QueryRequest request = new QueryRequestImpl(new QueryImpl(builder.attribute("anyText").is().like().text("searchValue"), 1, 1, new SortByImpl("title", SortOrder.DESCENDING), false, 1000));
InputStream entity = new ByteArrayInputStream(JSON_RESPONSE.getBytes(StandardCharsets.UTF_8));
when(clientResponse.getEntity()).thenReturn(entity);
when(clientResponse.getStatus()).thenReturn(Response.Status.OK.getStatusCode());
setupRegistryEntry("dateAttribute", BasicTypes.DATE_TYPE);
setupRegistryEntry("boolAttribute", BasicTypes.BOOLEAN_TYPE);
setupRegistryEntry("longAttribute", BasicTypes.LONG_TYPE);
setupRegistryEntry("intAttribute", BasicTypes.INTEGER_TYPE);
setupRegistryEntry("shortAttribute", BasicTypes.SHORT_TYPE);
setupRegistryEntry("floatAttribute", BasicTypes.FLOAT_TYPE);
setupRegistryEntry("doubleAttribute", BasicTypes.DOUBLE_TYPE);
setupRegistryEntry("binaryAttribute", BasicTypes.BINARY_TYPE);
setupRegistryEntry("badAttribute", BasicTypes.INTEGER_TYPE);
when(registry.lookup("missingAttribute")).thenReturn(Optional.empty());
Instant now = Instant.now();
List<String> additionalAttributes = new ArrayList<>();
additionalAttributes.add("attrib1=val1");
additionalAttributes.add("attrib2=val1,val2,val3");
additionalAttributes.add("dateAttribute=2018-06-28T10:44:00+07:00");
additionalAttributes.add("boolAttribute=true");
additionalAttributes.add("longAttribute=12345678900000");
additionalAttributes.add("intAttribute=1234");
additionalAttributes.add("shortAttribute=1");
additionalAttributes.add("floatAttribute=1.1");
additionalAttributes.add("doubleAttribute=1.23456");
additionalAttributes.add("binaryAttribute=binaryString");
additionalAttributes.add("badAttribute=1.23456");
additionalAttributes.add("missingAttribute=something");
confluence.setAttributeOverrides(additionalAttributes);
SourceResponse response = confluence.query(request);
assertThat(response.getHits(), is(1L));
Metacard mcard = response.getResults().get(0).getMetacard();
assertThat(mcard, notNullValue());
assertThat(mcard.getAttribute("attrib1").getValue(), is("val1"));
assertThat(mcard.getAttribute("attrib2").getValues().size(), is(3));
assertThat(mcard.getAttribute("dateAttribute").getValue(), is(DatatypeConverter.parseDateTime("2018-06-28T10:44:00+07:00").getTime()));
assertThat(mcard.getAttribute("boolAttribute").getValue(), is(true));
assertThat(mcard.getAttribute("longAttribute").getValue(), is(12345678900000L));
assertThat(mcard.getAttribute("intAttribute").getValue(), is(1234));
assertThat(mcard.getAttribute("shortAttribute").getValue(), is((short) 1));
assertThat(mcard.getAttribute("floatAttribute").getValue(), is(1.1f));
assertThat(mcard.getAttribute("doubleAttribute").getValue(), is(1.23456));
assertThat(mcard.getAttribute("binaryAttribute").getValue(), is("binaryString".getBytes(Charset.forName("UTF-8"))));
assertThat(mcard.getAttribute("badAttribute"), is(nullValue()));
assertThat(mcard.getAttribute("missingAttribute"), is(nullValue()));
}
use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.
the class ConfluenceSourceTest method testQuerySortOnNonConfluenceAttribute.
@Test
public void testQuerySortOnNonConfluenceAttribute() throws Exception {
QueryRequest request = new QueryRequestImpl(new QueryImpl(builder.attribute("anyText").is().like().text("searchValue"), 1, 1, new SortByImpl("someAttribute", SortOrder.DESCENDING), false, 1000));
InputStream entity = new ByteArrayInputStream(JSON_RESPONSE.getBytes(StandardCharsets.UTF_8));
when(clientResponse.getEntity()).thenReturn(entity);
when(clientResponse.getStatus()).thenReturn(Response.Status.OK.getStatusCode());
SourceResponse response = confluence.query(request);
assertThat(response.getHits(), is(1L));
assertThat(response.getResults().get(0).getMetacard(), notNullValue());
}
use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.
the class OpenSearchParserImplTest method populateSearchOptions.
// {@link OpenSearchParser#populateSearchOptions(WebClient, QueryRequest, Subject, List)} tests
@Test
public void populateSearchOptions() {
SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.DESCENDING);
Filter filter = mock(Filter.class);
Query query = new QueryImpl(filter, 0, 2000, sortBy, true, 30000);
QueryRequest queryRequest = new QueryRequestImpl(query);
openSearchParser.populateSearchOptions(webClient, queryRequest, null, Arrays.asList("q,src,mr,start,count,mt,dn,lat,lon,radius,bbox,polygon,dtstart,dtend,dateName,filter,sort".split(",")));
assertQueryParameterPopulated(OpenSearchConstants.COUNT);
assertQueryParameterPopulated(OpenSearchConstants.MAX_RESULTS, MAX_RESULTS);
assertQueryParameterPopulated(OpenSearchConstants.MAX_TIMEOUT, TIMEOUT);
assertQueryParameterPopulated(OpenSearchConstants.SORT, DESCENDING_TEMPORAL_SORT);
}
use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.
the class OpenSearchParserImplTest method populateSearchOptionsSortRelevance.
@Test
public void populateSearchOptionsSortRelevance() {
SortBy sortBy = new SortByImpl(Result.RELEVANCE, SortOrder.ASCENDING);
Filter filter = mock(Filter.class);
Query query = new QueryImpl(filter, 0, 2000, sortBy, true, 30000);
QueryRequest queryRequest = new QueryRequestImpl(query);
openSearchParser.populateSearchOptions(webClient, queryRequest, null, Arrays.asList("q,src,mr,start,count,mt,dn,lat,lon,radius,bbox,polygon,dtstart,dtend,dateName,filter,sort".split(",")));
assertQueryParameterPopulated(OpenSearchConstants.COUNT);
assertQueryParameterPopulated(OpenSearchConstants.MAX_RESULTS, MAX_RESULTS);
assertQueryParameterPopulated(OpenSearchConstants.MAX_TIMEOUT, TIMEOUT);
assertQueryParameterPopulated(OpenSearchConstants.SORT, "relevance:desc");
}
use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.
the class OpenSearchParserImplTest method populateSearchOptionsSortAscending.
@Test
public void populateSearchOptionsSortAscending() {
SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
Filter filter = mock(Filter.class);
Query query = new QueryImpl(filter, 0, 2000, sortBy, true, 30000);
QueryRequest queryRequest = new QueryRequestImpl(query);
openSearchParser.populateSearchOptions(webClient, queryRequest, null, Arrays.asList("q,src,mr,start,count,mt,dn,lat,lon,radius,bbox,polygon,dtstart,dtend,dateName,filter,sort".split(",")));
assertQueryParameterPopulated(OpenSearchConstants.COUNT);
assertQueryParameterPopulated(OpenSearchConstants.MAX_RESULTS, MAX_RESULTS);
assertQueryParameterPopulated(OpenSearchConstants.MAX_TIMEOUT, TIMEOUT);
assertQueryParameterPopulated(OpenSearchConstants.SORT, "date:asc");
}
Aggregations