How to make android unit test for notifications?

Viewed 5798

I have the class handleFirebaseMessages . It contains the function onMessageReceived() . This function is in charge of receiving data and creating notifications. onMessageReceived() receives data in a RemoteMessages object. I am trying to write a test for this function. But I've not got it completely.

HandleFirebaseMessages

public class HandleFirebaseMessages extends FirebaseMessagingService {
@Override
    public void onMessageReceived(final RemoteMessage remoteMessage) {
   final Map<String, String> data = remoteMessage.getData();
    //create notifications using NotificationCompat.Builder
    }
 }

I've been able to write a part of the test code. How do I complete this?

@Test
public  void testHandleFirebaseMessages() throws  Exception {

    Map<String,String> data=new HashMap<String,String>();
    data.put("id","4422");
    data.put("type", "1");
    data.put("imageUrl" , "https://image.freepik.com/free-vector/android-boot-logo_634639.jpg");
    data.put("smallTitle" , "DoJMA v2");
    data.put("smallSubTitle", "Update now from Google Play Store");
    data.put("ticker" , "New update for DoJMA");
    data.put("contentInfo" , "");
    data.put("link" , "https://photo2.tinhte.vn/data/avatars/l/1885/1885712.jpg?1402763583");
    data.put("className" , "HomeActivity");
    data.put("page" , "2");
    data.put("bigTitle" , "DoJMA Android app version 2 released!");
    data.put("bigSubTitle" , "Hi folks! New DoJMA update is here! Major redesigning and improvements! This app was made by the Mobile App Club.They work really hard man...and get good products");
    data.put("bigSummaryText" , "Update now");


    RemoteMessage message = new RemoteMessage.Builder("1")
            .setMessageId("1")
            .setData(data)
            .build();
    (new HandleFirebaseMessages()).onMessageReceived(message);

    //WHat now?
}
2 Answers
Related