HttpResponseSender implements IResponseSender { @Override public void send(final IResponse responseObject, final IObject environment, final IChannelHandler ctx) throws ResponseSendingException { FullHttpResponse response = new DefaultFullHttpResponse( HttpVersion.HTTP_1_1, getResponseStatus(environment), Unpooled.wrappedBuffer(responseObject.getContent())); try { headersSetter.set(response, environment); } catch (HeadersSetterException e) { throw new ResponseSendingException("Failed to set headers to response", e); } try { cookiesSetter.set(response, environment); } catch (CookieSettingException e) { throw new ResponseSendingException("Failed to set cookies to response", e); } ctx.send(response); } HttpResponseSender(final String name); @Override void send(final IResponse responseObject, final IObject environment,
                     final IChannelHandler ctx);  }
@Test public void writeShouldCallSendMethod() throws ResponseSendingException, ResolutionException, CookieSettingException, HeadersSetterException { HttpResponseSender sender = new HttpResponseSender("123"); IObject environment = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject"), "{\"foo\":\"bar\"}"); when(responseStatusExtractor.extract(any(IObject.class))).thenReturn(200); when(response.getContent()).thenReturn("{\"foo\":\"bar\"}".getBytes()); sender.send(response, environment, ctx); verify(cookiesExtractor, times(1)).set(any(FullHttpResponse.class), any(IObject.class)); verify(headersExtractor, times(1)).set(any(FullHttpResponse.class), any(IObject.class)); verify(ctx, times(1)).send(any(FullHttpResponse.class)); }