Changeset 1993 for trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/SOAPUtils.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/SOAPUtils.java
r1992 r1993 40 40 import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType; 41 41 import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType; 42 import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType.CallType; 42 43 43 44 /** … … 220 221 * @return body of the SOAP event 221 222 */ 222 public static Element getSoap RequestBodyFromEvent(Event event) {223 return getSoap RequestBodyFromEvent(event, false);223 public static Element getSoapBodyFromEvent(Event event) { 224 return getSoapBodyFromEvent(event, false); 224 225 } 225 226 … … 235 236 * @return body of the SOAP event 236 237 */ 237 public static Element getSoap RequestBodyFromEvent(Event event, boolean useRandomRequestBodies) {238 public static Element getSoapBodyFromEvent(Event event, boolean useRandomRequestBodies) { 238 239 Element requestBody = null; 239 240 if (event.getType() instanceof SOAPEventType) { … … 242 243 else if (event.getType() instanceof SimpleSOAPEventType) { 243 244 if (useRandomRequestBodies) { 244 requestBody = ((SimpleSOAPEventType) event.getType()).getRandomSoap RequestBody();245 requestBody = ((SimpleSOAPEventType) event.getType()).getRandomSoapMsgBody(); 245 246 } 246 247 else { 247 requestBody = ((SimpleSOAPEventType) event.getType()).getSoap RequestBody();248 requestBody = ((SimpleSOAPEventType) event.getType()).getSoapMsgBody(); 248 249 } 249 250 } … … 382 383 new Event(new SimpleSOAPEventType(methodName, eventType.getServiceName(), 383 384 eventType.getClientName(), 384 eventType.getSoap RequestBody(),385 eventType.getSoapMsgBody(), 385 386 eventType.getEqualSOAPDataMap()), 386 387 event.getTarget()); … … 457 458 return sortedSequences; 458 459 } 459 460 461 /** 462 * <p> 463 * Sorts the sequences by the orderingId of the requests/responses. This function only supports 464 * the ordering of {@link Event}s with a {@link SOAPEventType}. 465 * </p> 466 * 467 * @param sequences 468 * sequences to be order 469 * @param orderType 470 * determines if sequences are ordered by request or response 471 * @return sorted sequences 472 */ 473 public static Collection<List<Event>> sortAndConvertSequences(Collection<List<Event>> sequences, 474 boolean keepRequests, 475 boolean keepResponse) 476 { 477 Collection<List<Event>> sortedSequences = new LinkedList<>(); 478 EqualSOAPDataMap equalSOAPDataMap = new EqualSOAPDataMap(); 479 for (List<Event> sequence : sequences) { 480 // use insertion sort 481 List<Event> sortedSequence = new LinkedList<>(); 482 long lastOrderId = Long.MIN_VALUE; 483 long selectedOrderId; 484 Event selectedEvent; 485 CallType selectedCallType = CallType.RESPONSE; 486 do { 487 selectedEvent = null; 488 selectedOrderId = Long.MAX_VALUE; 489 for (Event event : sequence) { 490 if (!(event.getType() instanceof SOAPEventType)) { 491 throw new RuntimeException( 492 "Can only order SOAPEventTypes. SimpleSOAPEvent is also not supported. Event type found: " + 493 event.getType().getClass().getName()); 494 } 495 SOAPEventType soapEventType = (SOAPEventType) event.getType(); 496 long requestOrderId = soapEventType.getExchange().getRequest().getOrderingId(); 497 long responseOrderId = 498 soapEventType.getExchange().getResponse().getOrderingId(); 499 500 if (requestOrderId > lastOrderId && requestOrderId < selectedOrderId) { 501 selectedOrderId = requestOrderId; 502 selectedEvent = event; 503 selectedCallType = CallType.REQUEST; 504 } 505 if (responseOrderId > lastOrderId && responseOrderId < selectedOrderId) { 506 selectedOrderId = responseOrderId; 507 selectedEvent = event; 508 selectedCallType = CallType.RESPONSE; 509 } 510 } 511 if (selectedEvent != null) { 512 SOAPEventType eventType = (SOAPEventType) selectedEvent.getType(); 513 Element soapMsgBody; 514 switch (selectedCallType) 515 { 516 case REQUEST: 517 soapMsgBody = eventType.getSoapRequestBody(); 518 break; 519 case RESPONSE: 520 soapMsgBody = eventType.getSoapResponseBody(); 521 break; 522 default: 523 throw new RuntimeException("unsupported call type: " + selectedCallType); 524 } 525 if ((keepRequests && selectedCallType == CallType.REQUEST) || 526 (keepResponse && selectedCallType == CallType.RESPONSE)) 527 { 528 sortedSequence.add(new Event(new SimpleSOAPEventType(eventType 529 .getCalledMethod(), eventType.getServiceName(), eventType 530 .getClientName(), soapMsgBody, equalSOAPDataMap, selectedCallType))); 531 } 532 lastOrderId = selectedOrderId; 533 } 534 535 } while(selectedEvent!=null); 536 sortedSequences.add(sortedSequence); 537 } 538 return sortedSequences; 539 } 540 460 541 /** 461 542 * <p> 462 543 * Removes calls to and from all ignored services from the sequences. 463 544 * </p> 464 * 465 * @param sequences sequences where the ignored services are removed 466 * @param ignoredServicesString comma separted string that defines the ignored services 545 * 546 * @param sequences 547 * sequences where the ignored services are removed 548 * @param ignoredServicesString 549 * comma separted string that defines the ignored services 467 550 * @return sequences without events that reference the ignored services 468 551 */ 469 public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences, String ignoredServicesString) { 552 public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences, 553 String ignoredServicesString) 554 { 470 555 Set<String> ignoredServices = new HashSet<>(); 471 556 if (ignoredServicesString != null) { … … 476 561 return removeCallsToIgnoredServices(sequences, ignoredServices); 477 562 } 478 563 479 564 /** 480 565 * <p> 481 566 * Removes calls to and from all ignored services from the sequences. 482 567 * </p> 483 * 484 * @param sequences sequences where the ignored services are removed 485 * @param ignoredServices set with all ignored service names 568 * 569 * @param sequences 570 * sequences where the ignored services are removed 571 * @param ignoredServices 572 * set with all ignored service names 486 573 * @return sequences without events that reference the ignored services 487 574 */ 488 public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences, Set<String> ignoredServices) { 575 public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences, 576 Set<String> ignoredServices) 577 { 489 578 Collection<List<Event>> onlyAcceptedServicesSequences = new LinkedList<>(); 490 579 for (List<Event> sequence : sequences) { … … 493 582 SimpleSOAPEventType eventType = (SimpleSOAPEventType) event.getType(); 494 583 if (!ignoredServices.contains(eventType.getServiceName()) && 495 !ignoredServices.contains(eventType.getClientName()) ) { 584 !ignoredServices.contains(eventType.getClientName())) 585 { 496 586 onlyAcceptedServicesSequence.add(event); 497 587 }
Note: See TracChangeset
for help on using the changeset viewer.