static Map<String, Object> addField(Map<String, Object> event, Map<String, Object> fieldsToAdd) {
        Event tempEvent = new org.logstash.Event(event);
        addField(tempEvent, fieldsToAdd);
        return tempEvent.getData();
    }
@Test
    public void testAddField() {
        // add field to empty event
        Event e = new Event();
        String testField = "test_field";
        String testStringValue = "test_value";
        CommonActions.addField(e, Collections.singletonMap(testField, testStringValue));
        Assert.assertEquals(testStringValue, e.getField(testField));

        // add to existing field and convert to array value
        e = new Event(Collections.singletonMap(testField, testStringValue));
        CommonActions.addField(e, Collections.singletonMap(testField, testStringValue));
        Object value = e.getField(testField);
        Assert.assertTrue(value instanceof List);
        Assert.assertEquals(2, ((List) value).size());
        Assert.assertEquals(testStringValue, ((List) value).get(0));
        Assert.assertEquals(testStringValue, ((List) value).get(1));

        // add to existing array field
        String testStringValue2 = "test_value2";
        List<String> stringVals = Arrays.asList(testStringValue, testStringValue2);
        e = new Event(Collections.singletonMap(testField, stringVals));
        CommonActions.addField(e, Collections.singletonMap(testField, testStringValue));
        value = e.getField(testField);
        Assert.assertTrue(value instanceof List);
        Assert.assertEquals(3, ((List) value).size());
        Assert.assertEquals(testStringValue, ((List) value).get(0));
        Assert.assertEquals(testStringValue2, ((List) value).get(1));
        Assert.assertEquals(testStringValue, ((List) value).get(2));

        // add non-string value to empty event
        Long testLongValue = 42L;
        e = new Event();
        CommonActions.addField(e, Collections.singletonMap(testField, testLongValue));
        Assert.assertEquals(testLongValue, e.getField(testField));

        // add non-string value to existing field
        e = new Event(Collections.singletonMap(testField, testStringValue));
        CommonActions.addField(e, Collections.singletonMap(testField, testLongValue));
        value = e.getField(testField);
        Assert.assertTrue(value instanceof List);
        Assert.assertEquals(2, ((List) value).size());
        Assert.assertEquals(testStringValue, ((List) value).get(0));
        Assert.assertEquals(testLongValue, ((List) value).get(1));

        // add non-string value to existing array field
        e = new Event(Collections.singletonMap(testField, stringVals));
        CommonActions.addField(e, Collections.singletonMap(testField, testLongValue));
        value = e.getField(testField);
        Assert.assertTrue(value instanceof List);
        Assert.assertEquals(3, ((List) value).size());
        Assert.assertEquals(testStringValue, ((List) value).get(0));
        Assert.assertEquals(testStringValue2, ((List) value).get(1));
        Assert.assertEquals(testLongValue, ((List) value).get(2));

        // add field/value with dynamic values
        e = new Event(Collections.singletonMap(testField, testStringValue));
        String newField = "%{" + testField + "}_field";
        String newValue = "%{" + testField + "}_value";
        CommonActions.addField(e, Collections.singletonMap(newField, newValue));
        Assert.assertEquals(testStringValue + "_value", e.getField(testStringValue + "_field"));
    }