@Test
public void shouldCreateJaxbInstanceForFirstCallFromClassAndTypeAndReuseItForUnmarshallCallWithSameObjectType() throws Exception {

    Type type1 = Types.newType(List.class, Types.newType(Set.class, int[].class)); // List<Set<int[]>>
    Class clazz1 = List.class;
    Type type2 = String.class;
    Class clazz2 = String.class;
    Reader reader = mock(Reader.class);
    Jaxb mockJaxb1 = mock(Jaxb.class);
    Jaxb mockJaxb2 = mock(Jaxb.class);
    Class[] expected = asSet(List.class, Set.class, int[].class).toArray(new Class[3]);
    mockStatic(JaxbFactory.class);
    when(JaxbFactory.create(mockCRestConfig, getClass(), expected)).thenReturn(mockJaxb1);
    when(JaxbFactory.create(mockCRestConfig, getClass(), new Class<?>[]{String.class})).thenReturn(mockJaxb2);
    toTest.unmarshal(clazz1, type1, reader);
    toTest.unmarshal(clazz1, type1, reader);
    toTest.unmarshal(clazz2, type2, reader);
    toTest.unmarshal(clazz2, type2, reader);
    verify(mockJaxb1, times(2)).unmarshal(clazz1, type1, reader);
    verify(mockJaxb2, times(2)).unmarshal(clazz2, type2, reader);
}