### Question:
LiteralValueExtractor implements ValueVisitor { @Override public void visitLiteral(Literal<?> value) { value.accept(this.adapter); this.value=this.adapter.adaptedValue(); } private  LiteralValueExtractor(LiteralAdapter<T> adapter); @Override void visitLiteral(Literal<?> value); @Override void visitIndividual(Individual<?, ?> value);  }### Answer:
@Test public void testVisitLiteral$plainLiteral() throws Exception { LiteralValueExtractor<Number> extractor = LiteralValueExtractor.newInstance(Number.class); extractor.visitLiteral(Literals.newLiteral(1)); assertThat(extractor.getValue(),equalTo(LITERAL_VALUE)); assertThat(extractor.isAvailable(),equalTo(true)); }
@Test public void testVisitLiteral$plainLiteral$doesNotMatch() throws Exception { LiteralValueExtractor<Number> extractor = LiteralValueExtractor.newInstance(Number.class); extractor.visitLiteral(Literals.newLiteral("test")); assertThat(extractor.getValue(),nullValue()); assertThat(extractor.isAvailable(),equalTo(false)); }
@Test public void testVisitLiteral$typedLiteral() throws Exception { LiteralValueExtractor<Number> extractor = LiteralValueExtractor.newInstance(Number.class); extractor.visitLiteral(Literals.newTypedLiteral(1,Datatypes.STRING)); assertThat(extractor.getValue(),equalTo(LITERAL_VALUE)); assertThat(extractor.isAvailable(),equalTo(true)); }
@Test public void testVisitLiteral$typedLiteral$doesNotMatch() throws Exception { LiteralValueExtractor<Number> extractor = LiteralValueExtractor.newInstance(Number.class); extractor.visitLiteral(Literals.newTypedLiteral("test",Datatypes.STRING)); assertThat(extractor.getValue(),nullValue()); assertThat(extractor.isAvailable(),equalTo(false)); }
@Test public void testVisitLiteral$languageLiteral() throws Exception { LiteralValueExtractor<String> extractor = LiteralValueExtractor.newInstance(String.class); extractor.visitLiteral(Literals.newTypedLiteral("1",Datatypes.STRING)); assertThat(extractor.getValue(),equalTo(LITERAL_VALUE.toString())); assertThat(extractor.isAvailable(),equalTo(true)); }
@Test public void testVisitLiteral$languageLiteral$doesNotMatch() throws Exception { LiteralValueExtractor<Number> extractor = LiteralValueExtractor.newInstance(Number.class); extractor.visitLiteral(Literals.newLanguageLiteral("test","en")); assertThat(extractor.getValue(),nullValue()); assertThat(extractor.isAvailable(),equalTo(false)); }