use of io.gravitee.definition.model.services.Services 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.Services in project gravitee-management-rest-api by gravitee-io.
the class ApiService_UpdateTest method shouldNotUpdateWithInvalidSchedule.
@Test(expected = InvalidDataException.class)
public void shouldNotUpdateWithInvalidSchedule() throws TechnicalException {
prepareUpdate();
Services services = new Services();
HealthCheckService healthCheckService = mock(HealthCheckService.class);
when(healthCheckService.getSchedule()).thenReturn("**");
services.put(HealthCheckService.class, healthCheckService);
when(existingApi.getServices()).thenReturn(services);
final ApiEntity apiEntity = apiService.update(API_ID, existingApi);
assertNotNull(apiEntity);
assertEquals(API_NAME, apiEntity.getName());
}
use of io.gravitee.definition.model.services.Services in project gravitee-management-rest-api by gravitee-io.
the class ApiService_UpdateTest method shouldUpdateWithValidSchedule.
@Test
public void shouldUpdateWithValidSchedule() throws TechnicalException {
prepareUpdate();
Services services = new Services();
HealthCheckService healthCheckService = new HealthCheckService();
healthCheckService.setSchedule("1,2 */100 5-8 * * *");
services.put(HealthCheckService.class, healthCheckService);
when(existingApi.getServices()).thenReturn(services);
final ApiEntity apiEntity = apiService.update(API_ID, existingApi);
assertNotNull(apiEntity);
assertEquals(API_NAME, apiEntity.getName());
verify(searchEngineService, times(1)).index(any(), eq(false));
}
use of io.gravitee.definition.model.services.Services in project gravitee-management-rest-api by gravitee-io.
the class ApiService_hasHealthCheckEnabledTest method shouldNotBeEnabledWithDisabledGlobalHC.
@Test
public void shouldNotBeEnabledWithDisabledGlobalHC() {
ApiEntity api = mock(ApiEntity.class);
HealthCheckService hcSrv = mock(HealthCheckService.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.Services 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);
}
Aggregations