@Test public void testAreRelatedForBuildConfigAndService() { // given // when // then assertThat(areRelated((IBuildConfig) null, (IService) null)).isFalse(); // given // when // then assertThat(areRelated(mock(IBuildConfig.class), (IService) null)).isFalse(); // given // when // then assertThat(areRelated((IBuildConfig) null, mock(IService.class))).isFalse(); // given IBuildConfig buildConfig = mock(IBuildConfig.class); when(buildConfig.getName()).thenReturn("42"); IService service = mock(IService.class); when(service.getName()).thenReturn("24"); // when // then assertThat(areRelated(buildConfig, service)).isFalse(); // given buildConfig = mock(IBuildConfig.class); when(buildConfig.getName()).thenReturn("42"); service = mock(IService.class); when(service.getName()).thenReturn("42"); // when // then assertThat(areRelated(buildConfig, service)).isTrue(); }
@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()); }