### Question:
FactConverter { Fact convert(com.sabre.oss.yare.serializer.json.model.Fact fact) { if (fact == null) { return null; } return new Fact( fact.getName(), typeConverter.fromString(Type.class, fact.getType())); } FactConverter(TypeConverter typeConverter);   }### Answer:
@Test void shouldConvertToFact() { com.sabre.oss.yare.serializer.json.model.Fact toConvert = new com.sabre.oss.yare.serializer.json.model.Fact() .withName("fact-name") .withType("String"); Fact fact = factConverter.convert(toConvert); Fact expected = new Fact("fact-name", String.class); assertThat(fact).isEqualTo(expected); }
@Test void shouldConvertNullFact() { Fact fact = factConverter.convert(null); assertThat(fact).isNull(); }
@Test void shouldThrowExceptionWhenUnknownTypeUsed() { com.sabre.oss.yare.serializer.json.model.Fact toConvert = new com.sabre.oss.yare.serializer.json.model.Fact() .withName("fact-name") .withType("unknown"); assertThatThrownBy(() -> factConverter.convert(toConvert)) .isExactlyInstanceOf(IllegalArgumentException.class); }