All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.drus.jpa.unit.mongodb.DataSetLoaderProvider Maven / Gradle / Ivy

The newest version!
package eu.drus.jpa.unit.mongodb;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

import org.bson.Document;

import eu.drus.jpa.unit.spi.DataSetFormat.LoaderProvider;
import eu.drus.jpa.unit.spi.DataSetLoader;
import eu.drus.jpa.unit.spi.UnsupportedDataSetFormatException;

public class DataSetLoaderProvider implements LoaderProvider {

    @Override
    public DataSetLoader xmlLoader() {
        throw new UnsupportedDataSetFormatException("XML data sets are not supportred for MongoDB");
    }

    @Override
    public DataSetLoader yamlLoader() {
        throw new UnsupportedDataSetFormatException("YAML data sets are not supportred for MongoDB");
    }

    @Override
    public DataSetLoader jsonLoader() {
        return (final File path) -> Document.parse(new String(Files.readAllBytes(path.toPath()), StandardCharsets.UTF_8));
    }

    @Override
    public DataSetLoader csvLoader() {
        throw new UnsupportedDataSetFormatException("CSV data sets are not supportred for MongoDB");
    }

    @Override
    public DataSetLoader xlsLoader() {
        throw new UnsupportedDataSetFormatException("XSL data sets are not supportred for MongoDB");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy