Search in sources :

Example 1 with TestComponent

use of com.android.example.devsummit.archdemo.di.component.TestComponent in project dev-summit-architecture-demo by yigit.

the class TestUtil method prepare.

public static TestComponent prepare(App app) {
    FlowManager.destroy();
    resetSingleton(FlowManager.class, "mDatabaseHolder");
    ApplicationModule appModule = new ApplicationModule(app) {

        @Override
        public EventBus eventBus() {
            return new LoggingBus();
        }

        @Provides
        @Singleton
        public JobManager jobManager() {
            JobManager mock = mock(JobManager.class);
            when(mock.addJob(any(Job.class))).thenReturn(1L);
            return mock;
        }
    };
    TestComponent testComponent = DaggerTestComponent.builder().testApplicationModule(new TestApplicationModule()).applicationModule(appModule).build();
    testComponent.appContext().deleteDatabase(DemoDatabase.NAME + ".db");
    FlowManager.init(app);
    testComponent.feedModel().clear();
    testComponent.loggingBus().clear();
    return testComponent;
}
Also used : DaggerTestComponent(com.android.example.devsummit.archdemo.di.component.DaggerTestComponent) TestComponent(com.android.example.devsummit.archdemo.di.component.TestComponent) TestApplicationModule(com.android.example.devsummit.archdemo.di.module.TestApplicationModule) JobManager(com.path.android.jobqueue.JobManager) Job(com.path.android.jobqueue.Job) LoggingBus(com.android.example.devsummit.archdemo.event.LoggingBus) TestApplicationModule(com.android.example.devsummit.archdemo.di.module.TestApplicationModule) ApplicationModule(com.android.example.devsummit.archdemo.di.module.ApplicationModule)

Aggregations

DaggerTestComponent (com.android.example.devsummit.archdemo.di.component.DaggerTestComponent)1 TestComponent (com.android.example.devsummit.archdemo.di.component.TestComponent)1 ApplicationModule (com.android.example.devsummit.archdemo.di.module.ApplicationModule)1 TestApplicationModule (com.android.example.devsummit.archdemo.di.module.TestApplicationModule)1 LoggingBus (com.android.example.devsummit.archdemo.event.LoggingBus)1 Job (com.path.android.jobqueue.Job)1 JobManager (com.path.android.jobqueue.JobManager)1