### Question:
Neo4jRequestWrapper { public String executeCypherQuery(final String cypherQuery) { final JSONObject cypherQueryRequest = new JSONObject(); final HashMap<String, String> statement = new HashMap<>(); statement.put("statement", cypherQuery); final JSONArray statementsArray = new JSONArray(); statementsArray.put(statement); return executeRequest(cypherQueryRequest, statementsArray); } Neo4jRequestWrapper(final CloseableHttpClient httpClient, final HttpHost httpHost, final String username,
            final String password, final String serviceRoot);  Neo4jRequestWrapper(final CloseableHttpClient httpClient, final HttpHost httpHost,
            final String serviceRoot); String executeRestRequest(final HttpRequestBase httpRequest); String executeRestRequest(final HttpRequestBase httpRequest, final String username, final String password); String executeCypherQuery(final String cypherQuery); String executeCypherQueries(final List<String> cypherQueries);  }### Answer:
@Test public void testCreateCypherQueryWithAuthentication() { if (!isConfigured()) { System.err.println(getInvalidConfigurationMessage()); return; } CloseableHttpClient mockHttpClient = new CloseableHttpClient() { @Override public void close() throws IOException { } @Override public HttpParams getParams() { return null; } @Override public ClientConnectionManager getConnectionManager() { return null; } @Override protected CloseableHttpResponse doExecute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException { assertTrue(request instanceof HttpPost); HttpPost httpPost = (HttpPost) request; Header[] headers = httpPost.getHeaders("Authorization"); assertNotNull(headers); assertEquals(1, headers.length); String base64Encoded = headers[0].getValue(); base64Encoded = base64Encoded.replace("Basic ", ""); String decoded = new String(BaseEncoding.base64().decode(base64Encoded), StandardCharsets.UTF_8); assertEquals("testUsername:testPassword", decoded); assertEquals("{\"statements\":[{\"statement\":\"MATCH (n) RETURN n;\"}]}", EntityUtils.toString(httpPost.getEntity())); CloseableHttpResponse mockResponse = new MockClosableHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); return mockResponse; } }; Neo4jRequestWrapper wrapper = new Neo4jRequestWrapper(mockHttpClient, new HttpHost(getHostname(), getPort()), "testUsername", "testPassword", getServiceRoot()); wrapper.executeCypherQuery("MATCH (n) RETURN n;"); }
@Test public void testCreateCypherQueryWithoutAuthentication() { if (!isConfigured()) { System.err.println(getInvalidConfigurationMessage()); return; } CloseableHttpClient mockHttpClient = new CloseableHttpClient() { @Override public void close() throws IOException { } @Override public HttpParams getParams() { return null; } @Override public ClientConnectionManager getConnectionManager() { return null; } @Override protected CloseableHttpResponse doExecute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException { assertTrue(request instanceof HttpPost); HttpPost httpPost = (HttpPost) request; Header[] headers = httpPost.getHeaders("Authorization"); assertNotNull(headers); assertEquals(0, headers.length); assertEquals("{\"statements\":[{\"statement\":\"MATCH (n) RETURN n;\"}]}", EntityUtils.toString(httpPost.getEntity())); CloseableHttpResponse mockResponse = new MockClosableHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); return mockResponse; } }; Neo4jRequestWrapper wrapper = new Neo4jRequestWrapper(mockHttpClient, new HttpHost(getHostname(), getPort()), getServiceRoot()); wrapper.executeCypherQuery("MATCH (n) RETURN n;"); }