Commit c6a33e93 authored by David Trachtenherz's avatar David Trachtenherz
Browse files

Test model for SubComponentIterator removed

refs 779
parent 5fe5b717
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package test.org.fortiss.af3.component.model;
import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createComponentAndAttach;
import java.util.ArrayList;
import java.util.List;
import org.fortiss.af3.component.model.Component;
/**
*
* @author trachtenherz
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 1CF7592EE2076B9088748D4930614043
*/
public class SubComponentIteratorTestModel extends ComponentTestModelBase {
/**
* Number of sub-components to be created for each component
*
* @see #subComponents
*/
public static final int SUB_COMP_NUMBER = 3;
/**
* Number of sub-components hierarchy levels to be created.
*
* @see #subComponents
*/
public static final int SUB_COMP_DEPTH = 4;
/** Sub-components of {@link ComponentTestModelBase#rootComponent}. */
public List<Component> subComponents = new ArrayList<Component>();
/** Default constructor calling the super-class constructor. */
public SubComponentIteratorTestModel() {
super();
}
/** {@inheritDoc} */
@Override
public void setupModel() {
super.setupModel();
createComponents();
}
/** Creates the components. */
private void createComponents() {
// Create components
rootComponent.setName("Root");
createSubComponents(rootComponent, 1);
}
/**
* Creates {@link #SUB_COMP_NUMBER} sub-components for {@code parent} and recurses till depth
* given by {@link #SUB_COMP_DEPTH}.
* Thus, a component structure tree with depth {@link #SUB_COMP_DEPTH} and child number
* {@link #SUB_COMP_NUMBER} for each internal node is created.
*/
private void createSubComponents(Component parent, int depth) {
String parentName = parent.getName();
for(int i = 0; i < SUB_COMP_NUMBER; ++i) {
Component newSubComp = createComponentAndAttach(parent, parentName + i, "", true);
if(depth < SUB_COMP_DEPTH) {
createSubComponents(newSubComp, depth + 1);
}
subComponents.add(newSubComp);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment