### Question:
RemoteCallLoggerDelegate { public void logRequestDetails(RemoteCallReturn remoteCallReturn) { if (remoteCallReturn == null) { return; } boolean isSuccess = remoteCallReturn.getException() == null; if (!isDetailsLoggable(isSuccess)) { return; } String prettyRequest = null; if (remoteCallReturn.getRequestInfo() != null) { prettyRequest = prettyPrinter.prettyPrint(remoteCallReturn.getRequestInfo().getPayload()); } String prettyResponse = null; if (remoteCallReturn.getResponseInfo() != null) { prettyResponse = prettyPrinter.prettyPrint(remoteCallReturn.getResponseInfo().getPayload()); } if (isSuccess) { detailLogger.debug(DETAILS_REQUEST_TEMPLATE, remoteCallType, prettyRequest); detailLogger.debug(DETAILS_RESPONSE_TEMPLATE, remoteCallType, prettyResponse); } else { detailLogger.info(DETAILS_REQUEST_TEMPLATE, remoteCallType, prettyRequest); detailLogger.info(DETAILS_RESPONSE_TEMPLATE, remoteCallType, prettyResponse); } } RemoteCallLoggerDelegate(
      Logger summaryLogger,
      Logger detailLogger,
      @Nullable PrettyPrinterInterface prettyPrinter,
      RemoteCallType remoteCallType); boolean isSummaryLoggable(boolean isSuccess); boolean isDetailsLoggable(boolean isSuccess); void logRequestDetails(RemoteCallReturn remoteCallReturn); void logRequestSummary(RemoteCallReturn remoteCallReturn);  }### Answer:
@Test public void testLogRequestDetails_success_debugLevelEnabled() { when(soapXmlLogger.isDebugEnabled()).thenReturn(true); loggerDelegate.logRequestDetails(remoteCallReturn); verify(soapXmlLogger) .debug( RemoteCallLoggerDelegate.DETAILS_REQUEST_TEMPLATE, RemoteCallType.SOAP, prettyRequest); verify(soapXmlLogger) .debug( RemoteCallLoggerDelegate.DETAILS_RESPONSE_TEMPLATE, RemoteCallType.SOAP, prettyResponse); }
@Test public void testLogRequestDetails_success_infoLevelDisabled() { when(soapXmlLogger.isInfoEnabled()).thenReturn(false); when(soapXmlLogger.isWarnEnabled()).thenReturn(false); loggerDelegate.logRequestDetails(remoteCallReturn); verify(soapXmlLogger, times(0)).info(any(String.class)); verify(soapXmlLogger, times(0)).warn(any(String.class)); }
@Test public void testLogRequestDetails_failure_infoLevelEnabled() { Throwable returnedException = new Throwable(); remoteCallReturn = new RemoteCallReturn.Builder() .withRequestInfo(remoteCallReturn.getRequestInfo()) .withResponseInfo(remoteCallReturn.getResponseInfo()) .withException(returnedException) .build(); when(soapXmlLogger.isInfoEnabled()).thenReturn(true); when(soapXmlLogger.isWarnEnabled()).thenReturn(true); loggerDelegate.logRequestDetails(remoteCallReturn); verify(soapXmlLogger) .info( RemoteCallLoggerDelegate.DETAILS_REQUEST_TEMPLATE, RemoteCallType.SOAP, prettyRequest); verify(soapXmlLogger) .info( RemoteCallLoggerDelegate.DETAILS_RESPONSE_TEMPLATE, RemoteCallType.SOAP, prettyResponse); }