Sha256: 174ee8bd07fc3e2222b9c64cb66a3a287a3c820e3d855d7c41d5056ac70cb6c1

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

package org.embulk.input.jira;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.google.common.io.Resources;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;

import org.embulk.config.ConfigLoader;
import org.embulk.config.ConfigSource;
import org.embulk.config.ModelManager;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public final class TestHelpers
{
    private TestHelpers() {}

    public static JsonObject getJsonFromFile(final String fileName) throws IOException
     {
        final String path = Resources.getResource(fileName).getPath();
        try (JsonReader reader = new JsonReader(new FileReader(path))) {
            final JsonParser parser = new JsonParser();
            return parser.parse(reader).getAsJsonObject();
        }
    }

    public static ConfigSource config() throws IOException
    {
        final String path = Resources.getResource("config.yml").getPath();
        final ObjectMapper mapper = new ObjectMapper()
                .registerModule(new GuavaModule())
                .registerModule(new Jdk8Module());
        final ConfigLoader configLoader = new ConfigLoader(new ModelManager(null, mapper));
        return configLoader.fromYamlFile(new File(path));
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
embulk-input-jira-0.2.10 src/test/java/org/embulk/input/jira/TestHelpers.java