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  package com.eviware.soapui.support.dnd.handlers;
13  
14  import com.eviware.soapui.SoapUI;
15  import com.eviware.soapui.impl.wsdl.actions.mockresponse.AddMockResponseToTestCaseAction;
16  import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
17  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
18  import com.eviware.soapui.support.action.SoapUIAction;
19  
20  public class MockResponseToTestCaseDropHandler extends
21  		AbstractAfterModelItemDropHandler<WsdlMockResponse, WsdlTestCase>
22  {
23  	public MockResponseToTestCaseDropHandler()
24  	{
25  		super( WsdlMockResponse.class, WsdlTestCase.class );
26  	}
27  
28  	@Override
29  	boolean canCopyAfter( WsdlMockResponse source, WsdlTestCase target )
30  	{
31  		return source.getMockOperation().getMockService().getProject() == target.getTestSuite().getProject();
32  	}
33  
34  	@Override
35  	boolean canMoveAfter( WsdlMockResponse source, WsdlTestCase target )
36  	{
37  		return canCopyAfter( source, target );
38  	}
39  
40  	@Override
41  	boolean copyAfter( WsdlMockResponse source, WsdlTestCase target )
42  	{
43  		SoapUIAction<WsdlMockResponse> action = SoapUI.getActionRegistry().getAction(
44  				AddMockResponseToTestCaseAction.SOAPUI_ACTION_ID );
45  		AddMockResponseToTestCaseAction a = ( AddMockResponseToTestCaseAction )action;
46  
47  		a.addMockResponseToTestCase( source, target, -1 );
48  		return true;
49  	}
50  
51  	@Override
52  	boolean moveAfter( WsdlMockResponse source, WsdlTestCase target )
53  	{
54  		return copyAfter( source, target );
55  	}
56  
57  	@Override
58  	String getCopyAfterInfo( WsdlMockResponse source, WsdlTestCase target )
59  	{
60  		return "Add MockResponse TestStep to TestCase [" + target.getName() + "]";
61  	}
62  
63  	@Override
64  	String getMoveAfterInfo( WsdlMockResponse source, WsdlTestCase target )
65  	{
66  		return getCopyAfterInfo( source, target );
67  	}
68  }