/** * Implementation for tests of fid -> fid unmapping. * * @param idExpression * @throws Exception */ private void checkUnrollIdExpression(Expression idExpression) throws Exception { AttributeMapping featureMapping = null; Name featurePath = mapping.getTargetFeature().getName(); QName featureName = Types.toQName(featurePath); for (Iterator it = mapping.getAttributeMappings().iterator(); it.hasNext(); ) { AttributeMapping attMapping = (AttributeMapping) it.next(); StepList targetXPath = attMapping.getTargetXPath(); if (targetXPath.size() > 1) { continue; } Step step = (Step) targetXPath.get(0); if (featureName.equals(step.getName())) { featureMapping = attMapping; break; } } featureMapping.setIdentifierExpression(idExpression); this.visitor = new UnmappingFilterVisitor(this.mapping); // retrieve a single sample feature Feature sourceFeature = DataUtilities.first(mapping.getSource().getFeatures()); String fid = sourceFeature.getIdentifier().toString(); Id fidFilter = ff.id(Collections.singleton(ff.featureId(fid))); Filter unrolled = (Filter) fidFilter.accept(visitor, null); assertNotNull(unrolled); assertTrue(unrolled instanceof Id); FeatureCollection<SimpleFeatureType, SimpleFeature> results = mapping.getSource().getFeatures(unrolled); assertEquals(1, getCount(results)); SimpleFeature unmappedFeature = DataUtilities.first(results); assertEquals(fid, unmappedFeature.getID()); }