### Question:
EnvPullMessageFilter implements PullMessageFilter { @Override public boolean isActive(PullRequest request, Buffer message) { if (!enableSubEnvIsolation) { return false; } SubEnvIsolationPullFilter filter = getFilter(request, PullFilterType.SUB_ENV_ISOLATION); return filter != null; }  @Override boolean isActive(PullRequest request, Buffer message); @Override boolean match(PullRequest request, Buffer message); @Override void init(DynamicConfig config);  }### Answer:
@Test public void testInactiveOnSwitchOff() throws Exception { Buffer buffer = TestToolBox.createDefaultBuffer(); PullRequest request = TestToolBox.createDefaultPullRequest(); EnvPullMessageFilter filter = Mockito.spy(EnvPullMessageFilter.class); Whitebox.setInternalState(filter, "enableSubEnvIsolation", false); boolean active = filter.isActive(request, buffer); assertFalse(active); }
@Test public void testInactiveOnSwitchOnButFilterEmpty() { Buffer buffer = TestToolBox.createDefaultBuffer(); PullRequest request = TestToolBox.createDefaultPullRequest(); EnvPullMessageFilter filter = Mockito.spy(EnvPullMessageFilter.class); Whitebox.setInternalState(filter, "enableSubEnvIsolation", true); boolean active = filter.isActive(request, buffer); assertFalse(active); }
@Test public void testInactiveOnSwitchOnButFilterExists() { Buffer buffer = TestToolBox.createDefaultBuffer(); PullRequest request = TestToolBox.createDefaultPullRequest(); request.setFilters(Lists.newArrayList(new SubEnvIsolationPullFilter("test", "test"))); EnvPullMessageFilter filter = Mockito.spy(EnvPullMessageFilter.class); Whitebox.setInternalState(filter, "enableSubEnvIsolation", true); boolean active = filter.isActive(request, buffer); assertTrue(active); }