use of org.odk.collect.analytics.Analytics in project collect by opendatakit.
the class SelectOneWidgetTest method overrideDependencyModule.
private void overrideDependencyModule() throws Exception {
ReferenceManager referenceManager = setupFakeReferenceManager(REFERENCES);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public AudioHelperFactory providesAudioHelperFactory(Scheduler scheduler) {
return context -> audioHelper;
}
@Override
public Analytics providesAnalytics(Application application) {
return analytics;
}
@Override
public SoftKeyboardController provideSoftKeyboardController() {
return mock(SoftKeyboardController.class);
}
});
}
use of org.odk.collect.analytics.Analytics in project collect by opendatakit.
the class SelectMultiWidgetTest method overrideDependencyModule.
private void overrideDependencyModule() throws Exception {
ReferenceManager referenceManager = setupFakeReferenceManager(REFERENCES);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public AudioHelperFactory providesAudioHelperFactory(Scheduler scheduler) {
return context -> audioHelper;
}
@Override
public Analytics providesAnalytics(Application application) {
return analytics;
}
@Override
public SoftKeyboardController provideSoftKeyboardController() {
return mock(SoftKeyboardController.class);
}
});
}
use of org.odk.collect.analytics.Analytics in project collect by opendatakit.
the class ServerFormDownloaderTest method whenDownloadingFormWithVersion_andId_butNotHashOnDevice_logsAnalytics.
// endregion
// region Form update analytics
@Test
public void whenDownloadingFormWithVersion_andId_butNotHashOnDevice_logsAnalytics() throws Exception {
String xform = FormUtils.createXFormBody("form", "version", "A title");
Form form = buildForm("form", "version", getFormFilesPath(), xform).build();
formsRepository.save(form);
String xform2 = FormUtils.createXFormBody("form2", "version", "A different title");
Form form2 = buildForm("form", "version", getFormFilesPath(), xform2).build();
ServerFormDetails serverFormDetails = new ServerFormDetails(form2.getDisplayName(), "http://downloadUrl", form2.getFormId(), form2.getVersion(), Md5.getMd5Hash(new ByteArrayInputStream(xform2.getBytes())), true, false, null);
FormSource formSource = mock(FormSource.class);
when(formSource.fetchForm("http://downloadUrl")).thenReturn(new ByteArrayInputStream(xform2.getBytes()));
Analytics mockAnalytics = mock(Analytics.class);
ServerFormDownloader downloader = new ServerFormDownloader(formSource, formsRepository, cacheDir, formsDir.getAbsolutePath(), new FormMetadataParser(), mockAnalytics);
downloader.downloadForm(serverFormDetails, null, null);
String formIdentifier = form.getDisplayName() + " " + form.getFormId();
String formIdHash = Md5.getMd5Hash(new ByteArrayInputStream(formIdentifier.getBytes()));
verify(mockAnalytics).logEventWithParam(DOWNLOAD_SAME_FORMID_VERSION_DIFFERENT_HASH, "form", formIdHash);
}
use of org.odk.collect.analytics.Analytics in project collect by opendatakit.
the class ServerFormDownloaderTest method whenDownloadingFormWithVersion_andId_andHashOnDevice_doesNotLogAnalytics.
@Test
public void whenDownloadingFormWithVersion_andId_andHashOnDevice_doesNotLogAnalytics() throws Exception {
String xform = FormUtils.createXFormBody("form", "version", "A title");
Form form = buildForm("form", "version", getFormFilesPath(), xform).build();
formsRepository.save(form);
String xform2 = FormUtils.createXFormBody("form2", "version", "A different title");
Form form2 = buildForm("form", "version", getFormFilesPath(), xform2).build();
formsRepository.save(form2);
ServerFormDetails serverFormDetails = new ServerFormDetails(form.getDisplayName(), "http://downloadUrl", form.getFormId(), form.getVersion(), Md5.getMd5Hash(new ByteArrayInputStream(xform.getBytes())), true, false, null);
FormSource formSource = mock(FormSource.class);
when(formSource.fetchForm("http://downloadUrl")).thenReturn(new ByteArrayInputStream(xform.getBytes()));
Analytics mockAnalytics = mock(Analytics.class);
ServerFormDownloader downloader = new ServerFormDownloader(formSource, formsRepository, cacheDir, formsDir.getAbsolutePath(), new FormMetadataParser(), mockAnalytics);
downloader.downloadForm(serverFormDetails, null, null);
verifyNoInteractions(mockAnalytics);
}
use of org.odk.collect.analytics.Analytics in project collect by opendatakit.
the class QuestionWidgetTest method overrideDependencyModule.
private void overrideDependencyModule() throws Exception {
ReferenceManager referenceManager = setupFakeReferenceManager(asList(new Pair<>("ref", "blah.mp3")));
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public AudioHelperFactory providesAudioHelperFactory(Scheduler scheduler) {
return context -> audioHelper;
}
@Override
public Analytics providesAnalytics(Application application) {
return analytics;
}
});
}
Aggregations