OpenShiftEnvironmentValidator extends KubernetesEnvironmentValidator { public void validate(OpenShiftEnvironment env) throws ValidationException { super.validate(env); validateRoutesMatchServices(env); } @Inject  OpenShiftEnvironmentValidator(KubernetesEnvironmentPodsValidator podsValidator); void validate(OpenShiftEnvironment env);  }
@Test public void shouldDoNothingWhenRoutesMatchServices() throws Exception { Map<String, Service> services = ImmutableMap.of("service1", makeService("service1")); Map<String, Route> routes = ImmutableMap.of("route1", makeRoute("route1", "service1")); when(environment.getRoutes()).thenReturn(routes); when(environment.getServices()).thenReturn(services); envValidator.validate(environment); }
@Test public void shouldDoNothingWhenRoutesDoNotHaveToField() throws Exception { Map<String, Route> routes = ImmutableMap.of("route1", makeRoute("route1", null)); when(environment.getRoutes()).thenReturn(routes); envValidator.validate(environment); }
@Test(expectedExceptions = ValidationException.class) public void shouldThrowExceptionWhenRouteRefersToMissingService() throws Exception { Map<String, Service> services = ImmutableMap.of("service1", makeService("service1")); Map<String, Route> routes = ImmutableMap.of("route1", makeRoute("route1", "notservice1")); when(environment.getRoutes()).thenReturn(routes); when(environment.getServices()).thenReturn(services); envValidator.validate(environment); }