@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)); }