@Test public void instanciateShouldDelegateAnyExceptionToCRestHandle() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { RuntimeException expected = mock(RuntimeException.class); InvocationTargetException e = mock(InvocationTargetException.class); mockStatic(ComponentFactory.class); when(ComponentFactory.instantiate(String.class, mockCRestConfig)).thenThrow(e); mockStatic(CRestException.class); when(CRestException.handle((Exception)e)).thenReturn(expected); try { toTest.instantiate(String.class); fail(); } catch (Exception e1) { assertSame(expected, e1); } }
protected <T> T instantiate(Class<T> clazz) { if (clazz == null) { return null; }else{ try { return ComponentFactory.instantiate(clazz, crestConfig); } catch (Exception e) { throw CRestException.handle(e); } } }
ConfigBuilder { protected <T> T instantiate(Class<T> clazz) { if (clazz == null) { return null; }else{ try { return ComponentFactory.instantiate(clazz, crestConfig); } catch (Exception e) { throw CRestException.handle(e); } } } }
ConfigBuilder { protected <T> T instantiate(Class<T> clazz) { if (clazz == null) { return null; }else{ try { return ComponentFactory.instantiate(clazz, crestConfig); } catch (Exception e) { throw CRestException.handle(e); } } } ConfigBuilder(CRestConfig crestConfig); }
ConfigBuilder { protected <T> T instantiate(Class<T> clazz) { if (clazz == null) { return null; }else{ try { return ComponentFactory.instantiate(clazz, crestConfig); } catch (Exception e) { throw CRestException.handle(e); } } } ConfigBuilder(CRestConfig crestConfig); CRestConfig getCRestConfig(); T override(String property, T defaultIfNotFound); }
ConfigBuilder { protected <T> T instantiate(Class<T> clazz) { if (clazz == null) { return null; }else{ try { return ComponentFactory.instantiate(clazz, crestConfig); } catch (Exception e) { throw CRestException.handle(e); } } } ConfigBuilder(CRestConfig crestConfig); CRestConfig getCRestConfig(); T override(String property, T defaultIfNotFound);  }