BasicEventList's ListEvent has no information

View: New views
1 Messages — Rating Filter:   Alert me  

BasicEventList's ListEvent has no information

by reibans :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I want to use glazedlists-1.8.0_java15 in my project and I wrote a little
unit test beforehand to play with the API and get to know how it works. In
the test, I'm using a BasicEventList and I register a mock listener. When I
add one element to the list, the listener is called but the resulting
ListEvent has no info. The test is failing in the first assert because
ListEvent.next() method is returning false. Could somebody tell me what I'm
doing wrong? Here is the test code:

package checklist;

import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.event.ListEvent;
import ca.odell.glazedlists.event.ListEventListener;
import org.junit.Test;
import static org.junit.Assert.*;

public class BasicEventListTest {

    @Test
    public void addElement() {
        EventList<String> eventList = new BasicEventList<String>();
        MockListEventListener<String> listener = new
MockListEventListener<String>();
        eventList.addListEventListener(listener);

        eventList.add("hello");
        assertEquals(1, listener.callCount);
        assertTrue("true expected", listener.event.next());
        assertEquals(ListEvent.INSERT, listener.event.getType());
        assertEquals(0, listener.event.getIndex());
    }


    private static class MockListEventListener<E> implements
ListEventListener<E> {
        int callCount;
        ListEvent<E> event;

        public void listChanged(ListEvent<E> listChanges) {
            callCount++;
            event = listChanges;
        }
    }
}


Many thanks,
--
View this message in context: http://old.nabble.com/BasicEventList%27s-ListEvent-has-no-information-tp26160591p26160591.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...