use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class CopyFilterDelegateTest method assertFilterException.
private void assertFilterException(Filter filterIn) {
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
// the UnsupportedQueryException thrown by the FilterAdapter.
try {
fa.adapt(filterIn, delegate);
fail("Should have gotten an UnsupportedQueryException");
} catch (UnsupportedQueryException e) {
assertTrue(e.getCause() instanceof UnsupportedOperationException);
}
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class CopyFilterDelegateTest method assertFilterContentsEqual.
private void assertFilterContentsEqual(Filter filterIn, Filter filterCopy) {
FilterDelegate<String> delegate = new FilterToTextDelegate();
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
String filterInString = null;
String filterCopyString = null;
try {
filterInString = fa.adapt(filterIn, delegate);
filterCopyString = fa.adapt(filterCopy, delegate);
} catch (UnsupportedQueryException e) {
fail(e.getMessage());
}
LOGGER.debug("filterInString: {}", filterInString);
LOGGER.debug("filterCopyString: {}", filterCopyString);
assertNotNull(filterInString);
assertNotNull(filterCopyString);
assertEquals(filterInString, filterCopyString);
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class CopyFilterDelegateTest method testExcludeFilter.
@Test
public void testExcludeFilter() {
Filter filterIn = Filter.EXCLUDE;
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
Filter filterCopy = null;
try {
filterCopy = fa.adapt(filterIn, delegate);
} catch (UnsupportedQueryException e) {
fail(e.getMessage());
}
assertNotNull(filterCopy);
assertSame(filterIn, filterCopy);
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class CopyFilterDelegateTest method testIncludeFilter.
@Test
public void testIncludeFilter() {
Filter filterIn = Filter.INCLUDE;
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
Filter filterCopy = null;
try {
filterCopy = fa.adapt(filterIn, delegate);
} catch (UnsupportedQueryException e) {
fail(e.getMessage());
}
assertNotNull(filterCopy);
assertSame(filterIn, filterCopy);
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class CatalogFrameworkQueryTest method testAfterQuery.
@Test
public void testAfterQuery() throws Exception {
Calendar afterCal = Calendar.getInstance();
Calendar card1Exp = Calendar.getInstance();
card1Exp.add(Calendar.YEAR, 1);
Calendar card2Exp = Calendar.getInstance();
card2Exp.add(Calendar.YEAR, 3);
List<Metacard> metacards = new ArrayList<Metacard>();
MetacardImpl newCard1 = new MetacardImpl();
newCard1.setId(null);
newCard1.setExpirationDate(card1Exp.getTime());
metacards.add(newCard1);
MetacardImpl newCard2 = new MetacardImpl();
newCard2.setId(null);
newCard2.setExpirationDate(card2Exp.getTime());
metacards.add(newCard2);
String mcId1 = null;
String mcId2 = null;
CreateResponse createResponse = null;
createResponse = framework.create(new CreateRequestImpl(metacards, null));
assertEquals(createResponse.getCreatedMetacards().size(), metacards.size());
for (Metacard curCard : createResponse.getCreatedMetacards()) {
if (curCard.getExpirationDate().equals(card1Exp.getTime())) {
mcId1 = curCard.getId();
} else {
mcId2 = curCard.getId();
}
assertNotNull(curCard.getId());
}
FilterFactory filterFactory = new FilterFactoryImpl();
Instant afterInstant = new DefaultInstant(new DefaultPosition(afterCal.getTime()));
QueryImpl query = new QueryImpl(filterFactory.after(filterFactory.property(Metacard.EXPIRATION), filterFactory.literal(afterInstant)));
QueryRequest queryReq = new QueryRequestImpl(query, false);
try {
QueryResponse response = framework.query(queryReq);
LOGGER.info("Response:{}", response);
assertEquals("Expecting return 2 results.", 2, response.getHits());
} catch (UnsupportedQueryException e) {
LOGGER.error("Failure!!!", e);
fail();
} catch (FederationException e) {
fail();
}
afterInstant = new DefaultInstant(new DefaultPosition(card1Exp.getTime()));
query = new QueryImpl(filterFactory.after(filterFactory.property(Metacard.EXPIRATION), filterFactory.literal(afterInstant)));
queryReq = new QueryRequestImpl(query, false);
try {
QueryResponse response = framework.query(queryReq);
assertEquals("After filter should return 1 result", 1, response.getHits());
assertEquals("After filter should return metacard[" + mcId2 + "]", mcId2, response.getResults().get(0).getMetacard().getId());
} catch (UnsupportedQueryException e) {
fail();
} catch (FederationException e) {
fail();
}
afterInstant = new DefaultInstant(new DefaultPosition(card2Exp.getTime()));
query = new QueryImpl(filterFactory.after(filterFactory.property(Metacard.EXPIRATION), filterFactory.literal(afterInstant)));
queryReq = new QueryRequestImpl(query, false);
try {
QueryResponse response = framework.query(queryReq);
assertEquals("After filter should return 0 results.", 0, response.getHits());
} catch (UnsupportedQueryException e) {
fail();
} catch (FederationException e) {
fail();
}
}
Aggregations