AuthorizationHttpChannelFactory implements HttpChannelFactory { public HttpChannel open(MethodType methodType, String url, Charset charset) throws IOException { return new AuthorizationHttpChannel(delegate.open(methodType, url, charset), authorization, methodType, url, charset, entityParamExtrators); } AuthorizationHttpChannelFactory(HttpChannelFactory delegate, Authorization authorization, Map<String, EntityParamExtractor> entityParamExtrators); HttpChannel open(MethodType methodType, String url, Charset charset);  }
@Test public void shouldConstructAnAuthorizationHttpChannelWithGivenParams() throws Exception { MethodType type = mock(MethodType.class); HttpChannel channel = mock(HttpChannel.class); AuthorizationHttpChannel expected = mock(AuthorizationHttpChannel.class); when(delegate.open(type, "url", UTF8)).thenReturn(channel); whenNew(AuthorizationHttpChannel.class).withArguments(channel, authorization, type, "url", UTF8, httpEntityParamExtractors).thenReturn(expected); HttpChannel actual = toTest.open(type,"url", UTF8); assertSame(expected, actual); }