@Test public void testFactory() { assertEquals(IsInstanceOf.NAME, functionNames.get(0)); args.add(ff.literal(Object.class)); Function f = factory.function(IsInstanceOf.NAME.getFunctionName(), args, null); assertNotNull(f); try { args.add(ff.literal(Object.class)); f = factory.function(IsInstanceOf.NAME.getName(), args, null); } catch (IllegalArgumentException e) {
@Test public void testFindCategorizeFunction() throws Exception { // System.out.println(" testFindCategorizeFunction"); Literal fallback = ff2.literal("NOT_FOUND"); parameters.add(ff2.property("value")); parameters.add(ff2.literal(0)); Function fn = finder.findFunction("categorize", parameters, fallback); Object result = fn.evaluate(feature(0)); assertFalse("Could not locate 'categorize' function", result.equals(fallback.getValue())); }
@Test public void testFallback() { parameters.add(ff2.literal("abc12_67")); parameters.add(ff2.literal(".*(\\d{3})_(\\d{3})")); parameters.add(ff2.literal("first${1}_second${2}_full${0}")); parameters.add(ff2.literal("noMatch")); Function fn = finder.findFunction("stringTemplate", parameters, fallback); Object result = fn.evaluate(null); assertEquals("noMatch", result); }
@Test public void testNonSpatialFilter() { Filter filter = ff.between(ff.property("someAtt"), ff.literal(2), ff.literal(4)); SpatialIndexFeatureCollection collection = null; try { collection = new SpatialIndexFeatureCollection(delegate); } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e); } SimpleFeatureCollection sub = collection.subCollection(filter); assertEquals(3, sub.size()); }
@Test public void testConcatenate() { parameters.add(ff2.literal("123")); parameters.add(ff2.literal(".*")); parameters.add(ff2.literal("start${0}end")); Function fn = finder.findFunction("stringTemplate", parameters, fallback); Object result = fn.evaluate(null); assertEquals("start123end", result); }