Changeset 996


Ignore:
Timestamp:
11/16/12 13:51:11 (12 years ago)
Author:
pharms
Message:
  • added support for storing timestamps with events
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/EventTest.java

    r958 r996  
    313313    } 
    314314 
     315    @Test 
     316    public void testSetParameter_1() throws Exception { 
     317        Event fixture = new Event(mock(IEventType.class)); 
     318        assertNull(fixture.getParameter("key")); 
     319    } 
     320 
     321    @Test 
     322    public void testSetParameter_2() throws Exception { 
     323        Event fixture = new Event(mock(IEventType.class)); 
     324        fixture.setParameter("key", "value"); 
     325        assertEquals("value", fixture.getParameter("key")); 
     326    } 
     327 
     328    @Test 
     329    public void testSetParameter_3() throws Exception { 
     330        Event fixture = new Event(mock(IEventType.class)); 
     331        fixture.setParameter("key", "value"); 
     332        fixture.setParameter("key", null); 
     333        assertNull(fixture.getParameter("key")); 
     334    } 
     335 
     336    @Test 
     337    public void testSetParameter_4() throws Exception { 
     338        Event fixture = new Event(mock(IEventType.class)); 
     339        fixture.setParameter("key", "value"); 
     340        assertNull(fixture.getParameter("key2")); 
     341    } 
     342 
     343    @Test(expected = java.lang.IllegalArgumentException.class) 
     344    public void testSetParameter_5() throws Exception { 
     345        Event fixture = new Event(mock(IEventType.class)); 
     346        fixture.setParameter(null, null); 
     347    } 
     348 
     349    @Test(expected = java.lang.IllegalArgumentException.class) 
     350    public void testGetParameter_1() throws Exception { 
     351        Event fixture = new Event(mock(IEventType.class)); 
     352        fixture.getParameter(null); 
     353    } 
     354 
     355    @Test 
     356    public void testGetTimestamp_1() throws Exception { 
     357        Event fixture = new Event(mock(IEventType.class)); 
     358        assertTrue(fixture.getTimestamp() < 0); 
     359    } 
     360 
     361    @Test 
     362    public void testSetTimestamp_1() throws Exception { 
     363        Event fixture = new Event(mock(IEventType.class)); 
     364        fixture.setTimestamp(1234); 
     365        assertEquals(1234, fixture.getTimestamp()); 
     366    } 
     367 
    315368    public static void main(String[] args) { 
    316369        new org.junit.runner.JUnitCore().run(EventTest.class); 
  • trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/Event.java

    r958 r996  
    2424 * <p> 
    2525 * Base class for all events. An event is described by its {@link #type} and its {@link #target}. 
     26 * An event may be provided with a timestamp and further parameters. 
    2627 * </p> 
    2728 *  
     
    6263 
    6364    /** 
    64      * </p> Target of the event. 
     65     * <p> 
     66     * Target of the event. 
     67     * </p> 
    6568     */ 
    6669    private IEventTarget target = null; 
     70     
     71    /** 
     72     * <p> 
     73     * Timestamp of when the event took place. 
     74     * </p> 
     75     */ 
     76    private long timestamp = Long.MIN_VALUE; 
    6777     
    6878    /** 
     
    114124    /** 
    115125     * <p> 
    116      * Two events are equal, if their {@link #type} and {@link #target} are equal. 
     126     * Two events are equal, if their {@link #type} and {@link #target} are equal. The timestamp 
     127     * and other parameters are ignored. 
    117128     * </p> 
    118129     * <p> 
     
    309320    /** 
    310321     * <p> 
     322     * Sets the timestamp of the event, i.e. when the event occurred. A timestamp for events is 
     323     * optional. Therefore it is also ignored by the {@link #equals(Object)}-method. A timestamp 
     324     * with a value smaller 0 means, that now timestamp for the event exists. 
     325     * </p> 
     326     *  
     327     * @param timestamp the new value for the timestamp 
     328     */ 
     329    public void setTimestamp(long timestamp) { 
     330        this.timestamp = timestamp; 
     331    } 
     332 
     333    /** 
     334     * <p> 
     335     * Returns the timestamp of the event or a value lower than 0 if no timestamp for the event 
     336     * exists. 
     337     * </p> 
     338     *  
     339     * @return the timestamp of the event or a value lower than 0 if no timestamp exists 
     340     */ 
     341    public long getTimestamp() { 
     342        return timestamp; 
     343    } 
     344 
     345    /** 
     346     * <p> 
    311347     * Returns a the list of replay events. 
    312348     * </p> 
  • trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogParser.java

    r975 r996  
    356356        Event event = new Event(interaction, guiElement); 
    357357        event.setParameter("clientId", clientId); 
    358         event.setParameter("timestamp", Long.toString(timestamp)); 
    359358        event.setParameter("agent", agent); 
     359         
     360        event.setTimestamp(timestamp); 
    360361         
    361362        return event; 
Note: See TracChangeset for help on using the changeset viewer.