Refactor events based on InvitationRequestReceivedEvent

This commit is contained in:
Torsten Grote
2016-10-17 13:47:30 -02:00
parent a33d7d1663
commit 02a39f5694
6 changed files with 33 additions and 23 deletions

View File

@@ -547,7 +547,7 @@ public class BlogSharingIntegrationTest extends BriarIntegrationTest {
BlogInvitationReceivedEvent event =
(BlogInvitationReceivedEvent) e;
eventWaiter.assertEquals(contactId1, event.getContactId());
Blog b = event.getBlog();
Blog b = event.getShareable();
try {
Contact c = contactManager0.getContact(contactId1);
blogSharingManager0.respondToInvitation(b, c, true);
@@ -589,7 +589,7 @@ public class BlogSharingIntegrationTest extends BriarIntegrationTest {
(BlogInvitationReceivedEvent) e;
requestReceived = true;
if (!answer) return;
Blog b = event.getBlog();
Blog b = event.getShareable();
try {
eventWaiter.assertEquals(1,
blogSharingManager1.getInvitations().size());

View File

@@ -939,7 +939,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
(ForumInvitationReceivedEvent) e;
eventWaiter.assertEquals(contactId1, event.getContactId());
requestReceived = true;
Forum f = event.getForum();
Forum f = event.getShareable();
try {
Contact c = contactManager0.getContact(contactId1);
forumSharingManager0.respondToInvitation(f, c, true);
@@ -982,7 +982,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
(ForumInvitationReceivedEvent) e;
requestReceived = true;
if (!answer) return;
Forum f = event.getForum();
Forum f = event.getShareable();
try {
eventWaiter.assertEquals(1,
forumSharingManager1.getInvitations().size());

View File

@@ -5,17 +5,11 @@ import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sharing.InvitationRequest;
public class BlogInvitationReceivedEvent extends
InvitationRequestReceivedEvent {
private final Blog blog;
InvitationRequestReceivedEvent<Blog> {
public BlogInvitationReceivedEvent(Blog blog, ContactId contactId,
InvitationRequest request) {
super(contactId, request);
this.blog = blog;
super(blog, contactId, request);
}
public Blog getBlog() {
return blog;
}
}

View File

@@ -5,18 +5,11 @@ import org.briarproject.api.forum.Forum;
import org.briarproject.api.forum.ForumInvitationRequest;
public class ForumInvitationReceivedEvent extends
InvitationRequestReceivedEvent {
private final Forum forum;
InvitationRequestReceivedEvent<Forum> {
public ForumInvitationReceivedEvent(Forum forum, ContactId contactId,
ForumInvitationRequest request) {
super(contactId, request);
this.forum = forum;
}
public Forum getForum() {
return forum;
super(forum, contactId, request);
}
}

View File

@@ -0,0 +1,15 @@
package org.briarproject.api.event;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.forum.ForumInvitationRequest;
import org.briarproject.api.privategroup.PrivateGroup;
public class GroupInvitationReceivedEvent extends
InvitationRequestReceivedEvent<PrivateGroup> {
public GroupInvitationReceivedEvent(PrivateGroup group, ContactId contactId,
ForumInvitationRequest request) {
super(group, contactId, request);
}
}

View File

@@ -2,14 +2,18 @@ package org.briarproject.api.event;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sharing.InvitationRequest;
import org.briarproject.api.sharing.Shareable;
public abstract class InvitationRequestReceivedEvent extends Event {
public abstract class InvitationRequestReceivedEvent<S extends Shareable>
extends Event {
private final S shareable;
private final ContactId contactId;
private final InvitationRequest request;
InvitationRequestReceivedEvent(ContactId contactId,
InvitationRequestReceivedEvent(S shareable, ContactId contactId,
InvitationRequest request) {
this.shareable = shareable;
this.contactId = contactId;
this.request = request;
}
@@ -21,4 +25,8 @@ public abstract class InvitationRequestReceivedEvent extends Event {
public InvitationRequest getRequest() {
return request;
}
public S getShareable() {
return shareable;
}
}