### Question:
Function { @FunctionName("HttpTrigger-Java") public HttpResponseMessage run( @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) HttpRequestMessage<Optional<String>> request, final ExecutionContext context) { context.getLogger().info("Java HTTP trigger processed a request."); String query = request.getQueryParameters().get("name"); String name = request.getBody().orElse(query); if (name == null) { return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build(); } else { return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build(); } }  @FunctionName("HttpTrigger-Java") HttpResponseMessage run(
            @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) HttpRequestMessage<Optional<String>> request,
            final ExecutionContext context);  }### Answer:
@Test public void testHttpTriggerJava() throws Exception { @SuppressWarnings("unchecked") final HttpRequestMessage<Optional<String>> req = mock(HttpRequestMessage.class); final Map<String, String> queryParams = new HashMap<>(); queryParams.put("name", "Azure"); doReturn(queryParams).when(req).getQueryParameters(); final Optional<String> queryBody = Optional.empty(); doReturn(queryBody).when(req).getBody(); doAnswer(new Answer<HttpResponseMessage.Builder>() { @Override public HttpResponseMessage.Builder answer(InvocationOnMock invocation) { HttpStatus status = (HttpStatus) invocation.getArguments()[0]; return new HttpResponseMessageMock.HttpResponseMessageBuilderMock().status(status); } }).when(req).createResponseBuilder(any(HttpStatus.class)); final ExecutionContext context = mock(ExecutionContext.class); doReturn(Logger.getGlobal()).when(context).getLogger(); final HttpResponseMessage ret = new Function().run(req, context); assertEquals(ret.getStatus(), HttpStatus.OK); }