### Question:
OddOrEven { @FunctionName("HttpTrigger-Java") public HttpResponseMessage HttpTriggerJava( @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request, final ExecutionContext context) { try { context.getLogger().info("Java HTTP trigger processed a request."); String numberQueryValue = request.getQueryParameters().get("number"); int number = Integer.parseInt(numberQueryValue); return request .createResponseBuilder(HttpStatus.OK) .body(number % 2 == 0 ? "Even" : "Odd") .build(); } catch(NumberFormatException nfe) { return request .createResponseBuilder(HttpStatus.BAD_REQUEST) .body("Unable to parse") .build(); } }  @FunctionName("HttpTrigger-Java") HttpResponseMessage HttpTriggerJava(
            @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
            final ExecutionContext context);  }### Answer:
@Test public void testEvenNumbers() throws Exception { final Map<String, String> queryParams = new HashMap<>(); queryParams.put("number", "2"); final HttpResponseMessage.Builder builder = mock(HttpResponseMessage.Builder.class); HttpRequestMessage<Optional<String>> req = generateHttpRequest(queryParams, builder); ExecutionContext context = generateContext(); new OddOrEven().HttpTriggerJava(req, context); verify(builder).body("Even"); verify(req).createResponseBuilder(HttpStatus.OK); }
@Test public void testOddNumbers() throws Exception { final Map<String, String> queryParams = new HashMap<>(); queryParams.put("number", "3"); final HttpResponseMessage.Builder builder = mock(HttpResponseMessage.Builder.class); HttpRequestMessage<Optional<String>> req = generateHttpRequest(queryParams, builder); ExecutionContext context = generateContext(); new OddOrEven().HttpTriggerJava(req, context); verify(builder).body("Odd"); verify(req).createResponseBuilder(HttpStatus.OK); }
@Test public void testNonNumber() throws Exception { final Map<String, String> queryParams = new HashMap<>(); queryParams.put("number", "I'm Even"); final HttpResponseMessage.Builder builder = mock(HttpResponseMessage.Builder.class); HttpRequestMessage<Optional<String>> req = generateHttpRequest(queryParams, builder); ExecutionContext context = generateContext(); new OddOrEven().HttpTriggerJava(req, context); verify(builder).body("Unable to parse"); verify(req).createResponseBuilder(HttpStatus.BAD_REQUEST); }