mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Keep members in subclasses and use getters
This commit is contained in:
committed by
Torsten Grote
parent
ec3360400c
commit
7006f765a6
@@ -19,19 +19,18 @@ import static org.junit.Assert.assertTrue;
|
|||||||
public abstract class AbstractAutoDeleteIntegrationTest
|
public abstract class AbstractAutoDeleteIntegrationTest
|
||||||
extends AbstractAutoDeleteTest {
|
extends AbstractAutoDeleteTest {
|
||||||
|
|
||||||
protected SharingManager<? extends Shareable> sharingManager0;
|
protected abstract SharingManager<? extends Shareable> getSharingManager0();
|
||||||
protected Shareable shareable;
|
|
||||||
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>>
|
|
||||||
responseReceivedEventClass;
|
|
||||||
|
|
||||||
protected void testAutoDeclinedSharing(
|
protected abstract Shareable getShareable();
|
||||||
SharingManager<? extends Shareable> sharingManager0,
|
|
||||||
Shareable shareable) throws Exception {
|
protected abstract Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass();
|
||||||
|
|
||||||
|
protected void testAutoDeclinedSharing() throws Exception {
|
||||||
setAutoDeleteTimer(c0, contactId1From0, MIN_AUTO_DELETE_TIMER_MS);
|
setAutoDeleteTimer(c0, contactId1From0, MIN_AUTO_DELETE_TIMER_MS);
|
||||||
|
|
||||||
// Send invitation
|
// Send invitation
|
||||||
sharingManager0.sendInvitation(
|
getSharingManager0().sendInvitation(
|
||||||
shareable.getId(), contactId1From0, "This shareable!");
|
getShareable().getId(), contactId1From0, "This shareable!");
|
||||||
|
|
||||||
// The message should have been added to 0's view of the conversation
|
// The message should have been added to 0's view of the conversation
|
||||||
assertGroupCount(c0, contactId1From0, 1, 0);
|
assertGroupCount(c0, contactId1From0, 1, 0);
|
||||||
@@ -100,7 +99,7 @@ public abstract class AbstractAutoDeleteIntegrationTest
|
|||||||
// view of the conversation and the invitation auto-declined
|
// view of the conversation and the invitation auto-declined
|
||||||
c0.getTimeTravel().addCurrentTimeMillis(1);
|
c0.getTimeTravel().addCurrentTimeMillis(1);
|
||||||
ConversationMessageReceivedEvent<? extends InvitationResponse> e =
|
ConversationMessageReceivedEvent<? extends InvitationResponse> e =
|
||||||
assertEvent(c1, responseReceivedEventClass,
|
assertEvent(c1, getResponseReceivedEventClass(),
|
||||||
() -> c1.getTimeTravel().addCurrentTimeMillis(1)
|
() -> c1.getTimeTravel().addCurrentTimeMillis(1)
|
||||||
);
|
);
|
||||||
// assert that the proper event got broadcast
|
// assert that the proper event got broadcast
|
||||||
@@ -128,8 +127,8 @@ public abstract class AbstractAutoDeleteIntegrationTest
|
|||||||
waitForEvents(c1);
|
waitForEvents(c1);
|
||||||
|
|
||||||
// 0 can invite 1 again
|
// 0 can invite 1 again
|
||||||
assertTrue(sharingManager0
|
assertTrue(getSharingManager0()
|
||||||
.canBeShared(shareable.getId(), contact1From0));
|
.canBeShared(getShareable().getId(), contact1From0));
|
||||||
|
|
||||||
// Before 1's timer elapses, 1 should still see the auto-decline message
|
// Before 1's timer elapses, 1 should still see the auto-decline message
|
||||||
c0.getTimeTravel().addCurrentTimeMillis(timerLatency - 1);
|
c0.getTimeTravel().addCurrentTimeMillis(timerLatency - 1);
|
||||||
@@ -165,11 +164,12 @@ public abstract class AbstractAutoDeleteIntegrationTest
|
|||||||
assertEquals(0, getMessageHeaders(c0, contactId1From0).size());
|
assertEquals(0, getMessageHeaders(c0, contactId1From0).size());
|
||||||
|
|
||||||
// 0 can invite 1 again and really does invite
|
// 0 can invite 1 again and really does invite
|
||||||
assertTrue(sharingManager0
|
assertTrue(getSharingManager0()
|
||||||
.canBeShared(shareable.getId(), contact1From0));
|
.canBeShared(getShareable().getId(), contact1From0));
|
||||||
// Send invitation
|
// Send invitation
|
||||||
sharingManager0.sendInvitation(shareable.getId(), contactId1From0,
|
getSharingManager0()
|
||||||
"This shareable, please be quick!");
|
.sendInvitation(getShareable().getId(), contactId1From0,
|
||||||
|
"This shareable, please be quick!");
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
assertGroupCount(c1, contactId0From1, 1, 1);
|
assertGroupCount(c1, contactId0From1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ package org.briarproject.briar.sharing;
|
|||||||
|
|
||||||
import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent;
|
import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent;
|
||||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||||
|
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||||
|
import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||||
|
import org.briarproject.briar.api.sharing.Shareable;
|
||||||
|
import org.briarproject.briar.api.sharing.SharingManager;
|
||||||
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -9,6 +13,11 @@ import org.junit.Test;
|
|||||||
public class AutoDeleteBlogIntegrationTest
|
public class AutoDeleteBlogIntegrationTest
|
||||||
extends AbstractAutoDeleteIntegrationTest {
|
extends AbstractAutoDeleteIntegrationTest {
|
||||||
|
|
||||||
|
private SharingManager<? extends Shareable> sharingManager0;
|
||||||
|
private Shareable shareable;
|
||||||
|
private Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>>
|
||||||
|
responseReceivedEventClass;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -26,8 +35,23 @@ public class AutoDeleteBlogIntegrationTest
|
|||||||
return component.getBlogSharingManager();
|
return component.getBlogSharingManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SharingManager<? extends Shareable> getSharingManager0() {
|
||||||
|
return sharingManager0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Shareable getShareable() {
|
||||||
|
return shareable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass() {
|
||||||
|
return responseReceivedEventClass;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAutoDeclinedBlogSharing() throws Exception {
|
public void testAutoDeclinedBlogSharing() throws Exception {
|
||||||
testAutoDeclinedSharing(sharingManager0, shareable);
|
testAutoDeclinedSharing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package org.briarproject.briar.sharing;
|
package org.briarproject.briar.sharing;
|
||||||
|
|
||||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||||
|
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||||
import org.briarproject.briar.api.forum.event.ForumInvitationResponseReceivedEvent;
|
import org.briarproject.briar.api.forum.event.ForumInvitationResponseReceivedEvent;
|
||||||
|
import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||||
|
import org.briarproject.briar.api.sharing.Shareable;
|
||||||
|
import org.briarproject.briar.api.sharing.SharingManager;
|
||||||
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -9,6 +13,11 @@ import org.junit.Test;
|
|||||||
public class AutoDeleteForumIntegrationTest
|
public class AutoDeleteForumIntegrationTest
|
||||||
extends AbstractAutoDeleteIntegrationTest {
|
extends AbstractAutoDeleteIntegrationTest {
|
||||||
|
|
||||||
|
private SharingManager<? extends Shareable> sharingManager0;
|
||||||
|
protected Shareable shareable;
|
||||||
|
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>>
|
||||||
|
responseReceivedEventClass;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -25,8 +34,23 @@ public class AutoDeleteForumIntegrationTest
|
|||||||
return component.getForumSharingManager();
|
return component.getForumSharingManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SharingManager<? extends Shareable> getSharingManager0() {
|
||||||
|
return sharingManager0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Shareable getShareable() {
|
||||||
|
return shareable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass() {
|
||||||
|
return responseReceivedEventClass;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAutoDeclinedForumSharing() throws Exception {
|
public void testAutoDeclinedForumSharing() throws Exception {
|
||||||
testAutoDeclinedSharing(sharingManager0, shareable);
|
testAutoDeclinedSharing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user