### Question:
GenericFacesConverter extends WebApplicationObjectSupport implements ConditionalGenericConverter { public Object convert(final Object source, final TypeDescriptor sourceType, final TypeDescriptor targetType) { if (source == null) { return null; } SpringFacesContext springFacesContext = SpringFacesContext.getCurrentInstance(); FacesContext facesContext = springFacesContext.getFacesContext(); try { Converter facesConverter = createFacesConverter(facesContext, targetType); return facesConverter.getAsObject(facesContext, null, source.toString()); } finally { facesContext.release(); } }  Set<ConvertiblePair> getConvertibleTypes(); boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType); Object convert(final Object source, final TypeDescriptor sourceType, final TypeDescriptor targetType);  }### Answer:
@Test public void shouldConvertNull() throws Exception { assertThat(this.converter.convert(null, this.sourceType, TypeDescriptor.forObject(Object.class)), is(nullValue())); }
@Test public void shouldConvertAnnotationOnField() throws Exception { TypeDescriptor targetType = AnnotatedClass.getFieldTypeDescriptor(); assertThat(this.converter.convert(this.source, this.sourceType, targetType), is(equalTo(this.converted))); }
@Test public void shouldConvertAnnotationOnMethod() throws Exception { TypeDescriptor targetType = AnnotatedClass.getMethodParamTypeDescriptor(); assertThat(this.converter.convert(this.source, this.sourceType, targetType), is(equalTo(this.converted))); }
@Test public void shouldConvertByType() throws Exception { TypeDescriptor targetType = TypeDescriptor.valueOf(ClassWithConverter.class); assertThat(this.converter.convert(this.source, this.sourceType, targetType), is(equalTo(this.converted))); }
@Test public void shouldThrowIfNoConverter() throws Exception { TypeDescriptor targetType = AnnotatedClass.getFieldTypeDescriptor(); reset(this.application); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("No JSF converter located for ID 'example'"); this.converter.convert(this.source, this.sourceType, targetType); }
@Test public void shouldReThrowFacesException() throws Exception { TypeDescriptor targetType = AnnotatedClass.getFieldTypeDescriptor(); reset(this.application); given(this.application.createConverter("example")).willThrow(new FacesException()); this.thrown.expect(FacesException.class); this.converter.convert(this.source, this.sourceType, targetType); }