Changeset 1993 for trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java
- Timestamp:
- 07/08/15 13:09:44 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java
r1988 r1993 38 38 public class SimpleSOAPEventType implements IEventType { 39 39 40 /** 41 * <p> 42 * Defines if this event represents an request or an response. 43 * </p> 44 * 45 * @author Steffen Herbold 46 */ 47 public enum CallType { 48 REQUEST, RESPONSE 49 } 50 40 51 /** */ 41 52 private static final long serialVersionUID = 1L; … … 65 76 /** 66 77 * <p> 67 * the body of the SOAP request; storage as serialized XML string to allow object serialization 68 * </p> 69 */ 70 private final String soapRequestBody; 71 72 /** 73 * TODO 74 */ 75 private final EqualSOAPDataMap equalRequestsMap; 78 * the body of the SOAP message; storage as serialized XML string to allow object serialization 79 * </p> 80 */ 81 private final String soapMsgBody; 82 83 /** 84 * <p> 85 * defines whether this event represents a request or a response 86 * </p> 87 */ 88 private final CallType callType; 89 90 /** 91 * reference to the {@link EqualSOAPDataMap} associated with the sequence this event belongs to. 92 */ 93 private final EqualSOAPDataMap equalBodyMap; 76 94 77 95 /** … … 84 102 String serviceName, 85 103 String clientName, 86 Element soap RequestBody)104 Element soapMsgBody) 87 105 { 88 this(calledMethod, serviceName, clientName, soap RequestBody, null);89 } 90 91 /** 92 * <p> 93 * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 106 this(calledMethod, serviceName, clientName, soapMsgBody, null, CallType.REQUEST); 107 } 108 109 /** 110 * <p> 111 * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 94 112 * </p> 95 113 * … … 98 116 String serviceName, 99 117 String clientName, 100 Element soap RequestBody,118 Element soapMsgBody, 101 119 EqualSOAPDataMap equalRequestsMap) 120 { 121 this(calledMethod, serviceName, clientName, soapMsgBody, equalRequestsMap, 122 CallType.REQUEST); 123 } 124 125 /** 126 * <p> 127 * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 128 * </p> 129 * 130 */ 131 public SimpleSOAPEventType(String calledMethod, 132 String serviceName, 133 String clientName, 134 Element soapMsgBody, 135 EqualSOAPDataMap equalRequestsMap, 136 CallType callType) 102 137 { 103 138 if (calledMethod == null) { … … 113 148 this.serviceName = serviceName; 114 149 this.clientName = clientName; 115 this.soapRequestBody = SOAPUtils.getSerialization(soapRequestBody); 116 this.equalRequestsMap = equalRequestsMap; 117 if( equalRequestsMap!=null ) { 118 equalRequestsMap.add(this, this.soapRequestBody); 150 this.equalBodyMap = equalRequestsMap; 151 this.soapMsgBody = SOAPUtils.getSerialization(soapMsgBody); 152 this.callType = callType; 153 154 // this must be the last part of the constructor and only be called after all variables are 155 // initialized 156 if (equalRequestsMap != null) { 157 equalRequestsMap.add(this, this.soapMsgBody); 119 158 } 120 159 } … … 161 200 * @return body of the SOAP request 162 201 */ 163 public Element getSoapRequestBody() { 164 return createDOMElement(soapRequestBody); 165 } 166 167 /** 168 * <p> 169 * returns a randomly draw request body for the called method using {@link EqualSOAPDataMap#getRandom(SimpleSOAPEventType)} 170 * </p> 171 * 202 public Element getSoapMsgBody() { 203 return createDOMElement(soapMsgBody); 204 } 205 206 /** 207 * <p> 208 * returns a randomly draw request body for the called method using 209 * {@link EqualSOAPDataMap#getRandom(SimpleSOAPEventType)} 210 * </p> 211 * 172 212 * @return randomly drawn body of the SOAP request 173 213 */ 174 public Element getRandomSoapRequestBody() { 175 if( equalRequestsMap==null ) { 176 throw new RuntimeException("cannot use random mode is no request map is available; different data missing"); 177 } 178 return createDOMElement(equalRequestsMap.getRandom(this)); 179 } 180 214 public Element getRandomSoapMsgBody() { 215 if (equalBodyMap == null) { 216 throw new RuntimeException( 217 "cannot use random mode is no request map is available; different data missing"); 218 } 219 return createDOMElement(equalBodyMap.getRandom(this)); 220 } 221 222 /** 223 * <p> 224 * returns the {@link EqualSOAPDataMap} associated with this event 225 * </p> 226 * 227 * @return the {@link EqualSOAPDataMap} 228 */ 181 229 public EqualSOAPDataMap getEqualSOAPDataMap() { 182 return equalRequestsMap; 230 return equalBodyMap; 231 } 232 233 public CallType getCallType() { 234 return callType; 183 235 } 184 236 … … 190 242 @Override 191 243 public String getName() { 192 return "(" + serviceName + ", " + calledMethod + ")";244 return "(" + callType + ":" + clientName + "->" + serviceName + ", " + calledMethod + ")"; 193 245 } 194 246 … … 204 256 } 205 257 else if (obj instanceof SimpleSOAPEventType) { 206 return HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) && 258 return callType.equals(((SimpleSOAPEventType) obj).callType) && 259 HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) && 207 260 HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName) && 208 261 HTTPUtils.equals(clientName, ((SimpleSOAPEventType) obj).clientName); … … 220 273 @Override 221 274 public int hashCode() { 222 int hashCode = calledMethod.hashCode() + serviceName.hashCode() + clientName.hashCode();223 return hashCode;275 return callType.hashCode() + calledMethod.hashCode() + serviceName.hashCode() + 276 clientName.hashCode(); 224 277 } 225 278 … … 231 284 @Override 232 285 public String toString() { 233 return "SimpleSOAPEventType (" + serviceName + ", " + calledMethod + ")";286 return "SimpleSOAPEventType" + getName(); 234 287 } 235 288 … … 243 296 } 244 297 } 245 //246 // /**247 // * <p>248 // * Determines how getSoapRequestBody works.249 // * <ul>250 // * <li>LOCALEVENT: returns the request body of the event type itself</li>251 // * <li>RANDOM: returns a randomly draw request body for the called method using252 // * {@link EqualSOAPDataMap#getRandom(SimpleSOAPEventType)}.253 // * </ul>254 // * </p>255 // *256 // * @author Steffen Herbold257 // */258 // public static enum RequestBodyMode {259 // LOCALEVENT, RANDOM260 // }261 298 }
Note: See TracChangeset
for help on using the changeset viewer.