diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java index 2a97cb3b1..f2c2a9211 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java @@ -79,7 +79,7 @@ public Iterator getChildContacts() * Returns the contact with the specified identifier * * @param metaContactID a String identifier obtained through the - * MetaContact.getMetaContactID() method.

+ * MetaContact.getMetaUID() method.

* @return the MetaContact with the specified idnetifier. */ public MetaContact getMetaContact(String metaContactID) @@ -89,7 +89,7 @@ public MetaContact getMetaContact(String metaContactID) { MetaContact contact = (MetaContact)contactsIter.next(); - if (contact.getMetaContactID().equals(metaContactID)) + if (contact.getMetaUID().equals(metaContactID)) return contact; } diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java index b3ab11586..80f22493c 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java @@ -105,7 +105,7 @@ public Contact getDefaultContact() * * @return a String uniquely identifying this meta contact. */ - public String getMetaContactID() + public String getMetaUID() { return uid; } diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java index 07492d27b..ae204f195 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java @@ -44,10 +44,10 @@ * Because of its experimental-patch nature, the implementa would only function * properly if the underlying service providers have already been loaded at the * time this one gets started. - * + * * @todo might be a good idea to say that the implementation does not support * subgroups. - * + * * @author Emil Ivov */ public class MetaContactListServiceImpl @@ -106,7 +106,7 @@ public MetaContactListServiceImpl() { * protocol provider implementations and perform the same algorithm with * them. *

- * + * * @param bc * the currently valid osgi bundle context. */ @@ -151,7 +151,7 @@ public void start(BundleContext bc) { /** * Adds a listener for MetaContactListChangeEvents posted after * the tree changes. - * + * * @param l * the listener to add */ @@ -166,7 +166,7 @@ public void addContactListListener( * First makes the specified protocol provider create the contact as * indicated by contactID, and then associates it to the * _existing_ metaContact given as an argument. - * + * * @param provider * the ProtocolProviderService that should create the contact * indicated by contactID. @@ -193,7 +193,7 @@ public void addNewContactToMetaContact( * corresponding to the specified contactID, then creates a new * MetaContact which will encapsulate the newly crated protocol specific * contact. - * + * * @param provider * a ref to ProtocolProviderService instance which * will create the actual protocol specific contact. @@ -218,7 +218,7 @@ public void createMetaContact( /** * Creates a MetaContactGroup with the specified group name. - * + * * @param groupName * the name of the MetaContactGroup to create. * @throws MetaContactListException @@ -234,7 +234,7 @@ public void createMetaContactGroup(String groupName) /** * Returns the root MetaContactGroup in this contact list. - * + * * @return the root MetaContactGroup for this contact list. */ public MetaContactGroup getRoot() { @@ -244,7 +244,7 @@ public MetaContactGroup getRoot() { /** * Makes the specified contact a child of the newParent * MetaContact. - * + * * @param contact * the Contact to move to the * @param newParent @@ -262,7 +262,7 @@ public void moveContact(Contact contact, /** * Moves the specified MetaContact to newGroup. - * + * * @param metaContact * the MetaContact to move. * @param newGroup @@ -284,7 +284,7 @@ public void moveMetaContact(MetaContact metaContact, * Deletes the specified contact from both the local contact list and (if * applicable) the server stored contact list if supported by the * corresponding protocol. - * + * * @param contact * the contact to remove. * @throws MetaContactListException @@ -299,7 +299,7 @@ public void removeContact(Contact contact) /** * Removes a listener previously added with addContactListListener. - * + * * @param l * the listener to remove */ @@ -313,7 +313,7 @@ public void removeContactListListener( /** * Removes the specified metaContact as well as all of its * underlying contacts. - * + * * @param metaContact * the metaContact to remove. * @throws MetaContactListException @@ -330,7 +330,7 @@ public void removeMetaContact(MetaContact metaContact) /** * Removes the specified meta contact group, all its corresponding protocol * specific groups and all their children. - * + * * @param groupToRemove * the MetaContactGroup to have removed. * @throws MetaContactListException @@ -346,10 +346,10 @@ public void removeMetaContactGroup( } /** - * Returns the MetaContactGroup corresponding to the specified contactGroup - * or null if no such MetaContactGroup was found. - * @return the MetaContactGroup corresponding to the specified contactGroup - * or null if no such MetaContactGroup was found. + * Returns the MetaContactGroup corresponding to the specified contactGroup + * or null if no such MetaContactGroup was found. + * @return the MetaContactGroup corresponding to the specified contactGroup + * or null if no such MetaContactGroup was found. * @param contactGroup * the protocol specific contactGroup that we're looking * for. @@ -359,14 +359,14 @@ public void removeMetaContactGroup( /** @todo implement findMetaContactByContact() */ return null; } - + /** * Returns the MetaContact containing the specified contact or null if no * such MetaContact was found. The method can be used when for example we * need to find the MetaContact that is the author of an incoming message * and the corresponding ProtocolProviderService has only provided a * Contact as its author. - * + * * @return the MetaContact containing the speicified contact or null if no * such contact is present in this contact list. * @param contact @@ -380,7 +380,7 @@ public MetaContact findMetaContactByContact(Contact contact) { /** * Returns the MetaContact that corresponds to the specified metaContactID. - * + * * @param metaContactID * a String identifier of a meta contact. * @return the MetaContact with the speicified string identifier or null if @@ -395,7 +395,7 @@ public MetaContact findMetaContactByID(String metaContactID) { * Goes through the server stored ContactList of the specified operation * set, retrieves all protocol specific contacts it contains and makes sure * they are all present in the local contact list. - * + * * @param presenceOpSet * the presence operation set whose contact list we'd like to * synchronize with the local contact list. @@ -445,7 +445,7 @@ private void synchronizeOpSetWithLocalContactList( /** @todo this shouldn't be that simple */ newMetaContact.setDisplayName(contact - .getAlias()); + .getDisplayName()); newMetaGroup.addMetaContact(newMetaContact); } @@ -466,7 +466,7 @@ private void synchronizeOpSetWithLocalContactList( newMetaContact.addProtoContact(contact); /** @todo this shouldn't be that simple */ - newMetaContact.setDisplayName(contact.getAlias()); + newMetaContact.setDisplayName(contact.getDisplayName()); rootMetaGroup.addMetaContact(newMetaContact); @@ -488,7 +488,7 @@ private void synchronizeOpSetWithLocalContactList( * extract all contacts and synchronize them with the local contact list. * Otherwise it would start a process where local contacts would be added on * the server. - * + * * @param provider * the ProtocolProviderService that we've just detected. */ @@ -518,7 +518,7 @@ private void handleProviderAdded( /** * Removes the specified provider from the list of currently known providers * and ignores all the contacts that it has registered locally. - * + * * @param provider * the ProtocolProviderService that has been unregistered. */ @@ -534,7 +534,7 @@ private void handleProviderRemoved( * Implements the ServiceListener method. Verifies whether the * passed event concerns a ProtocolProviderService and modifies * the list of registered protocol providers accordingly. - * + * * @param event * The ServiceEvent object. */ @@ -589,7 +589,7 @@ public void subscriptionCreated(SubscriptionEvent evt) { logger.trace("Subscription created: " + evt); - MetaContactGroupImpl parentGroup = + MetaContactGroupImpl parentGroup = (MetaContactGroupImpl)rootMetaGroup.getMetaContactSubgroup(evt .getParentGroup().getGroupName()); @@ -599,11 +599,11 @@ public void subscriptionCreated(SubscriptionEvent evt) { .getSourceContact()); newMetaContact.setDisplayName(evt - .getSourceContact().getAlias()); + .getSourceContact().getDisplayName()); parentGroup.addMetaContact(newMetaContact); - fireMetaContactEvent(newMetaContact, + fireMetaContactEvent(newMetaContact, evt.getSourceProvider(), parentGroup, MetaContactEvent.METACONTACT_ADDED); @@ -617,15 +617,15 @@ public void subscriptionFailed(SubscriptionEvent evt) { public void subscriptionRemoved(SubscriptionEvent evt) { logger.trace("Subscription removed: " + evt); - - MetaContact metaContact + + MetaContact metaContact = findMetaContactByContact(evt.getSourceContact()); - + MetaContactGroup metaContactGroup = findMetaContactGroupByContactGroup(evt.getParentGroup()); - - //TODO: remove contact from metacontact - + + //TODO: remove contact from metacontact + fireMetaContactEvent(metaContact, evt.getSourceProvider(), metaContactGroup, @@ -656,14 +656,14 @@ public void groupCreated(ServerStoredGroupEvent evt) { .contacts(); while (contactsIter.hasNext()) { Contact contact = (Contact) contactsIter - .next(); + .next(); MetaContactImpl newMetaContact = new MetaContactImpl(); newMetaContact.addProtoContact(contact); newMetaContact.setDisplayName(contact - .getAlias()); + .getDisplayName()); newMetaGroup.addMetaContact(newMetaContact); } @@ -678,14 +678,14 @@ public void groupCreated(ServerStoredGroupEvent evt) { public void groupRemoved(ServerStoredGroupEvent evt) { logger.trace("ContactGroup removed: " + evt); - - MetaContactGroup metaContactGroup + + MetaContactGroup metaContactGroup = findMetaContactGroupByContactGroup(evt.getSrouceGroup()); if (metaContactGroup != null) { - + removeMetaContactGroup(metaContactGroup); - + fireMetaContactGroupEvent(metaContactGroup, evt.getSourceProvider(), MetaContactGroupEvent.METACONTACT_GROUP_REMOVED); @@ -693,12 +693,12 @@ public void groupRemoved(ServerStoredGroupEvent evt) { } public void groupNameChanged(ServerStoredGroupEvent evt) { - + logger.trace("ContactGroup renamed: " + evt); - - MetaContactGroup metaContactGroup + + MetaContactGroup metaContactGroup = findMetaContactGroupByContactGroup(evt.getSrouceGroup()); - + //TODO: change the name of the MetaContactGroup } } @@ -707,7 +707,7 @@ public void groupNameChanged(ServerStoredGroupEvent evt) { * Creates the corresponding MetaContact event and notifies all * MetaContactListListeners that a MetaContact is added or * removed from the MetaContactList. - * + * * @param source * the MetaContact instance that is added to the MetaContactList * @param provider @@ -747,7 +747,7 @@ else if (eventID == MetaContactEvent.METACONTACT_REMOVED) * Creates the corresponding MetaContactGroup event and notifies all * MetaContactListListeners that a MetaContactGroup is added or * removed from the MetaContactList. - * + * * @param source * the MetaContactGroup instance that is added to the * MetaContactList diff --git a/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java b/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java index 1167172f3..1d628d2d0 100644 --- a/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java @@ -92,7 +92,7 @@ public Iterator getChildContacts() * Returns the contact with the specified identifier * * @param metaContactID a String identifier obtained through the - * MetaContact.getMetaContactID() method.

+ * MetaContact.getMetaUID() method.

* @return the MetaContact with the specified idnetifier. */ public MetaContact getMetaContact(String metaContactID) @@ -102,7 +102,7 @@ public MetaContact getMetaContact(String metaContactID) { MetaContact contact = (MetaContact)contactsIter.next(); - if (contact.getMetaContactID().equals(metaContactID)) + if (contact.getMetaUID().equals(metaContactID)) return contact; } diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java index 01a775f84..8e1217d50 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java @@ -149,7 +149,7 @@ public PresenceStatus getPresenceStatus() * @return a String that can be used for referring to this contact when * interacting with the user. */ - public String getAlias() + public String getDisplayName() { //temporarily return the uin as we don't have alias support in joust //sim right now. diff --git a/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java b/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java index 36dec63f4..8cc770a0a 100644 --- a/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java +++ b/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java @@ -28,10 +28,10 @@ public class TestMetaContactList MclSlickFixture fixture = new MclSlickFixture(getClass().getName()); private static final Logger logger = - Logger.getLogger(TestOperationSetPersistentPresence.class); - + Logger.getLogger(TestMetaContactList.class); + private OperationSetPersistentPresence opSetPersPresence; - + /** * Creates a unit test with the specified name. * @param name the name of one of the test methods in this class. @@ -85,50 +85,79 @@ protected void tearDown() throws Exception /** * Verifies that the contacts retrieved by the meta contact list service, - * match those that were in the mock provider. + * matches the one that were in the mock provider. */ public void testContactListRetrieving() { - ContactGroup root + ContactGroup expectedRoot = opSetPersPresence.getServerStoredContactListRoot(); - + logger.debug("============== Predefined contact List =============="); - - logger.debug("rootGroup="+root.getGroupName() - +" rootGroup.childContacts="+root.countContacts() - + "rootGroup.childGroups="+root.countSubGroups() - + "Printing rootGroupContents=\n"+root.toString()); - - MetaContactGroup expectedRoot = fixture.metaClService.getRoot(); + + logger.debug("rootGroup="+expectedRoot.getGroupName() + +" rootGroup.childContacts="+expectedRoot.countContacts() + + "rootGroup.childGroups="+expectedRoot.countSubGroups() + + " Printing rootGroupContents=\n"+expectedRoot.toString()); + + MetaContactGroup actualRoot = fixture.metaClService.getRoot(); logger.debug("================ Meta Contact List ================="); - logger.debug("rootGroup="+expectedRoot.getGroupName() - +" rootGroup.childContacts="+expectedRoot.countChildContacts() - + "rootGroup.childGroups="+expectedRoot.countSubgroups() - + "Printing rootGroupContents=\n"+expectedRoot.toString()); - - Iterator groups = root.subGroups(); - while (groups.hasNext() ){ - ContactGroup group = (ContactGroup)groups.next(); - - MetaContactGroup expectedGroup - = expectedRoot - .getMetaContactSubgroup(group.getGroupName()); - - assertNotNull("Group " + group.getGroupName() + " was returned by " - +"the server but was not in the expected contact list." - , expectedGroup ); - - Iterator contactsIter = group.contacts(); - while (contactsIter.hasNext()){ - String contactID = ((Contact)contactsIter.next()).getAddress(); - MetaContact expectedContact - = expectedGroup.getMetaContact(contactID); - - assertNotNull("Contact " + contactID + " was returned by " - +"the server but was not in the expected contact list." - , expectedContact ); + logger.debug("rootGroup="+actualRoot.getGroupName() + +" rootGroup.childContacts="+actualRoot.countChildContacts() + + " rootGroup.childGroups="+actualRoot.countSubgroups() + + " Printing rootGroupContents=\n"+actualRoot.toString()); + + Iterator expectedSubgroups = expectedRoot.subGroups(); + + //loop over mock groups and check whether they've all been added + //to the meta contact list. + while (expectedSubgroups.hasNext() ){ + ContactGroup expectedGroup = (ContactGroup)expectedSubgroups.next(); + + MetaContactGroup actualGroup + = actualRoot + .getMetaContactSubgroup(expectedGroup.getGroupName()); + + assertNotNull("Group " + expectedGroup.getGroupName() + " was " + + "returned by the MetaContactListService implementation " + + "but was not in the expected contact list." + , actualGroup ); + + assertEquals("Group " + expectedGroup.getGroupName() + + " did not have the expected number of member contacts" + , expectedGroup.countContacts() + , actualGroup.countChildContacts() ); + + assertEquals("Group " + expectedGroup.getGroupName() + + " did not have the expected number of member contacts" + , expectedGroup.countContacts() + , actualGroup.countChildContacts() ); + assertEquals("Group " + expectedGroup.getGroupName() + + " did not have the expected number of sub groups" + , expectedGroup.countSubGroups() + , actualGroup.countSubgroups() ); + + Iterator actualContactsIter = actualGroup.getChildContacts(); + + //check whether every contact in the meta list exists in the source + //mock provider contact list. + while (actualContactsIter.hasNext()){ + MetaContact actualMetaContact + = (MetaContact)actualContactsIter.next(); + + Contact actualProtoContact + = actualMetaContact.getContactForProvider( + MclSlickFixture.mockProvider); + + Contact expectedProtoContact + = expectedGroup.getContact(actualProtoContact.getAddress()); + + assertNotNull("Contact " + actualMetaContact.getDisplayName() + + " was returned by " + + "the MetaContactListService implementation but was " + + "not in the expected contact list." + , expectedProtoContact ); } } }