    @Test
    public void testHandleDeeplink_Message() throws Exception {


        // 1. Test generic_campaign_event queued / sent
        // 2. Test message was shown
        // 3. Test message details were written to cache (for QA purposes)

        Bundle bundle = new Bundle();
        bundle.putString("target_url","swrve://app?ad_content=295411&ad_source=facebook&ad_campaign=BlackFriday");

        swrveSpy.swrveDeeplinkManager.handleDeeplink(bundle);

        //*** 1. Generic Event is queued

        ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
        ArgumentCaptor<String> userIdCaptor = ArgumentCaptor.forClass(String.class);
        ArgumentCaptor<ArrayList> events = ArgumentCaptor.forClass(ArrayList.class);
        Mockito.verify(swrveSpy, Mockito.atLeastOnce()).sendEventsInBackground(contextCaptor.capture(), userIdCaptor.capture(), events.capture());

        List<ArrayList> capturedProperties = events.getAllValues();
        String jsonString = capturedProperties.get(0).get(0).toString();
        JSONObject jObj = new JSONObject(jsonString);

        assertTrue(jObj.has("time"));
        assertTrue(jObj.has("seqnum"));
        assertTrue(jObj.get("type").equals(EVENT_TYPE_GENERIC_CAMPAIGN));
        assertTrue(jObj.get("id").equals("-1"));
        assertTrue(jObj.get(GENERIC_EVENT_CAMPAIGN_TYPE_KEY).equals("external_source_facebook"));
        assertTrue(jObj.get(GENERIC_EVENT_ACTION_TYPE_KEY).equals("reengage"));
        assertTrue(jObj.get(GENERIC_EVENT_CONTEXT_ID_KEY).equals("BlackFriday"));
        assertTrue(jObj.get(GENERIC_EVENT_CAMPAIGN_ID_KEY).equals("295411"));

        // 2. Test In-app message was shown

        await().until(campaignShown());

        ShadowActivity shadowMainActivity = Shadows.shadowOf(mActivity);
        Intent nextIntent = shadowMainActivity.peekNextStartedActivity();
        assertNotNull(nextIntent);
        assertEquals(nextIntent.getComponent(), new ComponentName(mActivity, SwrveInAppMessageActivity.class));
        Bundle extras = nextIntent.getExtras();
        assertNotNull(extras);

        boolean state = extras.getBoolean(SWRVE_AD_MESSAGE);
        assertTrue(state);

        SwrveMessage message = swrveSpy.getAdMesage();

        assertEquals(message.getId(), 298085);
        assertThat(message.getName(), equalTo("Double format"));

        // 3. Message Cached

        ISwrveCommon swrveCommon = SwrveCommon.getInstance();
        final String userId = swrveCommon.getUserId();
        String adCampaigns = swrveSpy.multiLayerLocalStorage.getCacheEntry(userId, CACHE_AD_CAMPAIGNS_DEBUG);
        JSONObject rootJson = new JSONObject(adCampaigns);
        JSONObject campaignJson = rootJson.getJSONObject("campaign");
        assertEquals(campaignJson.getInt("id"), 295411);
        assertEquals(campaignJson.get("subject"), "Facebook Ad Message");
        assertTrue(campaignJson.has("messages"));
    }