### Question:
EncodedCharactersFilter extends ZuulFilter { @Override public Object run() { RequestContext context = RequestContext.getCurrentContext(); final String requestPath = context.getRequest().getRequestURI(); if (checkRequestForEncodedCharacters(requestPath)) { rejectRequest(context); } return null; }  @Override String filterType(); @Override int filterOrder(); @Override boolean shouldFilter(); @Override Object run(); static final String METADATA_KEY; }### Answer:
@Test void shouldRejectRequestsWithEncodedCharacters() { RequestContext context = RequestContext.getCurrentContext(); MockHttpServletRequest mockRequest = new MockHttpServletRequest(); mockRequest.setRequestURI("/He%2f%2f0%2dwor%2fd"); context.setRequest(mockRequest); this.filter.run(); assertTrue(context.getResponseBody().contains("Service 'serviceid' does not allow encoded characters in the request path: '/He%2f%2f0%2dwor%2fd'.")); assertTrue(context.getResponseBody().contains("ZWEAG701E")); assertEquals(400, context.getResponse().getStatus()); }
@Test void shouldAllowRequestsWithoutEncodedCharacters() { RequestContext context = RequestContext.getCurrentContext(); MockHttpServletRequest mockRequest = new MockHttpServletRequest(); mockRequest.setRequestURI("/HelloWorld"); context.setRequest(mockRequest); this.filter.run(); assertEquals(200, context.getResponse().getStatus()); }
@Test void shouldPassNullRequest() { RequestContext context = RequestContext.getCurrentContext(); MockHttpServletRequest mockRequest = new MockHttpServletRequest(); mockRequest.setRequestURI(null); context.setRequest(mockRequest); this.filter.run(); assertEquals(200, context.getResponse().getStatus()); }