<commit_before>package org.dswarm.controller.resources.resource.test;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import javax.ws.rs.core.Response;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.DatasetFactory;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import org.apache.commons.io.FileUtils;
import org.apache.http.HttpStatus;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.dswarm.common.MediaTypeUtil;
import org.dswarm.controller.resources.resource.test.utils.DataModelsResourceTestUtils;
import org.dswarm.controller.resources.resource.test.utils.ExportTestUtils;
import org.dswarm.controller.resources.resource.test.utils.ResourcesResourceTestUtils;
import org.dswarm.controller.resources.test.ResourceTest;
import org.dswarm.controller.test.GuicedTest;
import org.dswarm.graph.rdf.utils.RDFUtils;
import org.dswarm.persistence.DMPPersistenceException;
// import org.dswarm.persistence.model.internal.Model;
import org.dswarm.persistence.model.resource.Configuration;
import org.dswarm.persistence.model.resource.DataModel;
import org.dswarm.persistence.model.resource.Resource;
import org.dswarm.persistence.service.internal.test.utils.InternalGDMGraphServiceTestUtils;
import org.dswarm.persistence.util.DMPPersistenceUtil;

/**
 * Created by tgaengler on 28/04/14.
 * 
 * @author tgaengler
 */
public class RDFResourceTest extends ResourceTest {

	private static final Logger					LOG				= LoggerFactory.getLogger(RDFResourceTest.class);

	private final ResourcesResourceTestUtils	resourcesResourceTestUtils;

	private final DataModelsResourceTestUtils	dataModelsResourceTestUtils;

	protected final ObjectMapper				objectMapper	= GuicedTest.injector.getInstance(ObjectMapper.class);

	public RDFResourceTest() {

		super("rdf");

		resourcesResourceTestUtils = new ResourcesResourceTestUtils();
		dataModelsResourceTestUtils = new DataModelsResourceTestUtils();

		initObjects();
	}

	/**
	 * reset mysql and graph db
	 * 
	 * @throws DMPPersistenceException
	 */
	@After
	public void tearDown2() throws DMPPersistenceException {
		maintainDBService.initDB();
		InternalGDMGraphServiceTestUtils.cleanGraphDB();
	}

	@Test
	public void testExportAllNQuads() throws Exception {

		exportInternal(MediaTypeUtil.N_QUADS, HttpStatus.SC_OK, Lang.NQUADS, ".nq");
	}

	@Test
	public void testExportAllTriG() throws Exception {

		exportInternal(MediaTypeUtil.TRIG, HttpStatus.SC_OK, Lang.TRIG, ".trig");
	}

	@Test
	public void testExportUnsupportedFormat() throws Exception {

		exportInternal(MediaTypeUtil.RDF_XML, HttpStatus.SC_NOT_ACCEPTABLE, null, null);
	}

	@Test
	public void testExportRandomFormat() throws Exception {

		exportInternal("khlav/kalash", HttpStatus.SC_NOT_ACCEPTABLE, null, null);
	}
<commit_msg>[TASK][DD-668] unit tests /rdf/exportall default format<commit_after>package org.dswarm.controller.resources.resource.test;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import javax.ws.rs.core.Response;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.DatasetFactory;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import org.apache.commons.io.FileUtils;
import org.apache.http.HttpStatus;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.dswarm.common.MediaTypeUtil;
import org.dswarm.controller.resources.resource.test.utils.DataModelsResourceTestUtils;
import org.dswarm.controller.resources.resource.test.utils.ExportTestUtils;
import org.dswarm.controller.resources.resource.test.utils.ResourcesResourceTestUtils;
import org.dswarm.controller.resources.test.ResourceTest;
import org.dswarm.controller.test.GuicedTest;
import org.dswarm.graph.rdf.utils.RDFUtils;
import org.dswarm.persistence.DMPPersistenceException;
// import org.dswarm.persistence.model.internal.Model;
import org.dswarm.persistence.model.resource.Configuration;
import org.dswarm.persistence.model.resource.DataModel;
import org.dswarm.persistence.model.resource.Resource;
import org.dswarm.persistence.service.internal.test.utils.InternalGDMGraphServiceTestUtils;
import org.dswarm.persistence.util.DMPPersistenceUtil;

/**
 * Created by tgaengler on 28/04/14.
 * 
 * @author tgaengler
 */
public class RDFResourceTest extends ResourceTest {

	private static final Logger					LOG				= LoggerFactory.getLogger(RDFResourceTest.class);

	private final ResourcesResourceTestUtils	resourcesResourceTestUtils;

	private final DataModelsResourceTestUtils	dataModelsResourceTestUtils;

	protected final ObjectMapper				objectMapper	= GuicedTest.injector.getInstance(ObjectMapper.class);

	public RDFResourceTest() {

		super("rdf");

		resourcesResourceTestUtils = new ResourcesResourceTestUtils();
		dataModelsResourceTestUtils = new DataModelsResourceTestUtils();

		initObjects();
	}

	/**
	 * reset mysql and graph db
	 * 
	 * @throws DMPPersistenceException
	 */
	@After
	public void tearDown2() throws DMPPersistenceException {
		maintainDBService.initDB();
		InternalGDMGraphServiceTestUtils.cleanGraphDB();
	}

	@Test
	public void testExportAllNQuads() throws Exception {

		exportInternal(MediaTypeUtil.N_QUADS, HttpStatus.SC_OK, Lang.NQUADS, ".nq");
	}

	@Test
	public void testExportAllTriG() throws Exception {

		exportInternal(MediaTypeUtil.TRIG, HttpStatus.SC_OK, Lang.TRIG, ".trig");
	}

	@Test
	public void testExportAllDefaultFormat() throws Exception {

		exportInternal("", HttpStatus.SC_OK, Lang.NQUADS, ".nq");
	}

	@Test
	public void testExportUnsupportedFormat() throws Exception {

		exportInternal(MediaTypeUtil.RDF_XML, HttpStatus.SC_NOT_ACCEPTABLE, null, null);
	}

	@Test
	public void testExportRandomFormat() throws Exception {

		exportInternal("khlav/kalash", HttpStatus.SC_NOT_ACCEPTABLE, null, null);
	}

{'fraction_non_alphanumeric': 0.10183587007688687, 'fraction_numerical': 0.0032951514200533502, 'mean_word_length': 5.84640171858217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1570578', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1969, 'n_words': 347}