use of org.odk.collect.android.injection.config.AppDependencyComponent in project collect by opendatakit.
the class FormMapActivityTest method setUpActivity.
@Before
public void setUpActivity() {
CollectHelpers.setupDemoProject();
AppDependencyComponent component = CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public MapProvider providesMapProvider() {
MapProvider mapProvider = mock(MapProvider.class);
when(mapProvider.createMapFragment(ArgumentMatchers.any())).thenReturn(map);
return mapProvider;
}
});
FormsRepository formsRepository = component.formsRepositoryProvider().get();
instancesRepository = component.instancesRepositoryProvider().get();
form = formsRepository.save(testForm);
Arrays.stream(testInstances).forEach(instancesRepository::save);
Intent intent = new Intent();
intent.putExtra(FormMapActivity.EXTRA_FORM_ID, form.getDbId());
activityController = CollectHelpers.buildThemedActivity(FormMapActivity.class, intent);
activity = (FormMapActivity) activityController.get();
activityController.setup();
}
use of org.odk.collect.android.injection.config.AppDependencyComponent in project collect by opendatakit.
the class CollectHelpers method overrideAppDependencyModule.
public static AppDependencyComponent overrideAppDependencyModule(AppDependencyModule appDependencyModule) {
AppDependencyComponent testComponent = DaggerAppDependencyComponent.builder().application(ApplicationProvider.getApplicationContext()).appDependencyModule(appDependencyModule).build();
((Collect) ApplicationProvider.getApplicationContext()).setComponent(testComponent);
return testComponent;
}
Aggregations