Ignore:
Timestamp:
07/31/14 16:44:36 (10 years ago)
Author:
sherbold
Message:
  • fixed SOAP event types hashCode and equals method to account for the serviceName
  • added SimpleSOAPEventType that contains only the name of the called method and of the called service
  • added convertToSimpleSOAPEvent method to HTTPUtils
  • added tests for convertToSimpleSOAPEvent
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/HTTPUtils.java

    r1561 r1635  
    1515package de.ugoe.cs.autoquest.plugin.http; 
    1616 
     17import java.util.LinkedList; 
     18import java.util.List; 
     19 
     20import de.ugoe.cs.autoquest.eventcore.Event; 
     21import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType; 
     22import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType; 
    1723import de.ugoe.cs.autoquest.plugin.http.logdata.Address; 
    1824 
     
    2834    /** 
    2935     * <p> 
    30      * converts an address to a simple string containing either host or ip and the port number 
    31      * if any. 
     36     * converts an address to a simple string containing either host or ip and the port number if 
     37     * any. 
    3238     * </p> 
    3339     *  
    34      * @param address the address to convert 
     40     * @param address 
     41     *            the address to convert 
    3542     *  
    3643     * @return either "host:port" or "ip:port" or "host" or "ip" or "port" or null 
     
    6572    /** 
    6673     * <p> 
    67      * compares two addresses and returns true, if they are equal and false else. The addresses 
    68      * are equal, if either the ip-addresses and the ports match or the host names and the 
    69      * ports match. 
     74     * compares two addresses and returns true, if they are equal and false else. The addresses are 
     75     * equal, if either the ip-addresses and the ports match or the host names and the ports match. 
    7076     * </p> 
    71      * 
    72      * @param address1 the first address to compare 
    73      * @param address2 the second address to compare 
     77     *  
     78     * @param address1 
     79     *            the first address to compare 
     80     * @param address2 
     81     *            the second address to compare 
    7482     *  
    7583     * @return as described 
     
    8290            return false; 
    8391        } 
    84          
     92 
    8593        if (!equals(address1.getPort(), address2.getPort())) { 
    8694            return false; 
    8795        } 
    88          
     96 
    8997        if (address1.getIp() != null) { 
    9098            return equals(address1.getIp(), address2.getIp()); 
     
    94102        } 
    95103    } 
    96      
     104 
    97105    /** 
    98106     * <p> 
    99      * convenience method to compare to objects. They are considered equal if they both are null, 
    100      * or if their equals method returns true. 
     107     * convenience method to compare to objects. They are considered equal if they both are null, or 
     108     * if their equals method returns true. 
    101109     * </p> 
    102      * 
    103      * @param object1 the first object to compare 
    104      * @param object2 the second object to compare 
     110     *  
     111     * @param object1 
     112     *            the first object to compare 
     113     * @param object2 
     114     *            the second object to compare 
    105115     *  
    106116     * @return as described 
    107117     */ 
    108118    public static <T> boolean equals(T object1, T object2) { 
    109         if (object1 == null)  { 
     119        if (object1 == null) { 
    110120            return object2 == null; 
    111121        } 
     
    117127    /** 
    118128     * <p> 
     129     * Replaces events with a {@link SOAPEventType} with new events of {@link SimpleSOAPEventType} 
     130     * and no target. 
     131     * </p> 
     132     *  
     133     * @param sequence 
     134     *            sequence where the events are replaced 
     135     * @return sequence with {@link SimpleSOAPEventType}s instead of {@link SOAPEventType}s 
     136     */ 
     137    public static List<Event> convertToSimpleSOAPEvent(List<Event> sequence) { 
     138        List<Event> newSequence = null; 
     139        if (sequence != null) { 
     140            newSequence = new LinkedList<>(); 
     141            for (Event event : sequence) { 
     142                if (event.getType() instanceof SOAPEventType) { 
     143                    SOAPEventType eventType = (SOAPEventType) event.getType(); 
     144                    newSequence.add(new Event(new SimpleSOAPEventType(eventType.getCalledMethod(), 
     145                                                                      eventType.getServiceName()))); 
     146                } 
     147                else { 
     148                    newSequence.add(event); 
     149                } 
     150            } 
     151        } 
     152        return newSequence; 
     153    } 
     154 
     155    /** 
     156     * <p> 
    119157     * prevent instantiation 
    120158     * </p> 
    121159     */ 
    122     private HTTPUtils() { } 
    123      
     160    private HTTPUtils() {} 
     161 
    124162} 
Note: See TracChangeset for help on using the changeset viewer.