Search in sources :

Example 6 with Services

use of io.gravitee.definition.model.services.Services in project gravitee-management-rest-api by gravitee-io.

the class ApiService_hasHealthCheckEnabledTest method shouldBeEnabledWithGlobalHC.

@Test
public void shouldBeEnabledWithGlobalHC() {
    ApiEntity api = mock(ApiEntity.class);
    HealthCheckService hcSrv = mock(HealthCheckService.class);
    when(hcSrv.isEnabled()).thenReturn(Boolean.TRUE);
    Services services = new Services();
    services.set(Collections.singletonList(hcSrv));
    when(api.getServices()).thenReturn(services);
    mockProxy(api, false);
    boolean valid = apiService.hasHealthCheckEnabled(api, true);
    assertTrue(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 7 with Services

use of io.gravitee.definition.model.services.Services 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);
}
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 8 with Services

use of io.gravitee.definition.model.services.Services in project gravitee-management-rest-api by gravitee-io.

the class ApiService_hasHealthCheckEnabledTest method shouldNotBeEnabledWithEmptyServices.

@Test
public void shouldNotBeEnabledWithEmptyServices() {
    ApiEntity api = mock(ApiEntity.class);
    Services services = new Services();
    services.set(Collections.emptyList());
    mockProxy(api, false);
    boolean valid = apiService.hasHealthCheckEnabled(api, true);
    assertFalse(valid);
}
Also used : Services(io.gravitee.definition.model.services.Services) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Example 9 with Services

use of io.gravitee.definition.model.services.Services in project gravitee-management-rest-api by gravitee-io.

the class ApiService_hasHealthCheckEnabledTest method shouldNotBeEnabledWithAnotherService.

@Test
public void shouldNotBeEnabledWithAnotherService() {
    ApiEntity api = mock(ApiEntity.class);
    DynamicPropertyService dpSrv = mock(DynamicPropertyService.class);
    when(dpSrv.isEnabled()).thenReturn(Boolean.TRUE);
    Services services = new Services();
    services.set(Collections.singletonList(dpSrv));
    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) DynamicPropertyService(io.gravitee.definition.model.services.dynamicproperty.DynamicPropertyService) 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