### Question:
RdfValueToTermConverter { public Term convertValue(final Value value) { if (value instanceof BNode) { return convertBlankNode((BNode) value); } else if (value instanceof Literal) { return convertLiteral((Literal) value); } else if (value instanceof URI) { return convertUri((URI) value); } else { throw new RulewerkRuntimeException("Unknown value type: " + value.getClass()); } } RdfValueToTermConverter(boolean skolemize); Term convertValue(final Value value); Term convertBlankNode(final BNode bNode); Term convertUri(final URI uri); Term convertLiteral(final Literal literal); Predicate convertUriToPredicate(final URI uri, int arity);  }### Answer:
@Test public void convertUri_succeeds() { URI uri = new URIImpl("http: RdfValueToTermConverter converter = new RdfValueToTermConverter(true); Term term = converter.convertValue(uri); assertEquals(TermType.ABSTRACT_CONSTANT, term.getType()); assertEquals("http: }
@Test public void convertLiteralDatatype_succeeds() { Literal literal = new LiteralImpl("42", new URIImpl("http: RdfValueToTermConverter converter = new RdfValueToTermConverter(true); Term term = converter.convertValue(literal); assertEquals(TermType.DATATYPE_CONSTANT, term.getType()); DatatypeConstant datataypeConstant = (DatatypeConstant) term; assertEquals("http: assertEquals("42", datataypeConstant.getLexicalValue()); }
@Test public void convertLiteralLanguage_succeeds() { Literal literal = new LiteralImpl("Test", "de"); RdfValueToTermConverter converter = new RdfValueToTermConverter(true); Term term = converter.convertValue(literal); assertEquals(TermType.LANGSTRING_CONSTANT, term.getType()); LanguageStringConstant langStringConstant = (LanguageStringConstant) term; assertEquals("Test", langStringConstant.getString()); assertEquals("de", langStringConstant.getLanguageTag()); }
@Test public void convertLiteralString_succeeds() { Literal literal = new LiteralImpl("RDF 1.0 untyped"); RdfValueToTermConverter converter = new RdfValueToTermConverter(true); Term term = converter.convertValue(literal); assertEquals(TermType.DATATYPE_CONSTANT, term.getType()); DatatypeConstant datataypeConstant = (DatatypeConstant) term; assertEquals(PrefixDeclarationRegistry.XSD_STRING, datataypeConstant.getDatatype()); assertEquals("RDF 1.0 untyped", datataypeConstant.getLexicalValue()); }
@Test public void convertBNodeSkolemize_succeeds() { BNode bnode = new BNodeImpl("myid"); RdfValueToTermConverter converter = new RdfValueToTermConverter(true); Term term = converter.convertValue(bnode); assertEquals(TermType.ABSTRACT_CONSTANT, term.getType()); assertTrue(term.getName().startsWith(Skolemization.SKOLEM_IRI_PREFIX)); }
@Test public void convertBNode_succeeds() { BNode bnode = new BNodeImpl("myid"); RdfValueToTermConverter converter = new RdfValueToTermConverter(false); Term term = converter.convertValue(bnode); assertEquals(TermType.NAMED_NULL, term.getType()); assertNotEquals("myid", term.getName()); }
@Test(expected = RulewerkRuntimeException.class) public void convertValueUnkownType_fails() { Value value = Mockito.mock(Value.class); RdfValueToTermConverter converter = new RdfValueToTermConverter(true); converter.convertValue(value); }