/**
   * 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());
  }
 /**
  * Find the source expression if the step is a client property.
  *
  * @param nextRootStep the step
  * @param fMapping feature type mapping to get namespaces from
  * @param mapping attribute mapping
  * @param targetXPath the full target xpath
  * @return
  */
 private Expression getClientPropertyExpression(AttributeMapping mapping, Step lastStep) {
   if (lastStep.isXmlAttribute()) {
     Map<Name, Expression> clientProperties = mapping.getClientProperties();
     QName lastStepQName = lastStep.getName();
     Name lastStepName;
     if (lastStepQName.getPrefix() != null
         && lastStepQName.getPrefix().length() > 0
         && (lastStepQName.getNamespaceURI() == null
             || lastStepQName.getNamespaceURI().length() == 0)) {
       String prefix = lastStepQName.getPrefix();
       String uri = namespaceSupport.getURI(prefix);
       lastStepName = Types.typeName(uri, lastStepQName.getLocalPart());
     } else {
       lastStepName = Types.toTypeName(lastStepQName);
     }
     if (clientProperties.containsKey(lastStepName)) {
       // end NC - added
       return (Expression) clientProperties.get(lastStepName);
     }
   }
   return null;
 }