@Test
public void openShouldOpenAHttpURLConnectionAndInjectItIntoAHttpURLConnectionHttpChannel() throws Exception {

    URL url = PowerMockito.mock(URL.class);
    HttpURLConnection httpURLConnection = mock(HttpURLConnection.class);
    HttpURLConnectionHttpChannel expected = mock(HttpURLConnectionHttpChannel.class);
    MethodType methodType = MethodType.POST;
    whenNew(URL.class).withArguments("url").thenReturn(url);
    whenNew(HttpURLConnectionHttpChannel.class).withArguments(httpURLConnection, methodType).thenReturn(expected);
    when(url.openConnection()).thenReturn(httpURLConnection);
    HttpChannel actual = toTest.open(methodType, "url", null);
    assertSame(expected, actual);
    verify(httpURLConnection).setRequestMethod("POST");
}