View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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 com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
16  import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestStepFactory;
17  import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestStepRegistry;
18  import com.eviware.soapui.support.action.support.DefaultActionMapping;
19  import com.eviware.soapui.support.action.support.DefaultSoapUIActionGroup;
20  import com.eviware.soapui.support.action.support.SoapUIActionMappingList;
21  
22  /***
23   * SoapUIActionGroup for WsdlTestCases, dynamically creates "Append Step" submenu contents from 
24   * the WsdlTestStepRegistry
25   * 
26   * @author ole.matzura
27   */
28  
29  public class WsdlTestCaseAddStepSoapUIActionGroup extends DefaultSoapUIActionGroup<WsdlTestCase>
30  {
31  	public WsdlTestCaseAddStepSoapUIActionGroup( String id, String name )
32  	{
33  		super( id, name );
34  	}
35  
36  	public SoapUIActionMappingList<WsdlTestCase> getActionMappings( WsdlTestCase modelItem )
37  	{
38  		SoapUIActionMappingList<WsdlTestCase> actions = new SoapUIActionMappingList<WsdlTestCase>();
39  		
40  		WsdlTestStepRegistry registry = WsdlTestStepRegistry.getInstance();
41  		WsdlTestStepFactory[] factories = (WsdlTestStepFactory[]) registry.getFactories();
42  
43  		for (int c = 0; c < factories.length; c++)
44  		{
45  			WsdlTestStepFactory factory = factories[c];
46  			if (factory.canCreate())
47  			{
48  				DefaultActionMapping<WsdlTestCase> actionMapping = new DefaultActionMapping<WsdlTestCase>( AddWsdlTestStepAction.SOAPUI_ACTION_ID, null,
49  											factory.getTestStepIconPath(), false, factory );
50  				
51  				actionMapping.setName( factory.getTestStepName() );
52  				actionMapping.setDescription( factory.getTestStepDescription() );
53  				
54  				actions.add( actionMapping );
55  			}
56  		}
57  		
58  		return actions;
59  	}
60  }