title: SpringBoot Junit testing for filters in Zuul
body: <p>I'm new to Zuul J-unit testing. I have a couple of filters which is ChangeRequestEntityFilter and SessionFilter, Where I pasted my filtercode below. Can someone tell me how to write a Junit for the filter. I've searched and trying to use MockWire for the unit testing(Also I pasted my empty methods with basic annotations and WireMock port). I need at-least one proper example how this J-unit for Zuul works. I've referred the <a href="http://wiremock.org/docs/getting-started/" rel="nofollow noreferrer">http://wiremock.org/docs/getting-started/</a> doc. Where I got what to do, but not how to do.</p>
  
  <pre><code>public class ChangeRequestEntityFilter extends ZuulFilter {
  
      @Autowired
      private UtilityHelperBean utilityHelperBean;
  
      @Override
      public boolean shouldFilter() {
          // //avoid http GET request since it does'nt have any request body
          return utilityHelperBean.isValidContentBody();
      }
  
      @Override
      public int filterOrder() {
          //given priority
      }
  
      @Override
      public String filterType() {
          // Pre
      }
  
      @Override
      public Object run() {
  
          RequestContext context = getCurrentContext();
  
          try {
              /** get values profile details from session */
              Map&lt;String, Object&gt; profileMap = utilityHelperBean.getValuesFromSession(context,
                      CommonConstant.PROFILE.value());
  
              if (profileMap != null) {
                  /** get new attributes need to add to the actual origin microservice request payload */
                  Map&lt;String, Object&gt; profileAttributeMap = utilityHelperBean.getProfileForRequest(context, profileMap);
                  /** add the new attributes in to the current request payload */
                  context.setRequest(new CustomHttpServletRequestWrapper(context.getRequest(), profileAttributeMap));
              }
  
          } catch (Exception ex) {
              ReflectionUtils.rethrowRuntimeException(new IllegalStateException("ChangeRequestEntityFilter : ", ex));
          }
  
          return null;
      }
  
  }
  </code></pre>
  
  <p>I know ,I'm asking more. But give me any simple working complete example, I'm fine with it.</p>
  
  <p>My current code with basic annotations and WireMock port.</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @DirtiesContext
  @EnableZuulProxy
  public class ChangeRequestEntityFilterTest {
  
      @Rule
      public WireMockRule wireMockRule = new WireMockRule(8080);
  
      @Mock
      ChangeRequestEntityFilter requestEntityFilter;
  
      int port = wireMockRule.port();
  
      @Test
      public void changeRequestTest() {
  
      }
  }
  </code></pre>