### Question:
RESTServiceConnector { @SuppressWarnings("unchecked") public <T> T executeCreateObject(final T newObject, final String path, final Map<String, String> parameters) throws CloudstackRESTException { s_logger.debug("Executing create object on " + path); final CloseableHttpResponse response = createAndExecuteRequest(HttpMethods.POST, path, parameters, Optional.fromNullable(gson.toJson(newObject))); return (T) readResponseBody(response, newObject.getClass()); } private  RESTServiceConnector(final Builder builder); static Builder create(); void executeUpdateObject(final T newObject, final String path, final Map<String, String> parameters); void executeUpdateObject(final T newObject, final String path); @SuppressWarnings("unchecked") T executeCreateObject(final T newObject, final String path, final Map<String, String> parameters); T executeCreateObject(final T newObject, final String uri); void executeDeleteObject(final String path); T executeRetrieveObject(final Type returnObjectType, final String path, final Map<String, String> parameters); T executeRetrieveObject(final Type returnObjectType, final String path);  }### Answer:
@Test public void testExecuteCreateObject() throws Exception { final TestPojo newObject = new TestPojo(); newObject.setField("newValue"); final String newObjectJson = gson.toJson(newObject); final CloseableHttpResponse response = mock(CloseableHttpResponse.class); when(response.getEntity()).thenReturn(new StringEntity(newObjectJson)); when(response.getStatusLine()).thenReturn(HTTP_200_STATUS_LINE); final CloseableHttpClient httpClient = mock(CloseableHttpClient.class); when(httpClient.execute(any(HttpHost.class), any(HttpRequest.class), any(HttpClientContext.class))).thenReturn(response); final RestClient restClient = new BasicRestClient(httpClient, HttpClientContext.create(), "localhost"); final RESTServiceConnector connector = new RESTServiceConnector.Builder().client(restClient).build(); final TestPojo object = connector.executeCreateObject(newObject, "/somepath"); assertThat(object, notNullValue()); assertThat(object, equalTo(newObject)); verify(httpClient).execute(any(HttpHost.class), HttpUriRequestMethodMatcher.aMethod("POST"), any(HttpClientContext.class)); verify(httpClient).execute(any(HttpHost.class), HttpUriRequestPayloadMatcher.aPayload(newObjectJson), any(HttpClientContext.class)); verify(response).close(); }