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