Search in sources :

Example 1 with MapperBiFunctionAdapter

use of org.simpleflatmapper.map.mapper.MapperBiFunctionAdapter in project SimpleFlatMapper by arnaudroger.

the class MapperBiFunctionAdapterTest method test.

@SuppressWarnings("unchecked")
@Test
public void test() throws Exception {
    Predicate<Object> nullChecker = mock(Predicate.class);
    Mapper<Object, String> mapper = mock(Mapper.class);
    MappingContext mappingContext = mock(MappingContext.class);
    MapperBiFunctionAdapter<Object, String> biFunctionAdapter = new MapperBiFunctionAdapter<Object, String>(mapper, nullChecker, 0);
    Object o = new Object();
    when(mapper.map(o, mappingContext)).thenReturn("HEllo", "Bye");
    when(nullChecker.test(any())).thenReturn(false, true);
    assertEquals("HEllo", biFunctionAdapter.apply(o, mappingContext));
    assertNull(biFunctionAdapter.apply(null, null));
    biFunctionAdapter.toString();
}
Also used : MappingContext(org.simpleflatmapper.map.MappingContext) MapperBiFunctionAdapter(org.simpleflatmapper.map.mapper.MapperBiFunctionAdapter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 MappingContext (org.simpleflatmapper.map.MappingContext)1 MapperBiFunctionAdapter (org.simpleflatmapper.map.mapper.MapperBiFunctionAdapter)1