View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.teststeps.actions;
14  
15  import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
16  import com.eviware.soapui.support.action.SoapUIActionMapping;
17  import com.eviware.soapui.support.action.support.DefaultActionMapping;
18  import com.eviware.soapui.support.action.support.DefaultSoapUIActionGroup;
19  import com.eviware.soapui.support.action.support.SoapUIActionMappingList;
20  
21  /***
22   * SoapUIActionGroup for a WsdlMessageAssertion
23   * 
24   * @author ole.matzura
25   */
26  
27  public class WsdlMessageAssertionSoapUIActionGroup extends DefaultSoapUIActionGroup<WsdlMessageAssertion>
28  {
29  	public WsdlMessageAssertionSoapUIActionGroup( String id, String name )
30  	{
31  		super( id, name );
32  	}
33  
34  	@Override
35  	public SoapUIActionMappingList<WsdlMessageAssertion> getActionMappings( WsdlMessageAssertion modelItem )
36  	{
37  		SoapUIActionMappingList<WsdlMessageAssertion> actions = super.getActionMappings( modelItem );
38  		SoapUIActionMappingList<WsdlMessageAssertion> result = new SoapUIActionMappingList<WsdlMessageAssertion>( actions );
39  
40  		if( modelItem.isConfigurable() )
41  		{
42  			DefaultActionMapping<WsdlMessageAssertion> actionMapping = new DefaultActionMapping<WsdlMessageAssertion>(
43  					ConfigureAssertionAction.SOAPUI_ACTION_ID, "ENTER", null, true, null );
44  
45  			actionMapping.setName( "Configure" );
46  			actionMapping.setDescription( "Configures this Assertion" );
47  
48  			result.add( 0, actionMapping );
49  		}
50  
51  		if( modelItem.isClonable() )
52  		{
53  			DefaultActionMapping<WsdlMessageAssertion> actionMapping = new DefaultActionMapping<WsdlMessageAssertion>(
54  					CloneAssertionAction.SOAPUI_ACTION_ID, "F9", null, true, null );
55  
56  			result.add( 1, actionMapping );
57  		}
58  
59  		// result.add( 1, SeperatorAction.getDefaultMapping() );
60  
61  		SoapUIActionMapping<WsdlMessageAssertion> toggleDisabledActionMapping = null;
62  		for( int c = 0; c < result.size(); c++ )
63  		{
64  			if( result.get( c ).getActionId().equals( ToggleDisableAssertionAction.SOAPUI_ACTION_ID ) )
65  			{
66  				toggleDisabledActionMapping = result.get( c );
67  				break;
68  			}
69  		}
70  
71  		if( toggleDisabledActionMapping != null )
72  		{
73  			if( modelItem.isDisabled() )
74  			{
75  				toggleDisabledActionMapping.setName( "Enable" );
76  				toggleDisabledActionMapping.setDescription( "Enable this Assertion" );
77  			}
78  			else
79  			{
80  				toggleDisabledActionMapping.setName( "Disable" );
81  				toggleDisabledActionMapping.setDescription( "Disables this Assertion" );
82  			}
83  		}
84  
85  		return result;
86  	}
87  }