package com.taxonic.rml.engine;

import static org.junit.Assert.*;

import java.util.List;

import org.eclipse.rdf4j.model.Model;
import org.junit.Before;
import org.junit.Test;

import com.taxonic.rml.model.TriplesMap;
import com.taxonic.rml.util.IoUtils;
import com.taxonic.rml.util.RmlMappingLoader;

// TODO consider dynamically creating tests using junit and just iterating over sets of input files

public class RmlMapperTest {

	private RmlMappingLoader loader = RmlMappingLoader.build();
	
	private RmlMapper mapper;
	
	// create a fresh mapper for every @Test
	@Before
	public void createMapper() {
		mapper = new RmlMapper();
	}
	
	@Test
	public void testConstantSubjectShortcutMapping() {
		testMapping("test1/constantSubjectShortcutMapping");
	}
	
	private void testMapping(String resourceBaseName) {
		List<TriplesMap> mapping = loader.load(resourceBaseName + ".rml.ttl");
		Model result = mapper.map(mapping);
		Model expected = IoUtils.parse(resourceBaseName + ".output.ttl");
		assertEquals(expected, result);
	}

}

@@ -61,9 +61,20 @@
 ert.
-*
+assertEquals
 ;%0A%0Ai
@@ -88,17 +88,81 @@
 ava.
-util.List
+io.InputStream;%0Aimport java.util.List;%0Aimport java.util.function.Function
 ;%0A%0Ai
@@ -219,23 +219,22 @@
 nit.
-Before;
+Test;%0A
 %0Aimport 
 org.
@@ -229,32 +229,63 @@
 %0Aimport 
-org.junit.Test;%0A
+com.taxonic.rml.engine.template.TemplateParser;
 %0Aimport 
@@ -600,151 +600,8 @@
 ;%0A%09%0A
-%09private RmlMapper mapper;%0A%09%0A%09// create a fresh mapper for every @Test%0A%09@Before%0A%09public void createMapper() %7B%0A%09%09mapper = new RmlMapper();%0A%09%7D%0A%09%0A
 %09@Te
@@ -674,22 +674,35 @@
 ng(%22
+RdfMapper/
 test1
-/
+%22, %22
 constant
 Subj
@@ -693,26 +693,25 @@
 %22, %22constant
-Su
+O
 bjectShortcu
@@ -760,16 +760,37 @@
 (String 
+resourcePath, String 
 resource
@@ -842,16 +842,37 @@
 er.load(
+resourcePath + %22/%22 + 
 resource
@@ -895,16 +895,231 @@
 .ttl%22);%0A
+%09%09Function%3CString, InputStream%3E sourceResolver =%0A%09%09%09s -%3E RmlMapperTest.class.getClassLoader().getResourceAsStream(resourcePath + %22/%22 + s);%0A%09%09RmlMapper mapper = new RmlMapper(sourceResolver, TemplateParser.build());%0A
 %09%09Model 
@@ -1181,16 +1181,37 @@
 s.parse(
+resourcePath + %22/%22 + 
 resource

Update RmlMapperTest