use of io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService in project gravitee-management-rest-api by gravitee-io.
the class ApiService_hasHealthCheckEnabledTest method shouldBeEnabledWithEndpointsHC.
@Test
public void shouldBeEnabledWithEndpointsHC() {
ApiEntity api = mock(ApiEntity.class);
EndpointHealthCheckService hcSrv = mock(EndpointHealthCheckService.class);
when(hcSrv.isEnabled()).thenReturn(Boolean.FALSE);
Services services = new Services();
services.set(Collections.singletonList(hcSrv));
when(api.getServices()).thenReturn(services);
mockProxy(api, true);
boolean valid = apiService.hasHealthCheckEnabled(api, true);
assertTrue(valid);
}
use of io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService in project gravitee-management-rest-api by gravitee-io.
the class ApiService_hasHealthCheckEnabledTest method shouldBeEnabledWithOnlyOneEndpointHC.
@Test
public void shouldBeEnabledWithOnlyOneEndpointHC() {
ApiEntity api = mock(ApiEntity.class);
EndpointHealthCheckService hcSrv = mock(EndpointHealthCheckService.class);
when(hcSrv.isEnabled()).thenReturn(Boolean.FALSE);
Services services = new Services();
services.set(Collections.singletonList(hcSrv));
when(api.getServices()).thenReturn(services);
mockProxy(api, false);
boolean valid = apiService.hasHealthCheckEnabled(api, false);
assertTrue(valid);
}
use of io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService in project gravitee-management-rest-api by gravitee-io.
the class ApiService_hasHealthCheckEnabledTest method shouldNotBeEnabledWithOnlyOneEndpointHC.
@Test
public void shouldNotBeEnabledWithOnlyOneEndpointHC() {
ApiEntity api = mock(ApiEntity.class);
EndpointHealthCheckService hcSrv = mock(EndpointHealthCheckService.class);
when(hcSrv.isEnabled()).thenReturn(Boolean.FALSE);
Services services = new Services();
services.set(Collections.singletonList(hcSrv));
when(api.getServices()).thenReturn(services);
mockProxy(api, false);
boolean valid = apiService.hasHealthCheckEnabled(api, true);
assertFalse(valid);
}
use of io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService in project gravitee-management-rest-api by gravitee-io.
the class ApiService_hasHealthCheckEnabledTest method mockProxy.
private void mockProxy(final ApiEntity api, final boolean withHC) {
final Proxy proxy = mock(Proxy.class);
when(api.getProxy()).thenReturn(proxy);
final EndpointGroup endpointGroup = mock(EndpointGroup.class);
when(proxy.getGroups()).thenReturn(Collections.singleton(endpointGroup));
final HttpEndpoint endpoint1 = mock(HttpEndpoint.class);
final HttpEndpoint endpoint2 = mock(HttpEndpoint.class);
when(endpointGroup.getEndpoints()).thenReturn(new HashSet<>(Arrays.asList(endpoint1, endpoint2)));
final EndpointHealthCheckService endpointHealthCheckService1 = mock(EndpointHealthCheckService.class);
when(endpoint1.getHealthCheck()).thenReturn(endpointHealthCheckService1);
when(endpointHealthCheckService1.isEnabled()).thenReturn(true);
final EndpointHealthCheckService endpointHealthCheckService2 = mock(EndpointHealthCheckService.class);
when(endpoint2.getHealthCheck()).thenReturn(endpointHealthCheckService2);
when(endpointHealthCheckService2.isEnabled()).thenReturn(withHC);
}
Aggregations