Unit test to check for nulls in EditN3GeneratorVTwo

This commit is contained in:
briancaruso 2011-11-11 15:59:00 +00:00
parent 7bfca34fe1
commit b6251c5f85

View file

@ -12,13 +12,37 @@ import java.util.Map;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
public class EditN3GeneratorVTwoTest { public class EditN3GeneratorVTwoTest {
static EditN3GeneratorVTwo gen = new EditN3GeneratorVTwo(); static EditN3GeneratorVTwo gen = new EditN3GeneratorVTwo();
@Test
public void testNullTarget(){
List<String> targets = Arrays.asList("?var",null,null,"?var");
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
keyToValues.put("var", Arrays.asList("ABC"));
keyToValues.put("var2", Arrays.asList((String)null));
/* test for exception */
gen.subInMultiUris(null, targets);
gen.subInMultiUris(keyToValues, null);
gen.subInMultiUris(keyToValues, targets);
Map<String,List<Literal>> keyToLiterals = new HashMap<String,List<Literal>>();
keyToLiterals.put("var", Arrays.asList( ResourceFactory.createTypedLiteral("String")));
keyToLiterals.put("var2", Arrays.asList( (Literal)null));
/* test for exception */
gen.subInMultiLiterals(keyToLiterals, targets);
gen.subInMultiLiterals(keyToLiterals, null);
gen.subInMultiLiterals(null, targets);
}
@Test @Test
public void testPunctAfterVarName(){ public void testPunctAfterVarName(){
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,"); List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,");