use of ddf.catalog.pubsub.predicate.Predicate in project ddf by codice.
the class PredicateTest method testTemporalNullOperation.
@Test
public void testTemporalNullOperation() throws Exception {
String methodName = "testTemporalNullOperation";
LOGGER.debug("*************** START: {} *****************", methodName);
MockQuery query = new MockQuery();
DatatypeFactory df = DatatypeFactory.newInstance();
XMLGregorianCalendar start = df.newXMLGregorianCalendarDate(2011, 10, 25, 0);
XMLGregorianCalendar end = df.newXMLGregorianCalendarDate(2011, 10, 27, 0);
query.addTemporalFilter(start, end, Metacard.EFFECTIVE);
SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor();
Predicate pred = (Predicate) query.getFilter().accept(visitor, null);
LOGGER.debug("Resulting Predicate: {}", pred);
Filter filter = query.getFilter();
FilterTransformer transform = new FilterTransformer();
transform.setIndentation(2);
String filterXml = transform.transform(filter);
LOGGER.debug(filterXml);
// input that passes temporal
LOGGER.debug("\npass temporal.\n");
MetacardImpl metacard = new MetacardImpl();
metacard.setCreatedDate(new Date());
metacard.setExpirationDate(new Date());
metacard.setModifiedDate(new Date());
metacard.setMetadata(TestDataLibrary.getCatAndDogEntry());
XMLGregorianCalendar cal = df.newXMLGregorianCalendarDate(2011, 10, 26, 0);
Date effectiveDate = cal.toGregorianCalendar().getTime();
metacard.setEffectiveDate(effectiveDate);
HashMap<String, Object> properties = new HashMap<>();
properties.put(PubSubConstants.HEADER_OPERATION_KEY, null);
Map<String, Object> contextualMap = constructContextualMap(metacard);
properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap);
properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard);
Event testEvent = new Event("topic", properties);
boolean b = pred.matches(testEvent);
assertTrue(b);
LOGGER.debug("*************** END: {} *****************", methodName);
}
use of ddf.catalog.pubsub.predicate.Predicate in project ddf by codice.
the class PredicateTest method testContextualQueryNullMetadata.
@Test
public void testContextualQueryNullMetadata() throws Exception {
String methodName = "testContextualQueryNullMetadata";
LOGGER.debug("*************** START: {} *****************", methodName);
String searchPhrase = "serengeti event";
MockQuery query = new MockQuery();
query.addContextualFilter(searchPhrase, null);
SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor();
Predicate predicate = (Predicate) query.getFilter().accept(visitor, null);
MetacardImpl metacard = new MetacardImpl();
metacard.setId("ABC123");
metacard.setMetadata(TestDataLibrary.getCatAndDogEntry());
HashMap<String, Object> properties = new HashMap<>();
properties.put(PubSubConstants.HEADER_ID_KEY, metacard.getId());
properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard);
properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE);
// No contextual map containing indexed metadata added to properties
Event testEvent = new Event("topic", properties);
assertFalse(predicate.matches(testEvent));
LOGGER.debug("*************** END: {} *****************", methodName);
}
Aggregations