UrlAccessLogMessageAssembler { public String assembleMessage(HttpServletRequest request, String message) { String ip = request.getRemoteAddr(); String host = ipAddressResolver.resolveToHostName(ip); return String.format(INFO_TEMPLATE, request.getRequestURI(), host, message); }  String assembleMessage(HttpServletRequest request, String message); String assembleDenyMessage(HttpServletRequest request);  }
@Test public void testAssembleMessageShouldGetRemoteAddressOfRequest() { underTest.assembleMessage(request, message); verify(request).getRemoteAddr(); }
@Test public void testAssembleMessageShouldResolveIpOfRequestToHostName() { given(request.getRemoteAddr()).willReturn("ipAddress"); underTest.assembleMessage(request, message); verify(ipAddressResolver).resolveToHostName("ipAddress"); }
@Test public void testAssembleMessageShoulReturnAnAssembledMessage() { String expectedResult = "URL: 'null', accessed from: 'null', message: 'null'"; String actualResult = underTest.assembleMessage(request, message); assertEquals(expectedResult, actualResult); }