use of org.infobip.mobile.messaging.api.registration.MobileApiRegistration in project mobile-messaging-sdk-android by infobip.
the class RetryableSynchronizersTest method setUp.
@SuppressLint("CommitPrefEdits")
@Override
public void setUp() throws Exception {
super.setUp();
MobileMessagingStats stats = mobileMessagingCore.getStats();
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.REPORT_SYSTEM_INFO, true);
PreferenceHelper.saveInt(context, MobileMessagingProperty.DEFAULT_EXP_BACKOFF_MULTIPLIER, 0);
PreferenceHelper.remove(context, MobileMessagingProperty.REPORTED_SYSTEM_DATA_HASH);
mobileMessageHandler = mock(MobileMessageHandler.class);
mobileApiData = mock(MobileApiData.class);
mobileApiMessages = mock(MobileApiMessages.class);
mobileApiRegistration = mock(MobileApiRegistration.class);
given(mobileApiData.reportUserData(anyString(), any(UserDataReport.class))).willThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error")));
doThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error"))).when(mobileApiData).reportSystemData(any(SystemDataReport.class));
given(mobileApiMessages.sync(any(SyncMessagesBody.class))).willThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error")));
given(mobileApiRegistration.upsert(anyString(), anyBoolean())).willThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error")));
RetryPolicyProvider retryPolicyProvider = new RetryPolicyProvider(context);
retryPolicy = retryPolicyProvider.DEFAULT();
executor = Executors.newSingleThreadExecutor();
systemDataReporter = new SystemDataReporter(mobileMessagingCore, stats, retryPolicy, executor, broadcaster, mobileApiData);
messagesSynchronizer = new MessagesSynchronizer(mobileMessagingCore, stats, executor, broadcaster, retryPolicy, mobileMessageHandler, mobileApiMessages);
registrationSynchronizer = new RegistrationSynchronizer(context, mobileMessagingCore, stats, executor, broadcaster, retryPolicyProvider, mobileApiRegistration);
userDataReporter = new UserDataReporter(mobileMessagingCore, executor, broadcaster, retryPolicyProvider, stats, mobileApiData);
}
use of org.infobip.mobile.messaging.api.registration.MobileApiRegistration in project mobile-messaging-sdk-android by infobip.
the class MobileApiRegistrationTest method setUp.
@Before
public void setUp() throws Exception {
debugServer = new DebugServer();
debugServer.start();
Properties properties = new Properties();
properties.put("api.key", "my_API_key");
Generator generator = new Generator.Builder().withBaseUrl("http://127.0.0.1:" + debugServer.getListeningPort() + "/").withProperties(properties).build();
mobileApiRegistration = generator.create(MobileApiRegistration.class);
}
use of org.infobip.mobile.messaging.api.registration.MobileApiRegistration in project mobile-messaging-sdk-android by infobip.
the class MobileMessagingTestCase method setUp.
@SuppressLint("ApplySharedPref")
@Before
public void setUp() throws Exception {
super.setUp();
PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
PreferenceHelper.saveString(context, MobileMessagingProperty.API_URI, "http://127.0.0.1:" + debugServer.getListeningPort() + "/");
PreferenceHelper.saveString(context, MobileMessagingProperty.APPLICATION_CODE, "TestApplicationCode");
PreferenceHelper.saveString(context, MobileMessagingProperty.INFOBIP_REGISTRATION_ID, "TestDeviceInstanceId");
PreferenceHelper.saveString(context, MobileMessagingProperty.GCM_REGISTRATION_ID, "TestRegistrationId");
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.GCM_REGISTRATION_ID_REPORTED, true);
MobileMessagingLogger.enforce();
time = new TestTimeProvider();
Time.reset(time);
notificationHandler = mock(NotificationHandler.class);
coreBroadcaster = mock(Broadcaster.class);
mobileApiMessages = mock(MobileApiMessages.class);
mobileApiRegistration = mock(MobileApiRegistration.class);
mobileApiResourceProvider = mock(MobileApiResourceProvider.class);
given(mobileApiResourceProvider.getMobileApiMessages(any(Context.class))).willReturn(mobileApiMessages);
given(mobileApiResourceProvider.getMobileApiRegistration(any(Context.class))).willReturn(mobileApiRegistration);
mobileMessagingCore = MobileMessagingTestable.create(context, coreBroadcaster, mobileApiResourceProvider);
mobileMessaging = mobileMessagingCore;
geofencingHelper = new GeofencingHelper(context);
geoBroadcaster = mock(GeoBroadcaster.class);
geofencingHelper.removeUnreportedGeoEvents();
databaseHelper = MobileMessagingCore.getDatabaseHelper(context);
databaseProvider = MobileMessagingCore.getDatabaseProvider(context);
geoStore = geofencingHelper.getMessageStoreForGeo();
}
Aggregations