### Question:
CountryFilterController { @RequestMapping(value = "/countryfilter/allowed", method = GET, produces = APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<?> isIPAllowed(HttpServletRequest requestContext) throws BaseException { String ipAddress = IPAddressUtil.getIPAddress(requestContext); boolean result = this.countryFilterService.isIPAllowed(ipAddress); LOG.debug("IP Address: {}, isIPAllowed result: {}", ipAddress, result); return new ResponseEntity<>(new CountryFilterResponse(result), HttpStatus.OK); }  @RequestMapping(value = "/countryfilter/allowed", method = GET, produces = APPLICATION_JSON_UTF8_VALUE) ResponseEntity<?> isIPAllowed(HttpServletRequest requestContext);  }### Answer:
@Test public void testCountryFilterAllowed_with_X_Real_IP_Header() throws Exception { when(mockCountryFilterService.isIPAllowed("1.1.1.1")).thenReturn(true); MvcResult mvcResult1 = this.mockMvc.perform(get(COUNTRY_FILTER_ALLOWED_ENDPOINT) .header("X-Real-IP", "1.1.1.1") .contentType(APPLICATION_JSON)) .andExpect(status().isOk()) .andDo(print()) .andReturn(); assertThat(mvcResult1.getResponse().getContentAsString()).isEqualTo( jsonCountryFilterResponse.write(new CountryFilterResponse(true)).getJson() ); when(mockCountryFilterService.isIPAllowed("1.1.1.1")).thenReturn(false); MvcResult mvcResult2 = this.mockMvc.perform(get(COUNTRY_FILTER_ALLOWED_ENDPOINT) .header("X-Real-IP", "1.1.1.1") .contentType(APPLICATION_JSON)) .andExpect(status().isOk()) .andDo(print()) .andReturn(); assertThat(mvcResult2.getResponse().getContentAsString()).isEqualTo( jsonCountryFilterResponse.write(new CountryFilterResponse(false)).getJson() ); }