Replace default methods with helper classes.

This is a workaround for AbstractMethodErrors
thrown by on-device tests.
This commit is contained in:
akwizgran
2019-12-11 16:27:55 +00:00
parent 5ba64577bd
commit 5962d3c763
35 changed files with 182 additions and 144 deletions

View File

@@ -65,23 +65,23 @@ public class BlogManagerIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -38,7 +38,7 @@ public class FeedManagerIntegrationTest extends BriarTestCase {
DaggerFeedManagerIntegrationTestComponent.builder()
.testDatabaseConfigModule(
new TestDatabaseConfigModule(testFile)).build();
component.injectFeedManagerEagerSingletons();
FeedManagerIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
IdentityManager identityManager = component.getIdentityManager();

View File

@@ -35,12 +35,6 @@ interface FeedManagerIntegrationTestComponent
void inject(FeedModule.EagerSingletons init);
default void injectFeedManagerEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new BlogModule.EagerSingletons());
inject(new FeedModule.EagerSingletons());
}
IdentityManager getIdentityManager();
LifecycleManager getLifecycleManager();
@@ -49,4 +43,13 @@ interface FeedManagerIntegrationTestComponent
BlogManager getBlogManager();
class Helper {
public static void injectEagerSingletons(
FeedManagerIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new BlogModule.EagerSingletons());
c.inject(new FeedModule.EagerSingletons());
}
}
}

View File

@@ -56,23 +56,23 @@ public class ForumManagerTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
private ForumPost createForumPost(GroupId groupId,

View File

@@ -54,7 +54,8 @@ public class IntroductionCryptoIntegrationTest extends BrambleTestCase {
public IntroductionCryptoIntegrationTest() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
crypto = new IntroductionCryptoImpl(cryptoComponent, clientHelper);

View File

@@ -114,23 +114,24 @@ public class IntroductionIntegrationTest
protected void createComponents() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerIntroductionIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerIntroductionIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerIntroductionIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -74,7 +74,8 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
public MessageEncoderParserIntegrationTest() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
messageEncoder = new MessageEncoderImpl(clientHelper, messageFactory);

View File

@@ -83,7 +83,8 @@ public class SessionEncoderParserIntegrationTest extends BrambleTestCase {
public SessionEncoderParserIntegrationTest() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
sessionEncoder = new SessionEncoderImpl(clientHelper);

View File

@@ -44,7 +44,8 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
public MessageSizeIntegrationTest() {
MessageSizeIntegrationTestComponent component =
DaggerMessageSizeIntegrationTestComponent.builder().build();
component.injectMessageSizeEagerSingletons();
MessageSizeIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
}

View File

@@ -27,9 +27,13 @@ interface MessageSizeIntegrationTestComponent
void inject(MessagingModule.EagerSingletons init);
default void injectMessageSizeEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new ForumModule.EagerSingletons());
inject(new MessagingModule.EagerSingletons());
class Helper {
public static void injectEagerSingletons(
MessageSizeIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new ForumModule.EagerSingletons());
c.inject(new MessagingModule.EagerSingletons());
}
}
}

View File

@@ -68,23 +68,23 @@ public class MessagingManagerIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -60,11 +60,13 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
alice = DaggerSimplexMessagingIntegrationTestComponent.builder()
.testDatabaseConfigModule(
new TestDatabaseConfigModule(aliceDir)).build();
alice.injectSimplexMessagingEagerSingletons();
SimplexMessagingIntegrationTestComponent.Helper
.injectEagerSingletons(alice);
bob = DaggerSimplexMessagingIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(bobDir))
.build();
bob.injectSimplexMessagingEagerSingletons();
SimplexMessagingIntegrationTestComponent.Helper
.injectEagerSingletons(bob);
}
@Test

View File

@@ -28,11 +28,6 @@ interface SimplexMessagingIntegrationTestComponent
void inject(MessagingModule.EagerSingletons init);
default void injectSimplexMessagingEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new MessagingModule.EagerSingletons());
}
LifecycleManager getLifecycleManager();
IdentityManager getIdentityManager();
@@ -46,4 +41,13 @@ interface SimplexMessagingIntegrationTestComponent
EventBus getEventBus();
ConnectionManager getConnectionManager();
class Helper {
public static void injectEagerSingletons(
SimplexMessagingIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new MessagingModule.EagerSingletons());
}
}
}

View File

@@ -70,23 +70,23 @@ public class PrivateGroupIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -59,23 +59,23 @@ public class PrivateGroupManagerIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -66,23 +66,23 @@ public class GroupInvitationIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -82,23 +82,23 @@ public class BlogSharingIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -99,23 +99,23 @@ public class ForumSharingIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
private void addForumForSharer() throws DbException {

View File

@@ -69,17 +69,6 @@ public interface BriarIntegrationTestComponent
void inject(SharingModule.EagerSingletons init);
default void injectBriarEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new BlogModule.EagerSingletons());
inject(new ForumModule.EagerSingletons());
inject(new GroupInvitationModule.EagerSingletons());
inject(new IntroductionModule.EagerSingletons());
inject(new MessagingModule.EagerSingletons());
inject(new PrivateGroupModule.EagerSingletons());
inject(new SharingModule.EagerSingletons());
}
LifecycleManager getLifecycleManager();
EventBus getEventBus();
@@ -121,4 +110,19 @@ public interface BriarIntegrationTestComponent
BlogFactory getBlogFactory();
ConnectionManager getConnectionManager();
class Helper {
public static void injectEagerSingletons(
BriarIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new BlogModule.EagerSingletons());
c.inject(new ForumModule.EagerSingletons());
c.inject(new GroupInvitationModule.EagerSingletons());
c.inject(new IntroductionModule.EagerSingletons());
c.inject(new MessagingModule.EagerSingletons());
c.inject(new PrivateGroupModule.EagerSingletons());
c.inject(new SharingModule.EagerSingletons());
}
}
}