use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class SolrProviderCreate method testCreateOperation.
/**
* Testing that if we create a record, it is truly ingested and we can retrieve all the fields we
* intend to be retrievable.
*/
@Test
public void testCreateOperation() throws IngestException, UnsupportedQueryException {
deleteAll(provider);
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
create(metacard, provider);
FilterFactory filterFactory = new FilterFactoryImpl();
// SIMPLE TITLE SEARCH
Filter filter = filterFactory.like(filterFactory.property(Metacard.TITLE), MockMetacard.DEFAULT_TITLE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false);
QueryImpl query = new QueryImpl(filter);
query.setStartIndex(1);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
List<Result> results = sourceResponse.getResults();
Metacard mResult = results.get(0).getMetacard();
assertEquals(1, results.size());
assertNotNull(mResult.getId());
assertEquals(MockMetacard.DEFAULT_TITLE, mResult.getTitle());
assertEquals(MockMetacard.DEFAULT_LOCATION, mResult.getLocation());
assertEquals(MockMetacard.DEFAULT_TYPE, mResult.getContentTypeName());
assertEquals(MockMetacard.DEFAULT_VERSION, mResult.getContentTypeVersion());
assertNotNull(mResult.getMetadata());
assertThat(mResult.getMetadata(), containsString("<title>Flagstaff Chamber of Commerce</title>"));
assertTrue(!mResult.getMetadata().isEmpty());
assertFalse(mResult.getCreatedDate().after(new Date()));
assertFalse(mResult.getModifiedDate().after(new Date()));
assertEquals(metacard.getEffectiveDate(), mResult.getEffectiveDate());
assertEquals(metacard.getExpirationDate(), mResult.getExpirationDate());
assertTrue(Arrays.equals(metacard.getThumbnail(), mResult.getThumbnail()));
assertEquals(metacard.getLocation(), mResult.getLocation());
assertEquals(MASKED_ID, mResult.getSourceId());
// --- Simple KEYWORD SEARCH
filter = filterFactory.like(filterFactory.property(Metacard.METADATA), MockMetacard.DEFAULT_TITLE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false);
query = new QueryImpl(filter);
query.setStartIndex(1);
sourceResponse = provider.query(new QueryRequestImpl(query));
results = sourceResponse.getResults();
mResult = results.get(0).getMetacard();
assertEquals(1, results.size());
assertNotNull(mResult.getId());
assertEquals(MockMetacard.DEFAULT_TITLE, mResult.getTitle());
assertEquals(MockMetacard.DEFAULT_LOCATION, mResult.getLocation());
assertEquals(MockMetacard.DEFAULT_TYPE, mResult.getContentTypeName());
assertEquals(MockMetacard.DEFAULT_VERSION, mResult.getContentTypeVersion());
assertNotNull(mResult.getMetadata());
assertTrue(!mResult.getMetadata().isEmpty());
assertFalse(mResult.getCreatedDate().after(new Date()));
assertFalse(mResult.getModifiedDate().after(new Date()));
assertEquals(metacard.getEffectiveDate(), mResult.getEffectiveDate());
assertEquals(metacard.getExpirationDate(), mResult.getExpirationDate());
assertTrue(Arrays.equals(metacard.getThumbnail(), mResult.getThumbnail()));
assertEquals(metacard.getLocation(), mResult.getLocation());
assertEquals(MASKED_ID, mResult.getSourceId());
}
use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class SourceIdFilterVisitorTest method testVisitorContainsSourceIds.
@Test
public void testVisitorContainsSourceIds() {
Filter filter = buildFilter(SOURCE_IDS);
filter.accept(sourceIdFilter, new FilterFactoryImpl());
List<String> result = sourceIdFilter.getSourceIds();
assertThat(result, containsInAnyOrder(SOURCE_IDS.toArray()));
}
use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class TestQueryImpl method testSetFilterWithNullFilter.
@Test(expected = IllegalArgumentException.class)
public void testSetFilterWithNullFilter() {
FilterFactory filterFactory = new FilterFactoryImpl();
// Dummy filter copied from another test
Filter filter1 = filterFactory.like(filterFactory.property(Metacard.METADATA), "million", DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, "^", false);
Filter filter2 = null;
QueryImpl qi = new QueryImpl(filter1);
assertEquals(filter1, qi.getFilter());
qi.setFilter(filter2);
}
use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class SolrProviderTest method testCreateOperation.
/**
* Testing that if we create a record, it is truly ingested and we can retrieve all the fields
* we intend to be retrievable.
*
* @throws IngestException
* @throws UnsupportedQueryException
*/
@Test
public void testCreateOperation() throws IngestException, UnsupportedQueryException {
deleteAllIn(provider);
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
create(metacard);
FilterFactory filterFactory = new FilterFactoryImpl();
// SIMPLE TITLE SEARCH
Filter filter = filterFactory.like(filterFactory.property(Metacard.TITLE), MockMetacard.DEFAULT_TITLE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false);
QueryImpl query = new QueryImpl(filter);
query.setStartIndex(1);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
List<Result> results = sourceResponse.getResults();
Metacard mResult = results.get(0).getMetacard();
assertEquals(1, results.size());
assertNotNull(mResult.getId());
assertEquals(MockMetacard.DEFAULT_TITLE, mResult.getTitle());
assertEquals(MockMetacard.DEFAULT_LOCATION, mResult.getLocation());
assertEquals(MockMetacard.DEFAULT_TYPE, mResult.getContentTypeName());
assertEquals(MockMetacard.DEFAULT_VERSION, mResult.getContentTypeVersion());
assertNotNull(mResult.getMetadata());
assertThat(mResult.getMetadata(), containsString("<title>Flagstaff Chamber of Commerce</title>"));
assertTrue(!mResult.getMetadata().isEmpty());
assertFalse(mResult.getCreatedDate().after(new Date()));
assertFalse(mResult.getModifiedDate().after(new Date()));
assertEquals(metacard.getEffectiveDate(), mResult.getEffectiveDate());
assertEquals(metacard.getExpirationDate(), mResult.getExpirationDate());
assertTrue(Arrays.equals(metacard.getThumbnail(), mResult.getThumbnail()));
assertEquals(metacard.getLocation(), mResult.getLocation());
assertEquals(MASKED_ID, mResult.getSourceId());
// --- Simple KEYWORD SEARCH
filter = filterFactory.like(filterFactory.property(Metacard.METADATA), MockMetacard.DEFAULT_TITLE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false);
query = new QueryImpl(filter);
query.setStartIndex(1);
sourceResponse = provider.query(new QueryRequestImpl(query));
results = sourceResponse.getResults();
mResult = results.get(0).getMetacard();
assertEquals(1, results.size());
assertNotNull(mResult.getId());
assertEquals(MockMetacard.DEFAULT_TITLE, mResult.getTitle());
assertEquals(MockMetacard.DEFAULT_LOCATION, mResult.getLocation());
assertEquals(MockMetacard.DEFAULT_TYPE, mResult.getContentTypeName());
assertEquals(MockMetacard.DEFAULT_VERSION, mResult.getContentTypeVersion());
assertNotNull(mResult.getMetadata());
assertTrue(!mResult.getMetadata().isEmpty());
assertFalse(mResult.getCreatedDate().after(new Date()));
assertFalse(mResult.getModifiedDate().after(new Date()));
assertEquals(metacard.getEffectiveDate(), mResult.getEffectiveDate());
assertEquals(metacard.getExpirationDate(), mResult.getExpirationDate());
assertTrue(Arrays.equals(metacard.getThumbnail(), mResult.getThumbnail()));
assertEquals(metacard.getLocation(), mResult.getLocation());
assertEquals(MASKED_ID, mResult.getSourceId());
}
use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class SolrProviderTest method testTemporalDuring.
@Test
public void testTemporalDuring() throws Exception {
deleteAllIn(provider);
Metacard metacard = new MockMetacard(Library.getFlagstaffRecord());
List<Metacard> list = Arrays.asList(metacard);
/** CREATE **/
create(list);
/** TEMPORAL QUERY - DURING FILTER (Period) - AKA ABSOLUTE **/
FilterFactory filterFactory = new FilterFactoryImpl();
int minutes = 3;
DateTime startDT = new DateTime().plusMinutes(ALL_RESULTS * minutes);
DateTime endDT = new DateTime();
CommonQueryBuilder queryBuilder = new CommonQueryBuilder();
QueryImpl query = queryBuilder.during(Metacard.MODIFIED, startDT.toDate(), endDT.toDate());
query.setStartIndex(1);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(1, sourceResponse.getResults().size());
for (Result content : sourceResponse.getResults()) {
String term = FLAGSTAFF_QUERY_PHRASE;
LOGGER.debug("RESULT returned: {}", content);
String metadata = content.getMetacard().getMetadata();
assertTrue("Testing if contents has term [" + term + "]", ALL_RESULTS != metadata.indexOf(term));
}
/** TEMPORAL QUERY - DURING FILTER (Duration) - AKA RELATIVE **/
DefaultPeriodDuration duration = new DefaultPeriodDuration(minutes * MINUTES_IN_MILLISECONDS);
Filter filter = filterFactory.during(filterFactory.property(Metacard.MODIFIED), filterFactory.literal(duration));
query = new QueryImpl(filter);
sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(1, sourceResponse.getResults().size());
for (Result content : sourceResponse.getResults()) {
String term = FLAGSTAFF_QUERY_PHRASE;
LOGGER.debug("RESULT returned: {}", content);
String metadata = content.getMetacard().getMetadata();
assertTrue("Testing if contents has term [" + term + "]", ALL_RESULTS != metadata.indexOf(term));
}
provider.isAvailable();
}
Aggregations