### Question:
ViewAmbariStreamProvider implements AmbariStreamProvider { @Override public InputStream readFrom(String path, String requestMethod, String body, Map<String, String> headers ) throws IOException, AmbariHttpException { return getInputStream(path, requestMethod, headers, body == null ? null : body.getBytes()); } protected  ViewAmbariStreamProvider(URLStreamProvider streamProvider, AmbariSessionManager ambariSessionManager,
                                     AmbariManagementController controller); @Override InputStream readFrom(String path, String requestMethod, String body, Map<String, String> headers
                              ); @Override InputStream readFrom(String path, String requestMethod, InputStream body, Map<String, String> headers
                              );  }### Answer:
@Test public void testReadFrom() throws Exception { URLStreamProvider streamProvider = createNiceMock(URLStreamProvider.class); AmbariSessionManager sessionManager = createNiceMock(AmbariSessionManager.class); AmbariManagementController controller = createNiceMock(AmbariManagementController.class); HttpURLConnection urlConnection = createNiceMock(HttpURLConnection.class); InputStream inputStream = createNiceMock(InputStream.class); Map<String, String> headers = new HashMap<>(); headers.put("header", "headerValue"); headers.put("Cookie", "FOO=bar"); Map<String, List<String>> headerMap = new HashMap<>(); headerMap.put("header", Collections.singletonList("headerValue")); headerMap.put("Cookie", Collections.singletonList("FOO=bar; AMBARISESSIONID=abcdefg")); expect(sessionManager.getCurrentSessionId()).andReturn("abcdefg"); expect(sessionManager.getSessionCookie()).andReturn("AMBARISESSIONID"); expect(controller.getAmbariServerURI("/spec")).andReturn("http: expect(streamProvider.processURL(eq("http: expect(urlConnection.getInputStream()).andReturn(inputStream); replay(streamProvider, sessionManager, controller, urlConnection, inputStream); ViewAmbariStreamProvider viewAmbariStreamProvider = new ViewAmbariStreamProvider(streamProvider, sessionManager, controller); Assert.assertEquals(inputStream, viewAmbariStreamProvider.readFrom("spec", "requestMethod", "params", headers)); verify(streamProvider, sessionManager, urlConnection, inputStream); }