### Question:
MaskSensitiveHelper { public void addSensitiveElementNames(final Set<String> inSensitiveElementNames) { for (final String sensitiveName : inSensitiveElementNames) { addReplacementPair(MATCH_PATTERN_XML_TEMPLATE, REPLACEMENT_XML_TEMPLATE, sensitiveName, replacementsXML); addReplacementPair(MATCH_PATTERN_JSON_TEMPLATE, REPLACEMENT_JSON_TEMPLATE, sensitiveName, replacementsJSON); } }  void addSensitiveElementNames(final Set<String> inSensitiveElementNames); String maskSensitiveElements(
            final Message message,
            final String originalLogString); void maskHeaders(
            final Map<String, String> headerMap,
            final Set<String> sensitiveHeaderNames);  }### Answer:
@Test public void shouldReplaceSensitiveDataIn() { final LoggingInInterceptor inInterceptor = new LoggingInInterceptor(logEventSender); inInterceptor.addSensitiveElementNames(SENSITIVE_ELEMENTS); final Message message = prepareInMessage(); Collection<PhaseInterceptor<? extends Message>> interceptors = inInterceptor.getAdditionalInterceptors(); for (PhaseInterceptor intercept : interceptors) { intercept.handleMessage(message); } inInterceptor.handleMessage(message); LogEvent event = logEventSender.getLogEvent(); assertNotNull(event); assertEquals(maskedContent, event.getPayload()); }
@Test public void shouldReplaceSensitiveDataOut() throws IOException { final LoggingOutInterceptor outInterceptor = new LoggingOutInterceptor(logEventSender); outInterceptor.addSensitiveElementNames(SENSITIVE_ELEMENTS); final Message message = prepareOutMessage(); outInterceptor.handleMessage(message); byte[] payload = loggingContent.getBytes(StandardCharsets.UTF_8); OutputStream out = message.getContent(OutputStream.class); out.write(payload); out.close(); LogEvent event = logEventSender.getLogEvent(); assertNotNull(event); assertEquals(maskedContent, event.getPayload()); }