work on implementing ordering contacts and a new event scheme for the meta contact list service

cusax-fix
Emil Ivov 20 years ago
parent 20da9c9d52
commit 05591b9e06

@ -48,6 +48,10 @@ public class MetaContactListServiceLick
static MockContact subsubContact = null;
static MockContact mockContactToRename = null;
static MockContact mockContactToReorder = null;
/**
* Start, init and register the SLICK. Create the mock protocol provider
* and register it as a service.
@ -139,6 +143,12 @@ private void fillMockContactList(MockProvider provider)
root.addContact( new MockContact("Martin Dupont", provider) );
root.addContact( new MockContact("Joe Bloggs", provider) );
mockContactToRename = new MockContact("Jane Doe", provider) ;
root.addContact( mockContactToRename );
mockContactToReorder = new MockContact("I'llChangeMyStatus", provider);
root.addContact(mockContactToReorder);
topLevelMockGroup = new MockContactGroup(topLevelGroupName, provider);
subLevelContact = new MockContact(subLevelContactName, provider);
@ -159,5 +169,6 @@ private void fillMockContactList(MockProvider provider)
topLevelMockGroup.addSubGroup(subLevelGroup);
root.addSubGroup(topLevelMockGroup);
}
}

@ -150,6 +150,9 @@ public void testGetDisplayName()
metaContact.getDisplayName());
}
/**
* Very light test of the existance and the uniqueness of meta UIDs
*/
public void testGetMetaUID()
{
String metaUID = metaContact.getMetaUID();
@ -159,4 +162,78 @@ public void testGetMetaUID()
assertTrue( "getMetaUID() did not seem to return a valid UID"
, metaUID.trim().length() > 0);
}
/**
* Verifies whether the compare method in meta contacts takes into account
* all important details: i.e. contact status, alphabetical order.
*/
public void testCompareTo()
{
verifyCompareToForAllContactsInGroupAndSubgroups(
fixture.metaClService.getRoot());
}
/**
* compare all neighbour contacts in <tt>group</tt> and its subgroups and
* try to determine whether they'reproperly ordered.
*
* @param group the <tt>MetaContactGroup</tt> to walk through
*/
public void verifyCompareToForAllContactsInGroupAndSubgroups(
MetaContactGroup group)
{
//first check order of contacts in this group
Iterator contacts = group.getChildContacts();
MetaContact previousContact = null;
int previousContactStatusSum = 0;
while(contacts.hasNext())
{
MetaContact currentContact = (MetaContact)contacts.next();
//calculate the total status for this contact
Iterator protoContacts = currentContact.getContacts();
int currentContactStatusSum = 0;
while(protoContacts.hasNext())
{
currentContactStatusSum
+= ((Contact)protoContacts.next()).getPresenceStatus()
.getStatus();
}
if (previousContact != null)
{
assertTrue( previousContact + " with status="
+ previousContactStatusSum
+ " was wrongfully before "
+ currentContact+ " with status="
+ currentContactStatusSum
, previousContactStatusSum <= currentContactStatusSum);
//if both were equal then assert alphabetical order.
if (previousContactStatusSum == currentContactStatusSum)
assertTrue( "The display name: "
+ previousContact.getDisplayName()
+ " should be considered less than "
+ currentContact.getDisplayName()
,previousContact.getDisplayName()
.compareToIgnoreCase(
currentContact.getDisplayName())
<= 0);
}
previousContact = currentContact;
previousContactStatusSum = currentContactStatusSum;
}
//now go over the subgroups
Iterator subgroups = group.getSubgroups();
while(subgroups.hasNext())
{
verifyCompareToForAllContactsInGroupAndSubgroups(
(MetaContactGroup)subgroups.next());
}
}
}

@ -168,7 +168,7 @@ private void assertGroupEquals(MockContactGroup expectedGroup,
//go over the subgroups and check that they've been all added to the
//meta contact list.
Iterator expectedSubgroups = expectedGroup.subGroups();
Iterator expectedSubgroups = expectedGroup.subgroups();
while (expectedSubgroups.hasNext() ){
MockContactGroup expectedSubGroup
= (MockContactGroup)expectedSubgroups.next();
@ -214,6 +214,132 @@ private void assertGroupEquals(MockContactGroup expectedGroup,
}
}
/**
* Verifies whether contacts are properly ordered according to their
* current status and name Checks whether reordered events are issued
* once a contact inside this group changes its status or is added
* removed a contact.
*/
public void testContactsOrder()
{
//first assert initial order.
assertContactsOrder(fixture.metaClService.getRoot());
MclEventCollector evtCollector = new MclEventCollector();
//change a status
fixture.metaClService.addContactListListener(evtCollector);
((MockPersistentPresenceOperationSet)opSetPersPresence)
.changePresenceStatusForContact(MetaContactListServiceLick
.mockContactToReorder
, MockStatusEnum.MOCK_STATUS_100);
fixture.metaClService.removeContactListListener(evtCollector);
//check whether a reordered event is dispatchect
assertEquals("Number of evts dispatched after a contact changed its status"
, 1
, evtCollector.collectedMetaContactGroupEvents.size());
MetaContactGroupEvent evt = (MetaContactGroupEvent)evtCollector
.collectedMetaContactGroupEvents.remove(0);
assertEquals("ID of the generated event",
MetaContactGroupEvent.CHILD_CONTACTS_REORDERED,
evt.getEventID());
assertEquals("Source meta contact."
, fixture.metaClService.getRoot()
, evt.getSourceMetaContactGroup());
//then check wether the contact is has been moved to the top of the list
MetaContact theReorderedContact
= fixture.metaClService.getRoot().getMetaContact(0);
assertEquals(MetaContactListServiceLick.mockContactToReorder
+ " was not moved to the top of the list after being "
+"assigned the highest possible presence status"
, MetaContactListServiceLick.mockContactToReorder
.getDisplayName()
, theReorderedContact.getDisplayName());
//then check the general order
assertContactsOrder(fixture.metaClService.getRoot());
//restore the contacts original status
((MockPersistentPresenceOperationSet)opSetPersPresence)
.changePresenceStatusForContact(MetaContactListServiceLick
.mockContactToReorder
, MockStatusEnum.MOCK_STATUS_50);
//repeat order tests but this time after changing the display name of a
//contact.
fixture.metaClService.addContactListListener(evtCollector);
fixture.metaClService.renameMetaContact(theReorderedContact, "zzzzzz");
fixture.metaClService.removeContactListListener(evtCollector);
//check whether a reordered event is dispatchect
assertEquals("Number of evts dispatched after a contact changed its "
+"display name"
, 1
, evtCollector.collectedMetaContactGroupEvents.size());
evt = (MetaContactGroupEvent)evtCollector
.collectedMetaContactGroupEvents.remove(0);
assertEquals("ID of the generated event",
MetaContactGroupEvent.CHILD_CONTACTS_REORDERED,
evt.getEventID());
assertEquals("Source meta contact."
, fixture.metaClService.getRoot()
, evt.getSourceMetaContactGroup());
//then check wether the contact is has been moved to the top of the list
assertSame(MetaContactListServiceLick.mockContactToReorder
+ " was not moved to the bottom of the list after being "
+"assigned an equal to all status and a heavy name."
, theReorderedContact
, fixture.metaClService.getRoot().getMetaContact(
fixture.metaClService.getRoot().countChildContacts()-1));
}
/**
* Makes sure that all child contacs (both direct and children of subgroups)
* are properly ordered.
* @param group a ref to the <tt>MetaContactGroup</tt> where we'd like to
* confirm order.
*/
public void assertContactsOrder(MetaContactGroup group)
{
//first check order of contacts in this group
Iterator contacts = group.getChildContacts();
MetaContact previousContact = null;
while(contacts.hasNext())
{
MetaContact currentContact = (MetaContact)contacts.next();
if (previousContact != null)
{
assertTrue( previousContact
+ " was wrongfully before "
+ currentContact
, previousContact.compareTo(currentContact) <= 0);
}
previousContact = currentContact;
}
//now go over the subgroups
Iterator subgroups = group.getSubgroups();
while(subgroups.hasNext())
{
assertContactsOrder((MetaContactGroup)subgroups.next());
}
}
/**
* Performs several tests in order to verify that the findMetaContactByID
* method of the tested implementation is working properly. We'll first
@ -411,9 +537,9 @@ public void testSubscriptionHandling() throws Exception
assertEquals("Number of evts dispatched while adding a contact"
, 1
, mclEvtCollector.collectedEvents.size());
, mclEvtCollector.collectedMetaContactEvents.size());
MetaContactEvent evt = (MetaContactEvent)mclEvtCollector
.collectedEvents.get(0);
.collectedMetaContactEvents.remove(0);
assertEquals("ID of the generated event",
MetaContactEvent.META_CONTACT_ADDED,
@ -426,12 +552,6 @@ public void testSubscriptionHandling() throws Exception
assertEquals("Source meta contact."
, newMetaContact, evt.getSourceContact());
assertEquals("Source provider"
, fixture.mockProvider, evt.getSourceProvider());
//remove the subscirption and check for the event
mclEvtCollector.collectedEvents.clear();
fixture.metaClService.addContactListListener(mclEvtCollector);
opSetPersPresence.unsubscribe(newProtoContact);
@ -445,8 +565,8 @@ public void testSubscriptionHandling() throws Exception
assertEquals("Number of evts dispatched while adding a contact"
, 1
, mclEvtCollector.collectedEvents.size());
evt = (MetaContactEvent)mclEvtCollector.collectedEvents.get(0);
, mclEvtCollector.collectedMetaContactEvents.size());
evt = (MetaContactEvent)mclEvtCollector.collectedMetaContactEvents.remove(0);
assertEquals("ID of the generated event",
MetaContactEvent.META_CONTACT_REMOVED,
@ -459,9 +579,6 @@ public void testSubscriptionHandling() throws Exception
assertEquals("Source meta contact."
, newMetaContact, evt.getSourceContact());
assertEquals("Source provider"
, fixture.mockProvider, evt.getSourceProvider());
}
@ -475,33 +592,55 @@ public void testSubscriptionHandling() throws Exception
public void testGroupChangeEventHandling() throws Exception
{
String newGroupName = "testGroupChangeEventHandling.NewContactGroup";
//add a group and check for the event
String newInnerGroupName
= "testGroupChangeEventHandling.NewInnderContactGroup";
//add 2 nested groups and check for the event
MclEventCollector mclEvtCollector = new MclEventCollector();
MockContactGroup newContactGroup
= new MockContactGroup(newGroupName, fixture.mockProvider);
MockContactGroup newInnerContactGroup
= new MockContactGroup(newGroupName, fixture.mockProvider);
newContactGroup.addSubGroup(newInnerContactGroup);
fixture.metaClService.addContactListListener(mclEvtCollector);
opSetPersPresence.createServerStoredContactGroup(
opSetPersPresence.getServerStoredContactListRoot(), newGroupName);
((MockPersistentPresenceOperationSet)opSetPersPresence)
.addMockGroupAndFireEvent(
(MockContactGroup)opSetPersPresence
.getServerStoredContactListRoot()
, newContactGroup);
fixture.metaClService.removeContactListListener(mclEvtCollector);
// first check whether event delivery went ok.
assertEquals("Number of evts dispatched while adding a contact group"
, 1
, mclEvtCollector.collectedEvents.size());
, mclEvtCollector.collectedMetaContactGroupEvents.size());
MetaContactGroupEvent evt = (MetaContactGroupEvent)mclEvtCollector
.collectedEvents.get(0);
.collectedMetaContactGroupEvents.remove(0);
assertEquals("ID of the generated event",
MetaContactGroupEvent.META_CONTACT_GROUP_ADDED,
evt.getEventID());
assertEquals("Source group of the AddEvent."
, newGroupName
assertEquals("Name of the source group of the AddEvent."
, newContactGroup.getGroupName()
, evt.getSourceMetaContactGroup().getGroupName());
//first check that the newly created group was really added
MetaContactGroup newMetaGroup = evt.getSourceMetaContactGroup();
assertSame("Contact group in the newly added meta group."
, newContactGroup
, newMetaGroup.getContactGroup(
newContactGroup.getGroupName()
, fixture.mockProvider));
assertEquals("Subgroups were not imported in the MetaContactList."
, newContactGroup.countSubgroups()
, evt.getSourceMetaContactGroup().countSubgroups());
//first check that the newly created group was really added
assertEquals("Source provider for the add event."
, fixture.mockProvider, evt.getSourceProvider());
@ -522,7 +661,6 @@ public void testGroupChangeEventHandling() throws Exception
, fixture.mockProvider);
mclEvtCollector.collectedEvents.clear();
//rename the group and see that the corresponding events are handled
//properly
fixture.metaClService.addContactListListener(mclEvtCollector);
@ -534,9 +672,10 @@ public void testGroupChangeEventHandling() throws Exception
//first check that the group was really renamed
assertEquals("Number of evts dispatched while renaming a contact group"
, 1
, mclEvtCollector.collectedEvents.size());
, mclEvtCollector.collectedMetaContactGroupEvents.size());
evt = (MetaContactGroupEvent)mclEvtCollector.collectedEvents.get(0);
evt = (MetaContactGroupEvent)mclEvtCollector
.collectedMetaContactGroupEvents.remove(0);
assertEquals("ID of the generated event",
MetaContactGroupEvent.CONTACT_GROUP_RENAMED_IN_META_GROUP,
@ -560,9 +699,6 @@ public void testGroupChangeEventHandling() throws Exception
, renamedGroupName
, ((MockContactGroup)groupsIter.next()).getGroupName());
mclEvtCollector.collectedEvents.clear();
//remove the group and check for the event.
fixture.metaClService.addContactListListener(mclEvtCollector);
opSetPersPresence.removeServerStoredContactGroup(newProtoGroup);
@ -572,8 +708,9 @@ public void testGroupChangeEventHandling() throws Exception
//first check that the group was really removed
assertEquals("Number of evts dispatched while removing a contact group"
, 1
, mclEvtCollector.collectedEvents.size());
evt = (MetaContactGroupEvent)mclEvtCollector.collectedEvents.get(0);
, mclEvtCollector.collectedMetaContactGroupEvents.size());
evt = (MetaContactGroupEvent)mclEvtCollector
.collectedMetaContactGroupEvents.remove(0);
assertEquals("ID of the generated event",
MetaContactGroupEvent.CONTACT_GROUP_REMOVED_FROM_META_GROUP,
@ -585,8 +722,6 @@ public void testGroupChangeEventHandling() throws Exception
assertEquals("Source provider for the remove event."
, fixture.mockProvider, evt.getSourceProvider());
mclEvtCollector.collectedEvents.clear();
}
/**
@ -633,20 +768,21 @@ public void testAddMoveRemoveContactToMetaContact()
//verify that events have been properly delivered.
assertEquals("Events delivered while adding a new contact to a "
+ "meta contact", 1, evtCollector.collectedEvents.size());
+ "meta contact", 1, evtCollector.collectedMetaContactEvents.size());
MetaContactEvent event = (MetaContactEvent)evtCollector
.collectedEvents.get(0);
evtCollector.collectedEvents.clear();
ProtoContactEvent event = (ProtoContactEvent)evtCollector
.collectedMetaContactEvents.remove(0);
assertSame ( "Source contact in MetaContactEvent gen. upon add."
, metaContact , event.getSourceContact());
assertSame ( "Source contact in ProtoContactEvent gen. upon add."
, newContact , event.getProtoContact());
assertSame ( "Source provider in MetaContactEvent gen. upon add."
, fixture.mockProvider, event.getSourceProvider());
assertSame ( "Source provider in ProtoContactEvent gen. upon add."
, fixture.mockProvider
, event.getProtoContact().getProtocolProvider());
assertEquals ( "Event ID in MetaContactEvent gen. upon add."
, MetaContactEvent.PROTO_CONTACT_ADDED, event.getEventID());
, ProtoContactEvent.PROTO_CONTACT_ADDED
, event.getPropertyName());
//move the mock contact to another meta contact
fixture.metaClService.addContactListListener(evtCollector);
@ -674,19 +810,23 @@ public void testAddMoveRemoveContactToMetaContact()
//verify that events have been properly delivered.
assertEquals("Events delivered while adding a moving a proto contact. "
, 1, evtCollector.collectedEvents.size());
, 1, evtCollector.collectedMetaContactEvents.size());
event = (MetaContactEvent) evtCollector.collectedEvents.get(0);
evtCollector.collectedEvents.clear();
event = (ProtoContactEvent) evtCollector.collectedMetaContactEvents.remove(0);
assertSame("Source contact in MetaContactEvent gen. upon move."
, dstMetaContact, event.getSourceContact());
assertSame("Source contact in ProtoContactEvent gen. upon move."
, newContact, event.getProtoContact());
assertSame("Source provider in MetaContactEvent gen. upon move."
, fixture.mockProvider, event.getSourceProvider());
assertSame("Parent meta contact in ProtoContactEvent gen. upon move."
, dstMetaContact, event.getParent());
assertEquals("Event ID in MetaContactEvent gen. upon add."
, MetaContactEvent.PROTO_CONTACT_MOVED, event.getEventID());
assertSame("Source provider in ProtoContactEvent gen. upon move."
, fixture.mockProvider
, event.getProtoContact().getProtocolProvider());
assertEquals("Event ID in ProtoContactEvent gen. upon add."
, ProtoContactEvent.PROTO_CONTACT_MOVED
, event.getPropertyName());
//remove the meta contact
fixture.metaClService.addContactListListener(evtCollector);
@ -709,21 +849,24 @@ public void testAddMoveRemoveContactToMetaContact()
//verify that events have been properly delivered.
assertEquals("Events delivered while adding a new contact to a "
+"meta contact", 1, evtCollector.collectedEvents.size());
+"meta contact", 1, evtCollector.collectedMetaContactEvents.size());
event = (MetaContactEvent)evtCollector
.collectedEvents.get(0);
evtCollector.collectedEvents.clear();
event = (ProtoContactEvent)evtCollector
.collectedMetaContactEvents.remove(0);
assertSame ( "Source contact in MetaContactEvent gen. upon remove."
, dstMetaContact, event.getSourceContact());
assertSame ( "Source contact in ProtoContactEvent gen. upon remove."
, newContact, event.getProtoContact());
assertSame ( "Source provider in MetaContactEvent gen. upon remove."
, fixture.mockProvider, event.getSourceProvider());
assertSame ( "Parent meta contact in ProtoContactEvent gen. upon remove."
, dstMetaContact, event.getParent());
assertEquals ( "Event ID in MetaContactEvent gen. upon remove."
, MetaContactEvent.PROTO_CONTACT_REMOVED
, event.getEventID());
assertSame ( "Source provider in ProtoContactEvent gen. upon remove."
, fixture.mockProvider
, event.getProtoContact().getProtocolProvider());
assertEquals ( "Event ID in ProtoContactEvent gen. upon remove."
, ProtoContactEvent.PROTO_CONTACT_REMOVED
, event.getPropertyName());
}
@ -761,18 +904,14 @@ public void testCreateMoveRemoveMetaContact()
//verify that events have been properly delivered.
assertEquals("Events delivered while creating a new meta contact"
, 1, evtCollector.collectedEvents.size());
, 1, evtCollector.collectedMetaContactEvents.size());
MetaContactEvent event = (MetaContactEvent)evtCollector
.collectedEvents.get(0);
evtCollector.collectedEvents.clear();
.collectedMetaContactEvents.remove(0);
assertSame ( "Source contact in MetaContactEvent gen. upon create."
, newMetaContact, event.getSourceContact());
assertSame ( "Source provider in MetaContactEvent gen. upon create."
, fixture.mockProvider, event.getSourceProvider());
assertEquals ( "Event ID in MetaContactEvent gen. upon create."
, MetaContactEvent.META_CONTACT_ADDED
, event.getEventID());
@ -813,18 +952,25 @@ public void testCreateMoveRemoveMetaContact()
//verify that events have been properly delivered.
assertEquals("Events delivered while moving a meta contact"
, 1, evtCollector.collectedEvents.size());
, 1, evtCollector.collectedMetaContactEvents.size());
event = (MetaContactEvent)evtCollector
.collectedEvents.get(0);
evtCollector.collectedEvents.clear();
MetaContactMovedEvent movedEvent = (MetaContactMovedEvent)evtCollector
.collectedMetaContactEvents.remove(0);
assertSame ( "Source contact in MetaContactEvent gen. upon move."
, newMetaContact, event.getSourceContact());
, newMetaContact, movedEvent.getSourceMetaContact());
assertEquals ( "Event ID in MetaContactEvent gen. upon move."
, MetaContactEvent.META_CONTACT_MOVED
, event.getEventID());
assertEquals ( "Event Property Name in MetaContactEvent gen. upon move."
, MetaContactMovedEvent.META_CONTACT_MOVED
, movedEvent.getPropertyName());
assertEquals ( "Old Parent in MetaContactEvent gen. upon move."
, parentMetaGroup
, movedEvent.getOldParent());
assertEquals ( "Old Parent in MetaContactEvent gen. upon move."
, fixture.metaClService.getRoot()
, movedEvent.getNewParent());
//remove the contact
fixture.metaClService.addContactListListener(evtCollector);
@ -849,18 +995,14 @@ public void testCreateMoveRemoveMetaContact()
//verify that events have been properly delivered.
assertEquals("Events delivered while removing a meta contact"
, 1, evtCollector.collectedEvents.size());
, 1, evtCollector.collectedMetaContactEvents.size());
event = (MetaContactEvent)evtCollector
.collectedEvents.get(0);
evtCollector.collectedEvents.clear();
.collectedMetaContactEvents.remove(0);
assertSame ( "Source contact in MetaContactEvent gen. upon remove."
, newMetaContact, event.getSourceContact());
assertSame ( "Source provider in MetaContactEvent gen. upon remove."
, fixture.mockProvider, event.getSourceProvider());
assertEquals ( "Event ID in MetaContactEvent gen. upon remove."
, MetaContactEvent.META_CONTACT_REMOVED
, event.getEventID());
@ -978,6 +1120,55 @@ public void testFindParentMetaContactGroup()
, metaGroup.getGroupName());
}
/**
* Renames a contact in the contact list and verifies whether the new name
* has taken effect and whether the corresponding event has been dispatched.
*/
public void testRenameMetaContact()
{
String newName = "testRenameMetaContact.AyNewName";
MockContact mockContact
= MetaContactListServiceLick.mockContactToRename;
//keep the name to later verify that it's untouched.
String oldMockContactDisplayName = mockContact.getDisplayName();
MetaContact contactToRename
= fixture.metaClService.findMetaContactByContact(mockContact);
MclEventCollector evtCollector = new MclEventCollector();
//rename the meta contact
fixture.metaClService.addContactListListener(evtCollector);
fixture.metaClService.renameMetaContact(contactToRename, newName);
fixture.metaClService.removeContactListListener(evtCollector);
//check that an event has been dispatched
assertEquals("Events delivered while renaming a meta contact"
, 1, evtCollector.collectedMetaContactEvents.size());
MetaContactRenamedEvent event = (MetaContactRenamedEvent)evtCollector
.collectedMetaContactEvents.remove(0);
assertSame ( "Source contact in MetaContactRenamedEvent gen. upon remove."
, contactToRename, event.getSourceMetaContact());
assertEquals ( "Event ID in MetaContactEvent gen. upon remove."
, MetaContactRenamedEvent.META_CONTACT_RENAMED
, event.getPropertyName());
//check that the meta contact has been renamed
assertEquals( "DisplayName of a MetaContact unchanged after renaming"
, newName
, contactToRename.getDisplayName() );
//verify that the underlying mock contact has not been changed
assertEquals( "Proto Contact modified after renaming a MetaContact"
, oldMockContactDisplayName
, mockContact.getDisplayName() );
}
/**
* Tests the MetaContactListService
* .findParentMetaContactGroup(MetaContactGroup)
@ -1015,7 +1206,9 @@ public void testFindParentMetaContactGroup2()
private class MclEventCollector implements MetaContactListListener
{
public Vector collectedEvents = new Vector();
public Vector collectedMetaContactEvents = new Vector();
public Vector collectedMetaContactGroupEvents = new Vector();
/**
* Indicates that a MetaContact has been successfully added
* to the MetaContact list.
@ -1023,76 +1216,118 @@ private class MclEventCollector implements MetaContactListListener
*/
public void metaContactAdded(MetaContactEvent evt)
{
collectedEvents.add(evt);
collectedMetaContactEvents.add(evt);
}
/**
* Indicates that a MetaContactGroup has been successfully added
* to the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding
* contact
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactGroupAdded(MetaContactGroupEvent evt)
{
collectedEvents.add(evt);
collectedMetaContactGroupEvents.add(evt);
}
/**
* Indicates that a MetaContactGroup has been removed from the
* MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding
* contact
* Indicates that a MetaContact has been moved inside the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactGroupRemoved(MetaContactGroupEvent evt)
public void metaContactMoved(MetaContactMovedEvent evt)
{
collectedEvents.add(evt);
collectedMetaContactEvents.add(evt);
}
/**
* Indicates that a MetaContact has been removed from the MetaContact
* list.
* @param evt the MetaContactListEvent containing the corresponding
* contact
* Indicates that a MetaContact has been modified.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactRemoved(MetaContactEvent evt)
public void metaContactRenamed(MetaContactRenamedEvent evt)
{
collectedEvents.add(evt);
collectedMetaContactEvents.add(evt);
}
/**
* Indicates that a MetaContact has been moved inside the MetaContact
* list.
* @param evt the MetaContactListEvent containing the corresponding
* contact
* Indicates that a protocol specific <tt>Contact</tt> instance has been
* moved from within one <tt>MetaContact</tt> to another.
* @param evt a reference to the <tt>ProtoContactMovedEvent</tt> instance.
*/
public void metaContactMoved(MetaContactEvent evt)
public void protoContactMoved(ProtoContactEvent evt)
{
collectedEvents.add(evt);
collectedMetaContactEvents.add(evt);
}
/**
* Indicates that a MetaContact has been modified.
* @param evt the MetaContactListEvent containing the corresponding
* contact
* Indicates that a protocol specific <tt>Contact</tt> instance has been
* removed from the list of protocol specific buddies in this
* <tt>MetaContact</tt>
* @param evt a reference to the corresponding
* <tt>ProtoContactEvent</tt>
*/
public void metaContactModified(MetaContactEvent evt)
public void protoContactRemoved(ProtoContactEvent evt)
{
collectedEvents.add(evt);
collectedMetaContactEvents.add(evt);
}
/**
* Indicates that a MetaContactGroup has been modified (e.g. a proto
* contact group was removed).
* Indicates that a MetaContactGroup has been modified (e.g. a proto contact
* group was removed).
*
* @param evt the MetaContactListEvent containing the corresponding
* contact
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactGroupModified(MetaContactGroupEvent evt)
{
collectedEvents.add(evt);
collectedMetaContactGroupEvents.add(evt);
}
}
/**
* Indicates that a MetaContactGroup has been removed from the MetaContact
* list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactGroupRemoved(MetaContactGroupEvent evt)
{
collectedMetaContactGroupEvents.add(evt);
}
/**
* Indicates that a MetaContact has been removed from the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactRemoved(MetaContactEvent evt)
{
collectedMetaContactEvents.add(evt);
}
/**
* Indicates that a protocol specific <tt>Contact</tt> instance has been
* added to the list of protocol specific buddies in this
* <tt>MetaContact</tt>
* @param evt a reference to the corresponding
* <tt>ProtoContactEvent</tt>
*/
public void protoContactAdded(ProtoContactEvent evt)
{
collectedMetaContactEvents.add(evt);
}
/**
* Indicates that the order under which the child contacts were ordered
* inside the source group has changed.
* @param evt the <tt>MetaContactGroupEvent</tt> containind details of this
* event.
*/
public void childContactsReordered(MetaContactGroupEvent evt)
{
collectedMetaContactGroupEvents.add(evt);
}
}
}

@ -7,7 +7,6 @@
package net.java.sip.communicator.slick.contactlist.mockprovider;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.icqconstants.*;
/**
* A simple, straightforward mock implementation of the Contact interface
@ -22,6 +21,7 @@ public class MockContact
private String contactID = null;
private MockProvider parentProvider = null;
private MockContactGroup parentGroup = null;
private PresenceStatus presenceStatus = MockStatusEnum.MOCK_STATUS_50;
/**
* Creates an instance of a meta contact with the specified string used
@ -88,7 +88,18 @@ public byte[] getImage()
*/
public PresenceStatus getPresenceStatus()
{
return IcqStatusEnum.ONLINE;
return this.presenceStatus;
}
/**
* Sets <tt>mockPresenceStatus</tt> as the PresenceStatus that this contact
* is currently in.
* @param mockPresenceStatus the <tt>MockPresenceStatus</tt> currently valid
* for this contact.
*/
public void setPresenceStatus(MockStatusEnum mockPresenceStatus)
{
this.presenceStatus = mockPresenceStatus;
}
/**
@ -129,7 +140,7 @@ public MockContactGroup getParentGroup()
*/
public String toString()
{
StringBuffer buff = new StringBuffer("MetaContact[ DisplayName=")
StringBuffer buff = new StringBuffer("MockContact[ DisplayName=")
.append(getDisplayName()).append("]");
return buff.toString();

@ -23,6 +23,7 @@ public class MockContactGroup
private Vector contacts = new Vector();
private Vector subGroups = new Vector();
private MockContactGroup parentGroup = null;
private MockProvider parentProvider = null;
@ -106,18 +107,40 @@ public int countSubgroups()
* Adds the specified contact group to the contained by this group.
* @param subGroup the MockContactGroup to add as a subgroup to this group.
*/
public void addSubGroup(MockContactGroup subGroup)
public void addSubGroup(MockContactGroup subgroup)
{
this.subGroups.add(subGroup);
this.subGroups.add(subgroup);
subgroup.setParentGroup(this);
}
/**
* Sets the group that is the new parent of this group
* @param parent MockContactGroup
*/
void setParentGroup(MockContactGroup parent)
{
this.parentGroup = parent;
}
/**
* Returns the <tt>MockContactGroup</tt> that is currently parent og this
* group.
* @return a reference to the <tt>MockContactGroup</tt> that is currently
* the parent of this group.
*/
public MockContactGroup getParentGroup()
{
return this.parentGroup;
}
/**
* Removes the specified contact group from the this group's subgroups.
* @param subGroup the MockContactGroup subgroup to remove.
*/
public void removeSubGroup(MockContactGroup subGroup)
public void removeSubGroup(MockContactGroup subgroup)
{
this.subGroups.remove(subGroup);
this.subGroups.remove(subgroup);
subgroup.setParentGroup(null);
}
@ -144,7 +167,7 @@ public MockContactGroup findGroupParent(MockContactGroup mockGroup)
if ( subGroups.contains(mockGroup) )
return this;
Iterator subGroupsIter = subGroups();
Iterator subGroupsIter = subgroups();
while (subGroupsIter.hasNext())
{
MockContactGroup subgroup = (MockContactGroup) subGroupsIter.next();
@ -168,7 +191,7 @@ public MockContactGroup findContactParent(MockContact mockContact)
if ( contacts.contains(mockContact) )
return this;
Iterator subGroupsIter = subGroups();
Iterator subGroupsIter = subgroups();
while (subGroupsIter.hasNext())
{
MockContactGroup subgroup = (MockContactGroup) subGroupsIter.next();
@ -221,7 +244,7 @@ public ContactGroup getGroup(int index)
*/
public ContactGroup getGroup(String groupName)
{
Iterator groupsIter = subGroups();
Iterator groupsIter = subgroups();
while (groupsIter.hasNext())
{
MockContactGroup contactGroup
@ -260,7 +283,7 @@ public void setGroupName(String newGrpName)
* @return a java.util.Iterator over the <tt>ContactGroup</tt> children
* of this group (i.e. subgroups).
*/
public Iterator subGroups()
public Iterator subgroups()
{
return subGroups.iterator();
}
@ -294,7 +317,7 @@ public MockContact findContactByID(String id)
}
//if we didn't find it here, let's try in the subougroups
Iterator groupsIter = subGroups();
Iterator groupsIter = subgroups();
while( groupsIter.hasNext() )
{
@ -321,7 +344,7 @@ public String toString()
StringBuffer buff = new StringBuffer(getGroupName());
buff.append(".subGroups=" + countSubgroups() + ":\n");
Iterator subGroups = subGroups();
Iterator subGroups = subgroups();
while (subGroups.hasNext())
{
MockContactGroup group = (MockContactGroup)subGroups.next();

Loading…
Cancel
Save