### Question:
ZookeeperElbFilter implements ELBFilter { @Override public boolean accept(LoadBalancerDescription loadBalancer) { String[] pieces = loadBalancer.getLoadBalancerName().split("-"); if (pieces.length < 2) { return false; } if (pieces[0].equalsIgnoreCase(environment) && pieces[1].startsWith("Zoo")) { return true; } if (pieces.length == 3 && pieces[0].equalsIgnoreCase("exhibitor") && pieces[1].equalsIgnoreCase(environment) && pieces[2].equalsIgnoreCase("internal")) { return true; } return false; } ZookeeperElbFilter(String environment); @Override boolean accept(LoadBalancerDescription loadBalancer);  }### Answer:
@Test public void noMatchingEnvironment() { LoadBalancerDescription loadBalancer = new LoadBalancerDescription(); loadBalancer.setLoadBalancerName("foo-Zookeeper-whatever"); Assert.assertFalse(filter.accept(loadBalancer)); }
@Test public void matchingEnvironmentNoMatchingName() { LoadBalancerDescription loadBalancer = new LoadBalancerDescription(); loadBalancer.setLoadBalancerName(ENVIRONMENT + "-Asgard-whatever"); Assert.assertFalse(filter.accept(loadBalancer)); }
@Test public void foundCloudformationZookeeper() { LoadBalancerDescription loadBalancer = new LoadBalancerDescription(); List<ListenerDescription> listenerDescriptions = new ArrayList<>(); listenerDescriptions.add(new ListenerDescription()); loadBalancer.setListenerDescriptions(listenerDescriptions); loadBalancer.setLoadBalancerName(ENVIRONMENT + "-Zookeeper-whatever"); Assert.assertTrue(filter.accept(loadBalancer)); }
@Test public void foundInternalExhibitor() { LoadBalancerDescription loadBalancer = new LoadBalancerDescription(); List<ListenerDescription> listenerDescriptions = new ArrayList<>(); listenerDescriptions.add(new ListenerDescription()); loadBalancer.setListenerDescriptions(listenerDescriptions); loadBalancer.setLoadBalancerName("exhibitor-" + ENVIRONMENT + "-internal"); Assert.assertTrue(filter.accept(loadBalancer)); }
@Test public void externalExhibitor() { LoadBalancerDescription loadBalancer = new LoadBalancerDescription(); List<ListenerDescription> listenerDescriptions = new ArrayList<>(); listenerDescriptions.add(new ListenerDescription()); loadBalancer.setListenerDescriptions(listenerDescriptions); loadBalancer.setLoadBalancerName("exhibitor-" + ENVIRONMENT); Assert.assertFalse(filter.accept(loadBalancer)); }
@Test public void randomUnmatchedELB() { LoadBalancerDescription loadBalancer = new LoadBalancerDescription(); List<ListenerDescription> listenerDescriptions = new ArrayList<>(); listenerDescriptions.add(new ListenerDescription()); loadBalancer.setListenerDescriptions(listenerDescriptions); loadBalancer.setLoadBalancerName(RandomStringUtils.random(5,"abcd")); Assert.assertFalse(filter.accept(loadBalancer)); }