Search in sources :

Example 1 with ServerFormsDetailsFetcher

use of org.odk.collect.android.formmanagement.ServerFormsDetailsFetcher in project collect by opendatakit.

the class DownloadFormListTaskTest method whenAlternateCredentialsAreSet_shouldServerFormsDetailsFetcherBeUpdated.

@Test
public void whenAlternateCredentialsAreSet_shouldServerFormsDetailsFetcherBeUpdated() {
    ServerFormsDetailsFetcher serverFormsDetailsFetcher = mock(ServerFormsDetailsFetcher.class);
    WebCredentialsUtils webCredentialsUtils = mock(WebCredentialsUtils.class);
    DownloadFormListTask task = new DownloadFormListTask(serverFormsDetailsFetcher);
    task.setAlternateCredentials(webCredentialsUtils, "https://test-server.com", "testUser", "testPassword");
    verify(serverFormsDetailsFetcher).updateUrl("https://test-server.com");
    verify(serverFormsDetailsFetcher).updateCredentials(webCredentialsUtils);
}
Also used : ServerFormsDetailsFetcher(org.odk.collect.android.formmanagement.ServerFormsDetailsFetcher) DownloadFormListTask(org.odk.collect.android.tasks.DownloadFormListTask) WebCredentialsUtils(org.odk.collect.android.utilities.WebCredentialsUtils) Test(org.junit.Test)

Example 2 with ServerFormsDetailsFetcher

use of org.odk.collect.android.formmanagement.ServerFormsDetailsFetcher in project collect by opendatakit.

the class DownloadFormListTaskTest method whenAlternateCredentialsDoNotContainUrl_shouldNotUrlBeUpdated.

@Test
public void whenAlternateCredentialsDoNotContainUrl_shouldNotUrlBeUpdated() {
    ServerFormsDetailsFetcher serverFormsDetailsFetcher = mock(ServerFormsDetailsFetcher.class);
    WebCredentialsUtils webCredentialsUtils = mock(WebCredentialsUtils.class);
    DownloadFormListTask task = new DownloadFormListTask(serverFormsDetailsFetcher);
    task.setAlternateCredentials(webCredentialsUtils, null, "testUser", "testPassword");
    verify(serverFormsDetailsFetcher, never()).updateUrl(anyString());
    verify(serverFormsDetailsFetcher).updateCredentials(webCredentialsUtils);
    task.setAlternateCredentials(webCredentialsUtils, "", "testUser", "testPassword");
    verify(serverFormsDetailsFetcher, never()).updateUrl(anyString());
    verify(serverFormsDetailsFetcher, times(2)).updateCredentials(webCredentialsUtils);
}
Also used : ServerFormsDetailsFetcher(org.odk.collect.android.formmanagement.ServerFormsDetailsFetcher) DownloadFormListTask(org.odk.collect.android.tasks.DownloadFormListTask) WebCredentialsUtils(org.odk.collect.android.utilities.WebCredentialsUtils) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ServerFormsDetailsFetcher (org.odk.collect.android.formmanagement.ServerFormsDetailsFetcher)2 DownloadFormListTask (org.odk.collect.android.tasks.DownloadFormListTask)2 WebCredentialsUtils (org.odk.collect.android.utilities.WebCredentialsUtils)2