Search in sources :

Example 1 with Services

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);
}
Also used : Services(io.gravitee.definition.model.services.Services) EndpointHealthCheckService(io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Example 2 with Services

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());
}
Also used : Services(io.gravitee.definition.model.services.Services) HealthCheckService(io.gravitee.definition.model.services.healthcheck.HealthCheckService) UpdateApiEntity(io.gravitee.rest.api.model.api.UpdateApiEntity) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Example 3 with Services

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));
}
Also used : Services(io.gravitee.definition.model.services.Services) HealthCheckService(io.gravitee.definition.model.services.healthcheck.HealthCheckService) UpdateApiEntity(io.gravitee.rest.api.model.api.UpdateApiEntity) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Example 4 with Services

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);
}
Also used : Services(io.gravitee.definition.model.services.Services) HealthCheckService(io.gravitee.definition.model.services.healthcheck.HealthCheckService) EndpointHealthCheckService(io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Example 5 with Services

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);
}
Also used : Services(io.gravitee.definition.model.services.Services) EndpointHealthCheckService(io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Aggregations

Services (io.gravitee.definition.model.services.Services)9 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)9 Test (org.junit.Test)9 EndpointHealthCheckService (io.gravitee.definition.model.services.healthcheck.EndpointHealthCheckService)5 HealthCheckService (io.gravitee.definition.model.services.healthcheck.HealthCheckService)4 UpdateApiEntity (io.gravitee.rest.api.model.api.UpdateApiEntity)2 DynamicPropertyService (io.gravitee.definition.model.services.dynamicproperty.DynamicPropertyService)1