aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2014-08-04 23:48:02 +0200
committerDanny van Heumen <danny@dannyvanheumen.nl>2014-08-05 00:01:50 +0200
commit1d44622699201ddbc6d10b13085f22982ff10eeb (patch)
treeff9d5a6b588035aa953761b7ac91aecd4d351aa2
parent2b73fd1ad37737a2dc02c5c77c1b0e4cd6e5e184 (diff)
downloadjitsi-1d44622699201ddbc6d10b13085f22982ff10eeb.zip
jitsi-1d44622699201ddbc6d10b13085f22982ff10eeb.tar.gz
jitsi-1d44622699201ddbc6d10b13085f22982ff10eeb.tar.bz2
Store parent provider by actual type.
-rw-r--r--src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java15
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java95
2 files changed, 56 insertions, 54 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java
index 7b704c4..678dfe1 100644
--- a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java
@@ -40,7 +40,7 @@ public class ChatRoomMemberIrcImpl
/**
* The provider that created us.
*/
- private final ProtocolProviderService parentProvider;
+ private final ProtocolProviderServiceIrcImpl parentProvider;
/**
* Set of active roles.
@@ -61,7 +61,8 @@ public class ChatRoomMemberIrcImpl
* @param chatRoomMemberRole the role that this member has in the
* corresponding chat room
*/
- public ChatRoomMemberIrcImpl(final ProtocolProviderService parentProvider,
+ public ChatRoomMemberIrcImpl(
+ final ProtocolProviderServiceIrcImpl parentProvider,
final ChatRoom chatRoom, final String contactID,
final ChatRoomMemberRole chatRoomMemberRole)
{
@@ -207,16 +208,14 @@ public class ChatRoomMemberIrcImpl
}
/**
- * Returns null to indicate that there's no contact corresponding to the
- * IRC member.
+ * Get the corresponding contact for a chat room member if it exists.
*
- * @return null
+ * @return Contact instance if it exists, or null otherwise.
*/
public Contact getContact()
{
- // FIXME look up contact via Persistent Presence OS. It might already
- // exist.
- return null;
+ return this.parentProvider.getPersistentPresence().findContactByID(
+ this.contactID);
}
/**
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java b/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java
index 20a931b..e1f22ce 100644
--- a/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java
+++ b/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java
@@ -31,8 +31,8 @@ public class ChatRoomMemberIrcImplTest
public void testConstructorNullChatRoom()
{
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
try
{
new ChatRoomMemberIrcImpl(provider, null, "user",
@@ -48,8 +48,8 @@ public class ChatRoomMemberIrcImplTest
public void testConstructorNullContactId()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
try
{
new ChatRoomMemberIrcImpl(provider, chatroom, null,
@@ -65,8 +65,8 @@ public class ChatRoomMemberIrcImplTest
public void testConstructorNullRole()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
try
{
new ChatRoomMemberIrcImpl(provider, chatroom, "user", null);
@@ -81,8 +81,8 @@ public class ChatRoomMemberIrcImplTest
public void testConstructorSuccessful()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
Assert.assertNotNull(new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER));
}
@@ -90,8 +90,8 @@ public class ChatRoomMemberIrcImplTest
public void testCheckGetters()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertEquals(provider, member.getProtocolProvider());
@@ -104,8 +104,8 @@ public class ChatRoomMemberIrcImplTest
public void testNameNull()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(provider, chatroom, "user",
ChatRoomMemberRole.SILENT_MEMBER);
@@ -125,8 +125,8 @@ public class ChatRoomMemberIrcImplTest
public void testNameChange()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertEquals("user", member.getContactAddress());
@@ -139,8 +139,8 @@ public class ChatRoomMemberIrcImplTest
public void testRoleNull()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(provider, chatroom, "user",
ChatRoomMemberRole.SILENT_MEMBER);
@@ -150,8 +150,8 @@ public class ChatRoomMemberIrcImplTest
public void testRoleUnchange()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole());
@@ -162,8 +162,8 @@ public class ChatRoomMemberIrcImplTest
public void testAddSignificantRole()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(provider, chatroom, "user",
ChatRoomMemberRole.SILENT_MEMBER);
@@ -175,8 +175,8 @@ public class ChatRoomMemberIrcImplTest
public void testRemoveSignificantRole()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(provider, chatroom, "user",
ChatRoomMemberRole.SILENT_MEMBER);
@@ -189,8 +189,8 @@ public class ChatRoomMemberIrcImplTest
public void testAddInsignificantRole()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(provider, chatroom, "user",
ChatRoomMemberRole.ADMINISTRATOR);
@@ -202,8 +202,8 @@ public class ChatRoomMemberIrcImplTest
public void testRemoveInsignificantRole()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(provider, chatroom, "user",
ChatRoomMemberRole.ADMINISTRATOR);
@@ -216,8 +216,11 @@ public class ChatRoomMemberIrcImplTest
public void testGetContact()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
+ OperationSetPersistentPresenceIrcImpl pp = EasyMock.createMock(OperationSetPersistentPresenceIrcImpl.class);
+ EasyMock.expect(provider.getPersistentPresence()).andReturn(pp);
+ EasyMock.replay(provider);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertNull(member.getContact());
@@ -226,8 +229,8 @@ public class ChatRoomMemberIrcImplTest
public void testGetAvatar()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertNull(member.getAvatar());
@@ -236,8 +239,8 @@ public class ChatRoomMemberIrcImplTest
public void testEqualsSame()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertTrue(member.equals(member));
@@ -246,8 +249,8 @@ public class ChatRoomMemberIrcImplTest
public void testEqualsNull()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertFalse(member.equals(null));
@@ -256,8 +259,8 @@ public class ChatRoomMemberIrcImplTest
public void testEqualsObject()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertFalse(member.equals(new Object()));
@@ -266,12 +269,12 @@ public class ChatRoomMemberIrcImplTest
public void testEqualsSameUserDifferentProvider()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member1 = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
- ProtocolProviderService provider2 =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider2 =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member2 = new ChatRoomMemberIrcImpl(provider2, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
Assert.assertFalse(member1.equals(member2));
@@ -280,8 +283,8 @@ public class ChatRoomMemberIrcImplTest
public void testEqualsSameProviderDifferentUser()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member1 = new ChatRoomMemberIrcImpl(provider, chatroom,
"user", ChatRoomMemberRole.SILENT_MEMBER);
ChatRoomMemberIrcImpl member2 = new ChatRoomMemberIrcImpl(provider, chatroom,
@@ -292,8 +295,8 @@ public class ChatRoomMemberIrcImplTest
public void testEqualsTrue()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member1 = new ChatRoomMemberIrcImpl(provider, chatroom,
"susy", ChatRoomMemberRole.SILENT_MEMBER);
ChatRoomMemberIrcImpl member2 = new ChatRoomMemberIrcImpl(provider, chatroom,
@@ -304,8 +307,8 @@ public class ChatRoomMemberIrcImplTest
public void testHashcodeNotFailing()
{
ChatRoom chatroom = EasyMock.createMock(ChatRoom.class);
- ProtocolProviderService provider =
- EasyMock.createMock(ProtocolProviderService.class);
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(provider, chatroom, "ET",
ChatRoomMemberRole.ADMINISTRATOR);