@Test
public void testWithTwoCycles()
                        throws Exception {

    GMLAppSchemaReader xsdDecoder = new GMLAppSchemaReader( null, null, schemaWithTwoCycles );
    AppSchema appSchema = xsdDecoder.extractAppSchema();
    CRSRef storageCrs = CRSManager.getCRSRef( "EPSG:4326" );
    GeometryStorageParams geometryParams = new GeometryStorageParams( storageCrs, String.valueOf( "0" ), DIM_2 );
    AppSchemaMapper mapper = new AppSchemaMapper( appSchema, false, true, geometryParams, 63, true, true, 2 );
    MappedAppSchema mappedSchema = mapper.getMappedSchema();
    Map<QName, FeatureTypeMapping> ftMappings = mappedSchema.getFtMappings();
    assertThat( ftMappings.size(), is( 1 ) );
    FeatureTypeMapping featureA = mappedSchema.getFtMapping( FEATURE_A );
    List<Mapping> mappings = featureA.getMappings();
    assertThat( mappings.size(), is( 6 ) );
    // Depth 0 - Cycle 0
    CompoundMapping featureCDepth0 = getFeatureC( mappings );
    List<Mapping> featureCDepth0Mapping = featureCDepth0.getParticles();
    assertThat( featureCDepth0Mapping.size(), is( 3 ) );
    CompoundMapping featureEDepth0 = getFeatureE( mappings );
    List<Mapping> featureEDepth0Mapping = featureEDepth0.getParticles();
    assertThat( featureEDepth0Mapping.size(), is( 3 ) );
    // Depth 1
    CompoundMapping featureDDepth1 = getFeatureD( featureCDepth0Mapping );
    List<Mapping> featureDDepth1Mapping = featureDDepth1.getParticles();
    assertThat( featureDDepth1Mapping.size(), is( 3 ) );
    CompoundMapping featureFDepth1 = getFeatureF( featureEDepth0Mapping );
    List<Mapping> featureFDepth1Mapping = featureFDepth1.getParticles();
    assertThat( featureFDepth1Mapping.size(), is( 3 ) );
    // Depth 2 - Cycle 1
    CompoundMapping featureCDepth2 = getFeatureC( mappings );
    List<Mapping> featureCDepth2Mapping = featureCDepth2.getParticles();
    assertThat( featureCDepth2Mapping.size(), is( 3 ) );
    CompoundMapping featureEDepth2 = getFeatureE( mappings );
    List<Mapping> featureEDepth2Mapping = featureEDepth2.getParticles();
    assertThat( featureEDepth2Mapping.size(), is( 3 ) );
    // Depth 3
    CompoundMapping featureDDepth3 = getFeatureD( featureCDepth2Mapping );
    List<Mapping> featureDDepth3Mapping = featureDDepth3.getParticles();
    assertThat( featureDDepth3Mapping.size(), is( 3 ) );
    CompoundMapping featureFDepth3 = getFeatureF( featureEDepth2Mapping );
    List<Mapping> featureFDepth3Mapping = featureFDepth3.getParticles();
    assertThat( featureFDepth3Mapping.size(), is( 3 ) );
    // Depth 4 - Cycle 1
    CompoundMapping featureCDepth4 = getFeatureC( featureDDepth3Mapping );
    List<Mapping> featureCDepth4Mapping = featureCDepth4.getParticles();
    assertThat( featureCDepth4Mapping.size(), is( 3 ) );
    CompoundMapping featureEDepth4 = getFeatureE( featureFDepth3Mapping );
    List<Mapping> featureEDepth4Mapping = featureEDepth4.getParticles();
    assertThat( featureEDepth4Mapping.size(), is( 3 ) );
    // Depth 5
    CompoundMapping featureDDepth5 = getFeatureD( featureCDepth4Mapping );
    List<Mapping> featureDDepth5Mapping = featureDDepth5.getParticles();
    assertThat( featureDDepth5Mapping.size(), is( 3 ) );
    CompoundMapping featureFDepth5 = getFeatureF( featureEDepth4Mapping );
    List<Mapping> featureFDepth5Mapping = featureFDepth5.getParticles();
    assertThat( featureFDepth5Mapping.size(), is( 3 ) );
    // Depth 6 - Cycle 2
    CompoundMapping featureCDepth6 = getFeatureC( featureDDepth5Mapping );
    List<Mapping> featureCDepth6Mapping = featureCDepth6.getParticles();
    assertThat( featureCDepth6Mapping.size(), is( 3 ) );
    CompoundMapping featureEDepth6 = getFeatureE( featureFDepth5Mapping );
    List<Mapping> featureEDepth6Mapping = featureEDepth6.getParticles();
    assertThat( featureEDepth6Mapping.size(), is( 3 ) );
    // Depth 7
    CompoundMapping featureDDepth7 = getFeatureD( featureCDepth6Mapping );
    List<Mapping> featureDDepth7Mapping = featureDDepth7.getParticles();
    assertThat( featureDDepth7Mapping.size(), is( 2 ) );
    CompoundMapping featureFDepth7 = getFeatureF( featureEDepth6Mapping );
    List<Mapping> featureFDepth7Mapping = featureFDepth7.getParticles();
    assertThat( featureFDepth7Mapping.size(), is( 2 ) );
    // Depth 8 - End
    assertThat( getFeatureD( featureDDepth7Mapping ), is( nullValue() ) );
    assertThat( getFeatureF( featureFDepth7Mapping ), is( nullValue() ) );
}