### Question:
RestServiceBase { public Map<String, Object> createResponse(final GetResponse response) { return response.getSource(); }  Map<String, Object> createResponse(final GetResponse response); StreamingOutput createResponse(final SearchResponse response,
			final Map<String, String> additionalResponseFields); StreamingOutput createResponse(final MultiSearchResponse response, final String responseUuid);  }### Answer:
@Test public void createResponse_Map() { RestServiceBase tested = getTested(); GetResponse rMock = Mockito.mock(GetResponse.class); Map<String, Object> m = new HashMap<String, Object>(); Mockito.when(rMock.getSource()).thenReturn(m); Assert.assertEquals(m, tested.createResponse(rMock)); }
@Test public void createResponse_StreamingOutput() throws IOException, JSONException { RestServiceBase tested = getTested(); SearchResponse srMock = Mockito.mock(SearchResponse.class); Mockito.doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); XContentBuilder resp = (XContentBuilder) args[0]; resp.field("testfield", "testvalue"); return null; } }).when(srMock).toXContent(Mockito.any(XContentBuilder.class), Mockito.eq(ToXContent.EMPTY_PARAMS)); Map<String, String> af = new LinkedHashMap<String, String>(); TestUtils.assetJsonStreamingOutputContent("{\"testfield\":\"testvalue\"}", tested.createResponse(srMock, af)); af.put("uuid", "myid"); af.put("ag", "qag"); af.put("oo", null); StreamingOutput so = tested.createResponse(srMock, af); TestUtils.assetJsonStreamingOutputContent("{\"uuid\":\"myid\",\"ag\":\"qag\",\"oo\":null,\"testfield\":\"testvalue\"}", so); TestUtils.assetJsonStreamingOutputContent("{\"testfield\":\"testvalue\"}", tested.createResponse(srMock, null)); }