Search in sources :

Example 1 with ContextFactory

use of org.simpleflatmapper.converter.ContextFactory in project SimpleFlatMapper by arnaudroger.

the class ConverterServiceTestHelper method testConverter.

public static <I, O> void testConverter(I i, O o, Class<I> classi, Class<O> classo, Object... params) throws Exception {
    if (hasZoneId(params)) {
        params = Arrays.copyOf(params, params.length + 1);
        params[params.length - 1] = TimeZone.getTimeZone("UTC");
    }
    DefaultContextFactoryBuilder defaultContextFactoryBuilder = new DefaultContextFactoryBuilder();
    final ContextualConverter<? super I, ? extends O> converter = ConverterService.getInstance().findConverter(classi, classo, defaultContextFactoryBuilder, params);
    assertNotNull("Converter not null", converter);
    ContextFactory contextFactory = defaultContextFactoryBuilder.build();
    assertEquals(o, converter.convert(i, contextFactory.newContext()));
    assertNotNull(converter.toString());
}
Also used : ContextFactory(org.simpleflatmapper.converter.ContextFactory) DefaultContextFactoryBuilder(org.simpleflatmapper.converter.DefaultContextFactoryBuilder)

Aggregations

ContextFactory (org.simpleflatmapper.converter.ContextFactory)1 DefaultContextFactoryBuilder (org.simpleflatmapper.converter.DefaultContextFactoryBuilder)1