@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(); }
public void serviceAndRouteWithSameNameShouldBeRelated() { // given IRoute route = mock(IRoute.class); when(route.getServiceName()).thenReturn("42"); IService service = mock(IService.class); when(service.getName()).thenReturn("42"); // when // then assertThat(areRelated(route, service)).isTrue(); }
@Test public void testGetServicesForPod() { IService match = mock(IService.class); when(match.getSelector()).thenReturn(serviceSelector); IService nomatch = mock(IService.class); when(nomatch.getSelector()).thenReturn(new HashMap<>()); Collection<IService> services = Arrays.asList(nomatch, match); IService[] exp = new IService[] {match}; assertArrayEquals(exp, getServicesForPod(pod, services).toArray()); }