/*
 * Copyright 2015 Dmitry Ustalov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package mtsar;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.jackson.Jackson;
import io.dropwizard.testing.FixtureHelpers;

import java.io.IOException;

public final class TestHelper {
    private static final ObjectMapper JSON = Jackson.newObjectMapper();

    public static <T> T fixture(String filename, Class<T> valueType) {
        try {
            return JSON.readValue(FixtureHelpers.fixture("fixtures/" + filename), valueType);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

@@ -608,16 +608,70 @@
 mtsar;%0A%0A
+import com.fasterxml.jackson.core.type.TypeReference;%0A
 import c
@@ -813,396 +813,1511 @@
 java
-.io.IOException;%0A%0Apublic final class TestHelper %7B%0A    private static final ObjectMapper JSON = Jackson.newObjectMapper();%0A%0A    public static %3CT%3E T fixture(String filename, Class%3CT%3E valueType) %7B%0A        try %7B%0A            return JSON.readValue(FixtureHelpers.fixture(%22fixtures/%22 + filename), valueType);%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(e);%0A        %7D
+x.annotation.Nonnull;%0Aimport javax.ws.rs.core.MultivaluedHashMap;%0Aimport javax.ws.rs.core.MultivaluedMap;%0Aimport java.io.IOException;%0Aimport java.util.Collection;%0Aimport java.util.Map;%0A%0Apublic final class TestHelper %7B%0A    public static final TypeReference%3CMap%3CString, Object%3E%3E MAP_STRING_TO_OBJECT = new TypeReference%3CMap%3CString, Object%3E%3E() %7B%0A    %7D;%0A%0A    private static final ObjectMapper JSON = Jackson.newObjectMapper();%0A%0A    public static %3CT%3E T fixture(String filename, Class%3CT%3E valueType) %7B%0A        try %7B%0A            return JSON.readValue(FixtureHelpers.fixture(%22fixtures/%22 + filename), valueType);%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    public static %3CT%3E MultivaluedMap%3CString, String%3E params(@Nonnull T object) %7B%0A        final MultivaluedMap%3CString, String%3E params = new MultivaluedHashMap%3C%3E();%0A        final Map%3CString, Object%3E attributes = JSON.convertValue(object, MAP_STRING_TO_OBJECT);%0A        for (final Map.Entry%3CString, Object%3E attribute : attributes.entrySet()) %7B%0A            if (attribute.getValue() instanceof Collection) %7B%0A                for (final Object item : (Collection)attribute.getValue()) %7B%0A                    params.add(attribute.getKey(), item.toString());%0A                %7D%0A            %7D else %7B%0A                params.add(attribute.getKey(), attribute.getValue().toString());%0A            %7D%0A        %7D%0A        params.remove(%22id%22);%0A        params.addAll(%22datetime%22, params.remove(%22dateTime%22));%0A        return params;
 %0A   

Add TestHelper.params