### Question:
ApiHandlerHelpers { public static String validateContentType(HttpRequest request, String expectedContentType) { LoggingService.logDebug(MODULE_NAME, "Validate content type in request : " + request); try { final String contentType = request.headers().get(HttpHeaderNames.CONTENT_TYPE, ""); if (TextUtils.isEmpty(contentType) || !(contentType.trim().split(";")[0].equalsIgnoreCase(expectedContentType))) { return "Incorrect content type " + contentType; } } catch (Exception e) { LoggingService.logError(MODULE_NAME, "Error validating content type", new AgentUserException(e.getMessage(), e)); return "Incorrect content type " ; } return null; }  static boolean validateMethod(HttpRequest request, HttpMethod expectedMethod); static String validateContentType(HttpRequest request, String expectedContentType); static boolean validateAccessToken(HttpRequest request); static FullHttpResponse successResponse(ByteBuf outputBuffer, String content); static FullHttpResponse methodNotAllowedResponse(); static FullHttpResponse badRequestResponse(ByteBuf outputBuffer, String content); static FullHttpResponse unauthorizedResponse(ByteBuf outputBuffer, String content); static FullHttpResponse notFoundResponse(ByteBuf outputBuffer, String content); static FullHttpResponse internalServerErrorResponse(ByteBuf outputBuffer, String content);  }### Answer:
@Test public void testValidateContentType() { try { assertEquals("Incorrect content type ", ApiHandlerHelpers.validateContentType(request, contentType)); } catch (Exception e) { fail("This should not happen"); } }
@Test public void testValidateContentTypeAreDifferent() { try { PowerMockito.when(request.headers()).thenReturn(httpHeaders); PowerMockito.when(httpHeaders.get(HttpHeaderNames.CONTENT_TYPE, "")).thenReturn("text/html"); assertEquals("Incorrect content type text/html", ApiHandlerHelpers.validateContentType(request, contentType)); } catch (Exception e) { fail("This should not happen"); } }
@Test public void testValidateContentTypeAreSame() { try { PowerMockito.when(request.headers()).thenReturn(httpHeaders); PowerMockito.when(httpHeaders.get(HttpHeaderNames.CONTENT_TYPE, "")).thenReturn(contentType); assertNull(ApiHandlerHelpers.validateContentType(request, contentType)); } catch (Exception e) { fail("This should not happen"); } }