    @Test
    public void testWriteTo() throws Exception {

        ViewableWriter writer = new ViewableWriter();

        Field mvcField = writer.getClass().getDeclaredField("mvc");
        mvcField.setAccessible(true);
        mvcField.set(writer, new MvcContextImpl());
        
        ViewEngineFinder finder = EasyMock.createStrictMock(ViewEngineFinder.class);
        Field finderField = writer.getClass().getDeclaredField("engineFinder");
        finderField.setAccessible(true);
        finderField.set(writer, finder);

        HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);
        Field requestField = writer.getClass().getDeclaredField("injectedRequest");
        requestField.setAccessible(true);
        requestField.set(writer, request);

        Event<MvcEvent> dispatcher = EasyMock.createStrictMock(Event.class);
        Field dispatcherField = writer.getClass().getDeclaredField("dispatcher");
        dispatcherField.setAccessible(true);
        dispatcherField.set(writer, dispatcher);

        ViewEngine viewEngine = EasyMock.createStrictMock(ViewEngine.class);

        HttpServletResponse response = EasyMock.createStrictMock(HttpServletResponse.class);
        Field responseField = writer.getClass().getDeclaredField("injectedResponse");
        responseField.setAccessible(true);
        responseField.set(writer, response);

        Configuration config = EasyMock.createStrictMock(Configuration.class);
        Field configField = writer.getClass().getDeclaredField("config");
        configField.setAccessible(true);
        configField.set(writer, config);

        MultivaluedHashMap map = new MultivaluedHashMap();
        ArrayList<MediaType> contentTypes = new ArrayList<>();
        contentTypes.add(MediaType.TEXT_HTML_TYPE);
        map.put("Content-Type", contentTypes);

        Viewable viewable = new Viewable("myview");
        viewable.setModels(new ModelsImpl());

        expect(finder.find(anyObject())).andReturn(viewEngine);
        viewEngine.processView((ViewEngineContext) anyObject());

        replay(finder, request, viewEngine, response);
        writer.writeTo(viewable, null, null, new Annotation[] {}, MediaType.WILDCARD_TYPE, map, null);
        verify(finder, request, viewEngine, response);
    }