Search in sources :

Example 1 with Maintenance

use of io.gravitee.rest.api.model.settings.Maintenance in project gravitee-management-rest-api by gravitee-io.

the class ConsoleSettingsResourceTest method shouldCallSaveMethod_EnabledMaintenance.

@Test
public void shouldCallSaveMethod_EnabledMaintenance() {
    ConsoleSettingsEntity config = new ConsoleSettingsEntity();
    Maintenance maintenance = new Maintenance();
    maintenance.setEnabled(true);
    config.setMaintenance(maintenance);
    when(parameterService.findAsBoolean(Key.MAINTENANCE_MODE_ENABLED, GraviteeContext.getCurrentOrganization(), ParameterReferenceType.ORGANIZATION)).thenReturn(false);
    final Response response = orgTarget().request().post(Entity.json(config));
    assertEquals(response.readEntity(String.class), OK_200, response.getStatus());
    verify(configService).save(any(ConsoleSettingsEntity.class));
}
Also used : Response(javax.ws.rs.core.Response) ConsoleSettingsEntity(io.gravitee.rest.api.model.settings.ConsoleSettingsEntity) Maintenance(io.gravitee.rest.api.model.settings.Maintenance) Test(org.junit.Test)

Example 2 with Maintenance

use of io.gravitee.rest.api.model.settings.Maintenance in project gravitee-management-rest-api by gravitee-io.

the class ConsoleSettingsResourceTest method shouldNotCallSaveMethod_MaintenanceAlreadyEnabled.

@Test
public void shouldNotCallSaveMethod_MaintenanceAlreadyEnabled() {
    ConsoleSettingsEntity config = new ConsoleSettingsEntity();
    Maintenance maintenance = new Maintenance();
    maintenance.setEnabled(true);
    config.setMaintenance(maintenance);
    when(parameterService.findAsBoolean(Key.MAINTENANCE_MODE_ENABLED, GraviteeContext.getCurrentOrganization(), ParameterReferenceType.ORGANIZATION)).thenReturn(true);
    final Response response = orgTarget().request().post(Entity.json(config));
    assertEquals(response.readEntity(String.class), SERVICE_UNAVAILABLE_503, response.getStatus());
    verify(configService, never()).save(any(ConsoleSettingsEntity.class));
}
Also used : Response(javax.ws.rs.core.Response) ConsoleSettingsEntity(io.gravitee.rest.api.model.settings.ConsoleSettingsEntity) Maintenance(io.gravitee.rest.api.model.settings.Maintenance) Test(org.junit.Test)

Example 3 with Maintenance

use of io.gravitee.rest.api.model.settings.Maintenance in project gravitee-management-rest-api by gravitee-io.

the class ConsoleSettingsResourceTest method shouldCallSaveMethod.

@Test
public void shouldCallSaveMethod() {
    ConsoleSettingsEntity config = new ConsoleSettingsEntity();
    config.setMaintenance(new Maintenance());
    when(parameterService.findAsBoolean(Key.MAINTENANCE_MODE_ENABLED, GraviteeContext.getCurrentOrganization(), ParameterReferenceType.ORGANIZATION)).thenReturn(false);
    final Response response = orgTarget().request().post(Entity.json(config));
    assertEquals(response.readEntity(String.class), OK_200, response.getStatus());
    verify(configService).save(any(ConsoleSettingsEntity.class));
}
Also used : Response(javax.ws.rs.core.Response) ConsoleSettingsEntity(io.gravitee.rest.api.model.settings.ConsoleSettingsEntity) Maintenance(io.gravitee.rest.api.model.settings.Maintenance) Test(org.junit.Test)

Aggregations

ConsoleSettingsEntity (io.gravitee.rest.api.model.settings.ConsoleSettingsEntity)3 Maintenance (io.gravitee.rest.api.model.settings.Maintenance)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3