/** * Build an instance of provided class. * @param type Type of resource * @return The resource * @param <T> Type of it * @since 0.4.11 */ public <T extends BaseResource> T mock(final Class<T> type) { final T rest; try { rest = type.newInstance(); } catch (final InstantiationException ex) { throw new IllegalArgumentException(ex); } catch (final IllegalAccessException ex) { throw new IllegalArgumentException(ex); } rest.setHttpHeaders(this.resource.httpHeaders()); rest.setHttpServletRequest(this.resource.httpServletRequest()); rest.setProviders(this.resource.providers()); rest.setSecurityContext(this.resource.securityContext()); rest.setServletContext(this.resource.servletContext()); rest.setUriInfo(this.resource.uriInfo()); return rest; }