### Question:
SwrveDeeplinkManager { protected void queueDeeplinkGenericEvent(String adSource, String campaignId, String contextId, String actionType) throws JSONException { ISwrveCommon swrve = SwrveCommon.getInstance(); if (swrve != null && SwrveHelper.isNotNullOrEmpty(adSource) && SwrveHelper.isNotNullOrEmpty(contextId)) { Map<String, String> payload = new HashMap<>(); String id = "-1"; String campaignType = "external_source_" + adSource.toLowerCase(Locale.ENGLISH); ArrayList<String> events = EventHelper.createGenericEvent(id, campaignType, actionType, contextId, campaignId, payload, swrve.getNextSequenceNumber()); swrve.sendEventsInBackground(context, swrve.getUserId(), events); } else { SwrveLogger.e("Cannot queueDeeplinkGenericEvent: no SwrveSDK instance present or parameters were null"); } } SwrveDeeplinkManager(Map<String, String> standardParams, final SwrveConfig config, final Context context, SwrveAssetsManager swrveAssetsManager, IRESTClient restClient); SwrveMessage getSwrveMessage(); void setSwrveMessage(SwrveMessage swrveMessage); IRESTClient getRestClient(); void setRestClient(IRESTClient restClient); static final String SWRVE_AD_MESSAGE; public SwrveMessageListener swrveMessageListener; public SwrveConversationListener swrveConversationListener; }### Answer:
@Test public void testQueueDeeplinkGenericEvent_Queued() throws Exception { final String userId = swrveSpy.profileManager.getUserId(); Map<String, String> params = swrveSpy.getContentRequestParams(userId); SwrveDeeplinkManager swrveDeeplinkManager = new SwrveDeeplinkManager(params, swrveSpy.getConfig(), swrveSpy.getContext(), swrveSpy.swrveAssetsManager, swrveSpy.restClient); SwrveDeeplinkManager swrveDeeplinkManagerSpy = Mockito.spy(swrveDeeplinkManager); swrveSpy.swrveDeeplinkManager = swrveDeeplinkManagerSpy; swrveDeeplinkManagerSpy.queueDeeplinkGenericEvent("facebook", "291145", "blackfriday", "install"); 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("install")); assertTrue(jObj.get(GENERIC_EVENT_CONTEXT_ID_KEY).equals("blackfriday")); assertTrue(jObj.get(GENERIC_EVENT_CAMPAIGN_ID_KEY).equals("291145")); }