use of com.nightscout.core.preferences.TestPreferences in project android-uploader by nightscout.
the class AbstractRestUploaderTest method setUp.
@Before
public void setUp() throws Exception {
URI uri = URI.create("http://test.com");
restUploader = new NoopRestUploader(new TestPreferences(), uri);
mockHttpClient = mock(HttpClient.class);
restUploader.setClient(mockHttpClient);
captor = ArgumentCaptor.forClass(HttpUriRequest.class);
}
use of com.nightscout.core.preferences.TestPreferences in project android-uploader by nightscout.
the class UploaderTest method shouldSendToastIntentOnInvalidMongoUri.
@Test
public void shouldSendToastIntentOnInvalidMongoUri() throws Exception {
TestPreferences prefs = new TestPreferences();
prefs.setMongoUploadEnabled(true);
prefs.setMongoClientUri(null);
whenOnBroadcastReceived(ToastReceiver.ACTION_SEND_NOTIFICATION, new Function<Intent, Void>() {
@Override
public Void apply(Intent input) {
assertThat(input.getStringExtra(ToastReceiver.TOAST_MESSAGE), is(not(nullValue())));
assertThat(input.getStringExtra(ToastReceiver.TOAST_MESSAGE), is(getContext().getString(R.string.unknown_mongo_host)));
return null;
}
});
new Uploader(getContext(), prefs);
assertIntentSeen();
}
use of com.nightscout.core.preferences.TestPreferences in project android-uploader by nightscout.
the class UploaderTest method shouldSendToastIntentOnInvalidRestUri.
@Test
public void shouldSendToastIntentOnInvalidRestUri() throws Exception {
TestPreferences prefs = new TestPreferences();
prefs.setRestApiEnabled(true);
prefs.setRestApiBaseUris(Lists.newArrayList("\\invalid"));
whenOnBroadcastReceived(ToastReceiver.ACTION_SEND_NOTIFICATION, new Function<Intent, Void>() {
@Override
public Void apply(Intent input) {
assertThat(input.getStringExtra(ToastReceiver.TOAST_MESSAGE), is(not(nullValue())));
assertThat(input.getStringExtra(ToastReceiver.TOAST_MESSAGE), is(getContext().getString(R.string.illegal_rest_url)));
return null;
}
});
new Uploader(getContext(), prefs);
assertIntentSeen();
}
use of com.nightscout.core.preferences.TestPreferences in project android-uploader by nightscout.
the class UploaderTest method initializeShouldFailOnInvalidMongoUri.
@Test
public void initializeShouldFailOnInvalidMongoUri() throws Exception {
TestPreferences prefs = new TestPreferences();
prefs.setMongoUploadEnabled(true);
prefs.setMongoClientUri("http://test.com");
Uploader uploader = new Uploader(getContext(), prefs);
assertThat(uploader.areAllUploadersInitialized(), is(false));
}
use of com.nightscout.core.preferences.TestPreferences in project android-uploader by nightscout.
the class UploaderTest method shouldSendToastIntentOnInvalidRestv1Uri.
@Test
public void shouldSendToastIntentOnInvalidRestv1Uri() throws Exception {
TestPreferences prefs = new TestPreferences();
prefs.setRestApiEnabled(true);
prefs.setRestApiBaseUris(Lists.newArrayList("http://test/v1"));
whenOnBroadcastReceived(ToastReceiver.ACTION_SEND_NOTIFICATION, new Function<Intent, Void>() {
@Override
public Void apply(Intent input) {
assertThat(input.getStringExtra(ToastReceiver.TOAST_MESSAGE), is(not(nullValue())));
assertThat(input.getStringExtra(ToastReceiver.TOAST_MESSAGE), is(getContext().getString(R.string.illegal_rest_url)));
return null;
}
});
new Uploader(getContext(), prefs);
assertIntentSeen();
}
Aggregations