package org.valuereporter.agent.activity;

import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

/**
 * Created by baardl on 02.03.16.
 */
public class CommandSendActivitiesTest {

    private ObjectMapper objectMapper;
    private CommandSendActivities sendActivities;

    @BeforeMethod
    public void setUp() throws Exception {
        objectMapper = new ObjectMapper();



    }

    @Test
    public void testBuildJson() throws Exception {
        List<ObservedActivity> observedActivities = new ArrayList();
        ObservedActivity observedActivity = new ObservedActivity("logon",1456904461955L);
        observedActivity.put("userId", "me");
        observedActivities.add(observedActivity);
        sendActivities = new CommandSendActivities(null,null,"test",observedActivities);
        String observedActivitiesJson = sendActivities.getObservedActivitiesJson();
        assertNotNull(observedActivitiesJson);
        assertEquals(observedActivitiesJson, expectedSingle);

    }

    private static final String expectedSingle = "[{\"name\":\"logon\",\"startTime\":1456904461955,\"data\":{\"userId\":\"me\"}}]";
}
@@ -82,16 +82,41 @@
 Mapper;%0A
+import org.slf4j.Logger;%0A
 import o
@@ -237,62 +237,63 @@
 til.
-HashMap
+List
 ;%0A
+%0A
 import 
-java.util.List;%0Aimport java.util.Map;%0A
+static org.slf4j.LoggerFactory.getLogger;
 %0Aimp
@@ -465,16 +465,98 @@
 esTest %7B
+%0A    private static final Logger log = getLogger(CommandSendActivitiesTest.class);
 %0A%0A    pr
@@ -1355,24 +1355,1257 @@
 e);%0A%0A    %7D%0A%0A
+    public static void main(String%5B%5D args) %7B%0A        List%3CObservedActivity%3E observedActivities = new ArrayList();%0A        ObservedActivity userSession = new ObservedActivity(%22userSession%22, System.currentTimeMillis());%0A        userSession.put(%22usersessionfunction%22,%22userSessionAccess%22);%0A        userSession.put(%22applicationid%22,%22100%22);%0A        userSession.put(%22userid%22, %22test-only%22);%0A        userSession.put(%22applicationtokenid%22, %22to-be-set%22);%0A        observedActivities.add(userSession);%0A        ObservedActivity userLogon = new ObservedActivity(%22userLogon%22, System.currentTimeMillis());%0A        userLogon.put(%22usersessionfunction%22,%22userLogon%22);%0A        userLogon.put(%22applicationid%22,%22100%22);%0A        userLogon.put(%22userid%22, %22test-only%22);%0A        userLogon.put(%22applicationtokenid%22, %22to-be-set%22);%0A        observedActivities.add(userLogon);%0A        String host = %22localhost%22;%0A        String port = %224901%22;%0A        String prefix = %22initial%22;%0A        //Send%0A        CommandSendActivities sendActivities = new CommandSendActivities(host,port,prefix,observedActivities);%0A        //Validate%0A        String observedActivitiesJson = sendActivities.getObservedActivitiesJson();%0A        log.info(%22Received %7B%7D%22, observedActivitiesJson);%0A%0A%0A    %7D%0A%0A
     private 

Test sending UserActivity to ValueReporter.