View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.actions.testcase;
14  
15  import java.util.ArrayList;
16  import java.util.List;
17  
18  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
19  import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestStepFactory;
20  import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestStepRegistry;
21  import com.eviware.soapui.support.action.SoapUIActionMapping;
22  import com.eviware.soapui.support.action.support.DefaultActionMapping;
23  import com.eviware.soapui.support.action.support.DefaultSoapUIActionGroup;
24  
25  /***
26   * SoapUIActionGroup for WsdlTestCases, dynamically creates "Append Step" submenu contents from 
27   * the WsdlTestStepRegistry
28   * 
29   * @author ole.matzura
30   *
31   */
32  public class WsdlTestCaseAddStepSoapUIActionGroup extends DefaultSoapUIActionGroup<WsdlTestCase>
33  {
34  	public WsdlTestCaseAddStepSoapUIActionGroup( String id, String name )
35  	{
36  		super( id, name );
37  	}
38  
39  	public List<SoapUIActionMapping<WsdlTestCase>> getActionMappings( WsdlTestCase modelItem )
40  	{
41  		List<SoapUIActionMapping<WsdlTestCase>> actions = new ArrayList<SoapUIActionMapping<WsdlTestCase>>();
42  		
43  		WsdlTestStepRegistry registry = WsdlTestStepRegistry.getInstance();
44  		WsdlTestStepFactory[] factories = (WsdlTestStepFactory[]) registry.getFactories();
45  
46  		for (int c = 0; c < factories.length; c++)
47  		{
48  			WsdlTestStepFactory factory = factories[c];
49  			if (factory.canCreate())
50  			{
51  				DefaultActionMapping<WsdlTestCase> actionMapping = new DefaultActionMapping<WsdlTestCase>( AddWsdlTestStepAction.SOAPUI_ACTION_ID, null,
52  											factory.getTestStepIconPath(), false, factory );
53  				
54  				actionMapping.setName( factory.getTestStepName() );
55  				actionMapping.setDescription( factory.getTestStepDescription() );
56  				
57  				actions.add( actionMapping );
58  			}
59  		}
60  		
61  		return actions;
62  	}
63  }