Search in sources :

Example 91 with QueryResponse

use of ddf.catalog.operation.QueryResponse in project ddf by codice.

the class GazetteerQueryCatalogTest method testQueryInvalidStringAttributeOnMetacard.

@Test
public void testQueryInvalidStringAttributeOnMetacard() throws Exception {
    Metacard metacard = generateGeoNamesMetacard();
    metacard.setAttribute(new AttributeImpl(Core.TITLE, 1L));
    QueryResponse queryResponse = generateQueryResponseFromMetacard(metacard);
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
    List<GeoEntry> geoEntryList = queryCatalog.query(QUERY_STRING, 1);
    GeoEntry geoEntry = geoEntryList.get(0);
    assertThat(geoEntry.getName(), nullValue());
}
Also used : Metacard(ddf.catalog.data.Metacard) GeoEntry(org.codice.ddf.spatial.geocoding.GeoEntry) QueryRequest(ddf.catalog.operation.QueryRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) QueryResponse(ddf.catalog.operation.QueryResponse) Test(org.junit.Test)

Example 92 with QueryResponse

use of ddf.catalog.operation.QueryResponse in project ddf by codice.

the class GazetteerQueryCatalogTest method testQueryNoCountryCodeOnMetacard.

@Test
public void testQueryNoCountryCodeOnMetacard() throws Exception {
    Metacard metacard = generateGeoNamesMetacard();
    metacard.setAttribute(new AttributeImpl(Location.COUNTRY_CODE, ""));
    QueryResponse queryResponse = generateQueryResponseFromMetacard(metacard);
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
    List<GeoEntry> geoEntryList = queryCatalog.query(QUERY_STRING, 1);
    assertThat(geoEntryList.size(), is(1));
    GeoEntry geoEntry = geoEntryList.get(0);
    assertThat(geoEntry.getCountryCode(), nullValue());
}
Also used : Metacard(ddf.catalog.data.Metacard) GeoEntry(org.codice.ddf.spatial.geocoding.GeoEntry) QueryRequest(ddf.catalog.operation.QueryRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) QueryResponse(ddf.catalog.operation.QueryResponse) Test(org.junit.Test)

Example 93 with QueryResponse

use of ddf.catalog.operation.QueryResponse in project ddf by codice.

the class GazetteerQueryCatalogTest method testQueryInvalidLocationOnMetacard.

@Test
public void testQueryInvalidLocationOnMetacard() throws Exception {
    Metacard metacard = generateGeoNamesMetacard();
    metacard.setAttribute(new AttributeImpl(Core.LOCATION, BAD_WKT));
    QueryResponse queryResponse = generateQueryResponseFromMetacard(metacard);
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
    List<GeoEntry> geoEntryList = queryCatalog.query(QUERY_STRING, 1);
    assertThat(geoEntryList.size(), is(1));
    GeoEntry geoEntry = geoEntryList.get(0);
    assertThat(geoEntry.getLatitude(), nullValue());
    assertThat(geoEntry.getLongitude(), nullValue());
}
Also used : Metacard(ddf.catalog.data.Metacard) GeoEntry(org.codice.ddf.spatial.geocoding.GeoEntry) QueryRequest(ddf.catalog.operation.QueryRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) QueryResponse(ddf.catalog.operation.QueryResponse) Test(org.junit.Test)

Example 94 with QueryResponse

use of ddf.catalog.operation.QueryResponse in project ddf by codice.

the class GazetteerQueryCatalogTest method testGetNearestCitiesInvalidLocation.

@Test
public void testGetNearestCitiesInvalidLocation() throws Exception {
    Metacard metacard = generateGeoNamesMetacard();
    metacard.setAttribute(new AttributeImpl(Core.LOCATION, BAD_WKT));
    QueryResponse queryResponse = generateQueryResponseFromMetacard(metacard);
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
    List<NearbyLocation> nearbyLocations = queryCatalog.getNearestCities(NEAR_BOSTON_WKT, RADIUS_IN_KM, MAX_RESULTS);
    assertThat(nearbyLocations.size(), is(0));
}
Also used : Metacard(ddf.catalog.data.Metacard) QueryRequest(ddf.catalog.operation.QueryRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) QueryResponse(ddf.catalog.operation.QueryResponse) NearbyLocation(org.codice.ddf.spatial.geocoding.context.NearbyLocation) Test(org.junit.Test)

Example 95 with QueryResponse

use of ddf.catalog.operation.QueryResponse in project ddf by codice.

the class GazetteerQueryCatalogTest method testGetNearestCitiesMissingTitle.

@Test
public void testGetNearestCitiesMissingTitle() throws Exception {
    Metacard metacard = generateGeoNamesMetacard();
    metacard.setAttribute(new AttributeImpl(Core.TITLE, ""));
    QueryResponse queryResponse = generateQueryResponseFromMetacard(metacard);
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
    List<NearbyLocation> nearbyLocations = queryCatalog.getNearestCities(NEAR_BOSTON_WKT, RADIUS_IN_KM, MAX_RESULTS);
    assertThat(nearbyLocations.size(), is(0));
}
Also used : Metacard(ddf.catalog.data.Metacard) QueryRequest(ddf.catalog.operation.QueryRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) QueryResponse(ddf.catalog.operation.QueryResponse) NearbyLocation(org.codice.ddf.spatial.geocoding.context.NearbyLocation) Test(org.junit.Test)

Aggregations

QueryResponse (ddf.catalog.operation.QueryResponse)187 QueryRequest (ddf.catalog.operation.QueryRequest)130 Test (org.junit.Test)113 Metacard (ddf.catalog.data.Metacard)91 Result (ddf.catalog.data.Result)85 ArrayList (java.util.ArrayList)73 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)70 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)55 QueryImpl (ddf.catalog.operation.impl.QueryImpl)48 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)43 FederationException (ddf.catalog.federation.FederationException)40 ResultImpl (ddf.catalog.data.impl.ResultImpl)39 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)39 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)33 Filter (org.opengis.filter.Filter)33 HashMap (java.util.HashMap)31 Serializable (java.io.Serializable)30 Source (ddf.catalog.source.Source)28 HashSet (java.util.HashSet)28 CatalogFramework (ddf.catalog.CatalogFramework)26