### Question:
RelayUtils { public static boolean shouldOverwriteContentType(MessageContext msgContext, TargetRequest request) { boolean builderInvoked = Boolean.TRUE.equals(msgContext .getProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED)); boolean noEntityBodySet = Boolean.TRUE.equals(msgContext.getProperty(PassThroughConstants.NO_ENTITY_BODY)); Map<String, LinkedHashSet<String>> headers = request.getHeaders(); boolean contentTypeInRequest = false; if (headers.size() != 0 && (headers.get("Content-Type") != null || headers.get("content-type") != null)) { contentTypeInRequest = true; } boolean isDefaultContentTypeEnabled = false; ConfigurationContext configurationContex = msgContext.getConfigurationContext(); if (configurationContex != null && configurationContex.getAxisConfiguration() .getParameter(NhttpConstants.REQUEST_CONTENT_TYPE) != null) { isDefaultContentTypeEnabled = true; } return (builderInvoked && !noEntityBodySet) || contentTypeInRequest || isDefaultContentTypeEnabled; }  static void buildMessage(org.apache.axis2.context.MessageContext msgCtx); static void buildMessage(MessageContext messageContext, boolean earlyBuild); static void buildMessage(MessageContext messageContext, boolean earlyBuild,
                                     InputStream in); static String getMIMEContentType(String contentType); static boolean isDeleteRequestWithoutPayload(MessageContext msgContext); static boolean shouldOverwriteContentType(MessageContext msgContext, TargetRequest request); static boolean isEmptyPayloadStream(InputStream inputStream); static void consumeAndDiscardMessage(MessageContext msgContext);  }### Answer:
@Test public void testShouldOverwriteContentType() { MessageContext msgContext1 = Mockito.mock(MessageContext.class); TargetRequest tgtRequest1 = Mockito.mock(TargetRequest.class); Mockito.when(msgContext1.getProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED)).thenReturn(Boolean.FALSE); Mockito.when(msgContext1.getProperty(PassThroughConstants.NO_ENTITY_BODY)).thenReturn(Boolean.TRUE); boolean result = RelayUtils.shouldOverwriteContentType(msgContext1, tgtRequest1); Assert.assertFalse("Content type has been chosen to overwrite when builder is not invoked and " + "no incoming content type is present", result); Mockito.when(msgContext1.getProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED)).thenReturn(Boolean.TRUE); Mockito.when(msgContext1.getProperty(PassThroughConstants.NO_ENTITY_BODY)).thenReturn(Boolean.FALSE); result = RelayUtils.shouldOverwriteContentType(msgContext1, tgtRequest1); Assert.assertTrue("Content type has not been chosen to overwrite when there's a body " + "and builder is invoked", result); Map<String, LinkedHashSet<String>> headers = new HashMap<>(); LinkedHashSet<String> contentTypeHeaderSet = new LinkedHashSet<>(); contentTypeHeaderSet.add("application/json"); headers.put("Content-Type", contentTypeHeaderSet); Mockito.when(tgtRequest1.getHeaders()).thenReturn(headers); result = RelayUtils.shouldOverwriteContentType(msgContext1, tgtRequest1); Assert.assertTrue("Content type has not been chosen to overwrite when there's a content type header", result); }