Skip to content

Commit

Permalink
MM-1410 - Refactoring and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislavin committed Mar 15, 2017
1 parent feebcf0 commit 99696cc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.infobip.mobile.messaging;

import org.infobip.mobile.messaging.platform.Time;
import org.infobip.mobile.messaging.storage.SQLiteMessageStore;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;

/**
* @author sslavin
Expand All @@ -15,8 +13,7 @@ public class SeenStatusStorageTest extends MobileMessagingTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();

PreferenceHelper.saveString(context, MobileMessagingProperty.MESSAGE_STORE_CLASS, SQLiteMessageStore.class.getName());
enableMessageStoreForReceivedMessages();
}

public void test_shouldUpdateSeenTimestampInMessageStore() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import org.infobip.mobile.messaging.Message;
import org.infobip.mobile.messaging.MobileMessaging;
import org.infobip.mobile.messaging.MobileMessagingCore;
import org.infobip.mobile.messaging.MobileMessagingProperty;
import org.infobip.mobile.messaging.geo.Geo;
import org.infobip.mobile.messaging.storage.MessageStore;
import org.infobip.mobile.messaging.storage.SQLiteMessageStore;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.mockito.Mockito;

import java.util.List;
Expand All @@ -22,19 +18,15 @@ public class MobileMessageHandlerTest extends MobileMessagingTestCase {

private MobileMessageHandler handler;
private MessageStore commonStore;
private MessageStore geoStore;

@Override
protected void setUp() throws Exception {
super.setUp();

PreferenceHelper.saveString(context, MobileMessagingProperty.MESSAGE_STORE_CLASS, SQLiteMessageStore.class.getName());
enableMessageStoreForReceivedMessages();

handler = new MobileMessageHandler(broadcaster);
commonStore = MobileMessaging.getInstance(context).getMessageStore();
commonStore.deleteAll(context);
geoStore = MobileMessagingCore.getInstance(context).getMessageStoreForGeo();
geoStore.deleteAll(context);
}

public void test_shouldSaveGeoMessageToGeoStore() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ public void test_should_generate_messages_only_for_active_campaigns() throws Int
// Given
Area area = createArea("areaId1");
Mockito.when(messageStore.findAll(Mockito.any(Context.class))).thenReturn(Arrays.asList(
createMessage(context,"signalingMessageId1", "campaignId1", false, area),
createMessage(context,"signalingMessageId2", "campaignId2", false, area),
createMessage(context,"signalingMessageId3", "campaignId3", false, area)));
createMessage(context,"signalingMessageId1", "campaignId1", true, area),
createMessage(context,"signalingMessageId2", "campaignId2", true, area),
createMessage(context,"signalingMessageId3", "campaignId3", true, area)));
EventReportResponse response = new EventReportResponse();
response.setSuspendedCampaignIds(Sets.newSet("campaignId1"));
response.setFinishedCampaignIds(Sets.newSet("campaignId2"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
import org.infobip.mobile.messaging.mobile.geo.GeoReporter;
import org.infobip.mobile.messaging.storage.MessageStore;
import org.infobip.mobile.messaging.storage.SQLiteMessageStore;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.mockito.ArgumentCaptor;
Expand Down Expand Up @@ -41,7 +40,7 @@ protected void setUp() throws Exception {
super.setUp();

// Enable message store for notification messages
PreferenceHelper.saveString(context, MobileMessagingProperty.MESSAGE_STORE_CLASS, SQLiteMessageStore.class.getName());
enableMessageStoreForReceivedMessages();

messageStore = MobileMessaging.getInstance(context).getMessageStore();
geoReporter = new GeoReporter(context, broadcaster, MobileMessagingCore.getInstance(context).getStats());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import com.google.android.gms.location.Geofence;

import org.infobip.mobile.messaging.MobileMessagingProperty;
import org.infobip.mobile.messaging.api.support.Tuple;
import org.infobip.mobile.messaging.platform.Time;
import org.infobip.mobile.messaging.storage.SQLiteMessageStore;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.DateTimeUtil;
import org.infobip.mobile.messaging.util.PreferenceHelper;

import java.util.Date;
import java.util.List;
Expand All @@ -28,7 +25,7 @@ protected void setUp() throws Exception {

now = Time.now();

PreferenceHelper.saveString(context, MobileMessagingProperty.MESSAGE_STORE_CLASS, SQLiteMessageStore.class.getName());
enableMessageStoreForReceivedMessages();
Geofencing.getInstance(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.infobip.mobile.messaging.gcm.MobileMessageHandler;
import org.infobip.mobile.messaging.platform.Time;
import org.infobip.mobile.messaging.storage.MessageStore;
import org.infobip.mobile.messaging.storage.SQLiteMessageStore;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.DateTimeUtil;
import org.infobip.mobile.messaging.util.PreferenceHelper;
Expand All @@ -29,9 +28,8 @@ public class MobileMessageHandlerTest extends MobileMessagingTestCase {
protected void setUp() throws Exception {
super.setUp();

context = getInstrumentation().getContext();
enableMessageStoreForReceivedMessages();

PreferenceHelper.saveString(context, MobileMessagingProperty.MESSAGE_STORE_CLASS, SQLiteMessageStore.class.getName());
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.PUSH_REGISTRATION_ENABLED, true);
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.GEOFENCING_ACTIVATED, true);

Expand Down

0 comments on commit 99696cc

Please sign in to comment.