1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.propertyexpansion;
14
15 import com.eviware.soapui.impl.wsdl.teststeps.TestRequest;
16 import com.eviware.soapui.model.ModelItem;
17 import com.eviware.soapui.model.mock.MockResponse;
18 import com.eviware.soapui.model.mock.MockService;
19 import com.eviware.soapui.model.project.Project;
20 import com.eviware.soapui.model.testsuite.TestCase;
21 import com.eviware.soapui.model.testsuite.TestProperty;
22 import com.eviware.soapui.model.testsuite.TestStep;
23 import com.eviware.soapui.model.testsuite.TestSuite;
24 import com.eviware.soapui.support.StringUtils;
25
26 public class PropertyExpansionImpl implements PropertyExpansion
27 {
28 private String xpath;
29 private TestProperty property;
30 private String containerInfo;
31
32 public PropertyExpansionImpl( TestProperty property, String xpath )
33 {
34 this.property = property;
35 this.xpath = xpath;
36
37 containerInfo = property.getName();
38 if( property.getModelItem() != null )
39 containerInfo += " in " + property.getModelItem().getName();
40 }
41
42 public TestProperty getProperty()
43 {
44 return property;
45 }
46
47 public String toString()
48 {
49 StringBuffer result = new StringBuffer();
50 result.append( "${" );
51
52 ModelItem modelItem = property.getModelItem();
53
54 if( modelItem instanceof Project )
55 result.append( PropertyExpansionImpl.PROJECT_REFERENCE );
56 else if( modelItem instanceof TestSuite )
57 result.append( PropertyExpansionImpl.TESTSUITE_REFERENCE );
58 else if( modelItem instanceof TestCase )
59 result.append( PropertyExpansionImpl.TESTCASE_REFERENCE );
60 else if( modelItem instanceof MockService )
61 result.append( PropertyExpansionImpl.MOCKSERVICE_REFERENCE );
62 else if( modelItem instanceof MockResponse )
63 result.append( PropertyExpansionImpl.MOCKRESPONSE_REFERENCE );
64 else if( modelItem instanceof TestStep )
65 result.append( modelItem.getName() ).append( PROPERTY_SEPARATOR );
66 else if( modelItem instanceof TestRequest )
67 result.append( ( ( TestRequest )modelItem ).getTestStep().getName() ).append( PROPERTY_SEPARATOR );
68
69 result.append( property.getName() );
70 if( StringUtils.hasContent( xpath ) )
71 result.append( PROPERTY_SEPARATOR ).append( xpath );
72
73 result.append( '}' );
74
75 return result.toString();
76 }
77
78 public String getXPath()
79 {
80 return xpath;
81 }
82
83 public String getContainerInfo()
84 {
85 return containerInfo;
86 }
87
88 public void setContainerInfo( String containerInfo )
89 {
90 this.containerInfo = containerInfo;
91 }
92
93 protected void setProperty( TestProperty property )
94 {
95 this.property = property;
96 }
97
98 protected void setXPath( String xpath )
99 {
100 this.xpath = xpath;
101 }
102 }