@SuppressWarnings("unchecked")
  @Before
  public void setup() {
    podLabels.put("foo", "bar");
    podLabels.put("xyz", "bar");

    when(pod.getLabels()).thenReturn(podLabels);

    serviceSelector.put("foo", "bar");

    when(buildConfig.getBuildOutputReference()).thenReturn(objectRef);
    when(objectRef.getName()).thenReturn(IMAGE_REF);
    when(build.getName()).thenReturn("build");
    when(build.accept(any(CapabilityVisitor.class), anyBoolean()))
        .then(
            new Answer<Boolean>() {

              @Override
              public Boolean answer(InvocationOnMock invocation) throws Throwable {
                CapabilityVisitor<ITags, Boolean> vis =
                    (CapabilityVisitor<ITags, Boolean>) invocation.getArguments()[0];
                return vis.visit(tagsCap);
              }
            });
    when(tagsCap.getTags()).thenReturn(Collections.emptyList());
  }
 @Test
 public void testIsNotMatchingResourceWhenNameIsInFilterTextIsNotNameOrInTag() {
   when(build.getName()).thenReturn("bar");
   when(tagsCap.getTags()).thenReturn(Arrays.asList("xyz", "123"));
   assertFalse("Exp. no match", isMatching("foo", "bar", Arrays.asList("xyz", "123")));
 }
 @Test
 public void testIsMatchingResourceWhenNameMatchesTags() {
   when(build.getName()).thenReturn("barrr");
   when(tagsCap.getTags()).thenReturn(Arrays.asList("xyz", "bar"));
   assertTrue("Exp. a match on a tag", isMatching("bar", build));
 }
 @Test
 public void testIsMatchingResourceWhenNameIsInFilterTextThatIsNotDelimited() {
   when(build.getName()).thenReturn("bar");
   assertTrue("Exp. a match on undelimited filter", isMatching(" bar ", build));
 }
 @Test
 public void testIsMatchingResourceWhenNameIsInFilterTextThatIsDelimited() {
   when(build.getName()).thenReturn("torque-java-jruby");
   assertTrue("Exp. a match on delimited filter", isMatching("java,jruby", build));
 }