Search in sources :

Example 1 with AlertInput

use of io.gravitee.rest.api.portal.rest.model.AlertInput in project gravitee-management-rest-api by gravitee-io.

the class AlertMapperTest method convertAlertInputToUpdateAlertTriggerEntityResponseTime.

@Test
public void convertAlertInputToUpdateAlertTriggerEntityResponseTime() {
    final AlertInput alertInput = new AlertInput();
    alertInput.setEnabled(true);
    alertInput.setResponseTime(35);
    alertInput.setDuration(10);
    alertInput.setTimeUnit(AlertTimeUnit.MINUTES);
    alertInput.setType(AlertType.RESPONSE_TIME);
    final UpdateAlertTriggerEntity actual = alertMapper.convertToUpdate(alertInput);
    assertThat(actual.isEnabled()).isEqualTo(alertInput.getEnabled());
    final AggregationCondition aggregationCondition = (AggregationCondition) actual.getConditions().get(0);
    assertThat(aggregationCondition.getDuration()).isEqualTo(alertInput.getDuration().longValue());
    assertThat(aggregationCondition.getTimeUnit()).isEqualTo(TimeUnit.MINUTES);
    assertThat(aggregationCondition.getThreshold()).isEqualTo(alertInput.getResponseTime().doubleValue());
}
Also used : UpdateAlertTriggerEntity(io.gravitee.rest.api.model.alert.UpdateAlertTriggerEntity) AggregationCondition(io.gravitee.alert.api.condition.AggregationCondition) AlertInput(io.gravitee.rest.api.portal.rest.model.AlertInput) Test(org.junit.Test)

Example 2 with AlertInput

use of io.gravitee.rest.api.portal.rest.model.AlertInput in project gravitee-management-rest-api by gravitee-io.

the class AlertMapperTest method convertAlertInputToUpdateAlertTriggerEntityStatus2xx.

@Test
public void convertAlertInputToUpdateAlertTriggerEntityStatus2xx() {
    final AlertInput alertInput = new AlertInput();
    alertInput.setEnabled(true);
    alertInput.setStatusCode("2xx");
    alertInput.setStatusPercent(20);
    alertInput.setDuration(10);
    alertInput.setTimeUnit(AlertTimeUnit.MINUTES);
    alertInput.setType(AlertType.STATUS);
    final UpdateAlertTriggerEntity actual = alertMapper.convertToUpdate(alertInput);
    assertThat(actual.isEnabled()).isEqualTo(alertInput.getEnabled());
    final RateCondition rateCondition = (RateCondition) actual.getConditions().get(0);
    assertThat(rateCondition.getDuration()).isEqualTo(alertInput.getDuration().longValue());
    assertThat(rateCondition.getTimeUnit()).isEqualTo(TimeUnit.MINUTES);
    assertThat(rateCondition.getThreshold()).isEqualTo(alertInput.getStatusPercent().doubleValue());
    final ThresholdRangeCondition condition = (ThresholdRangeCondition) rateCondition.getComparison();
    assertThat(condition.getProperty()).isEqualTo("response.status");
    assertThat(condition.getThresholdLow()).isEqualTo(200D);
    assertThat(condition.getThresholdHigh()).isEqualTo(299D);
}
Also used : UpdateAlertTriggerEntity(io.gravitee.rest.api.model.alert.UpdateAlertTriggerEntity) AlertInput(io.gravitee.rest.api.portal.rest.model.AlertInput) RateCondition(io.gravitee.alert.api.condition.RateCondition) ThresholdRangeCondition(io.gravitee.alert.api.condition.ThresholdRangeCondition) Test(org.junit.Test)

Example 3 with AlertInput

use of io.gravitee.rest.api.portal.rest.model.AlertInput in project gravitee-management-rest-api by gravitee-io.

the class AlertMapperTest method convertAlertInputToUpdateAlertTriggerEntityStatus200.

@Test
public void convertAlertInputToUpdateAlertTriggerEntityStatus200() {
    final AlertInput alertInput = new AlertInput();
    alertInput.setEnabled(true);
    alertInput.setStatusCode("200");
    alertInput.setStatusPercent(20);
    alertInput.setDuration(10);
    alertInput.setTimeUnit(AlertTimeUnit.MINUTES);
    alertInput.setType(AlertType.STATUS);
    final UpdateAlertTriggerEntity actual = alertMapper.convertToUpdate(alertInput);
    assertThat(actual.isEnabled()).isEqualTo(alertInput.getEnabled());
    final RateCondition rateCondition = (RateCondition) actual.getConditions().get(0);
    assertThat(rateCondition.getDuration()).isEqualTo(alertInput.getDuration().longValue());
    assertThat(rateCondition.getTimeUnit()).isEqualTo(TimeUnit.MINUTES);
    assertThat(rateCondition.getThreshold()).isEqualTo(alertInput.getStatusPercent().doubleValue());
    final ThresholdRangeCondition condition = (ThresholdRangeCondition) rateCondition.getComparison();
    assertThat(condition.getProperty()).isEqualTo("response.status");
    assertThat(condition.getThresholdLow()).isEqualTo(200D);
    assertThat(condition.getThresholdHigh()).isEqualTo(200D);
}
Also used : UpdateAlertTriggerEntity(io.gravitee.rest.api.model.alert.UpdateAlertTriggerEntity) AlertInput(io.gravitee.rest.api.portal.rest.model.AlertInput) RateCondition(io.gravitee.alert.api.condition.RateCondition) ThresholdRangeCondition(io.gravitee.alert.api.condition.ThresholdRangeCondition) Test(org.junit.Test)

Example 4 with AlertInput

use of io.gravitee.rest.api.portal.rest.model.AlertInput in project gravitee-management-rest-api by gravitee-io.

the class AlertMapperTest method convertAlertInputToNewAlertTriggerEntityResponseTime.

@Test
public void convertAlertInputToNewAlertTriggerEntityResponseTime() {
    final AlertInput alertInput = new AlertInput();
    alertInput.setEnabled(true);
    alertInput.setResponseTime(35);
    alertInput.setDuration(10);
    alertInput.setTimeUnit(AlertTimeUnit.MINUTES);
    alertInput.setType(AlertType.RESPONSE_TIME);
    final NewAlertTriggerEntity actual = alertMapper.convert(alertInput);
    assertThat(actual.isEnabled()).isEqualTo(alertInput.getEnabled());
    assertThat(actual.getType()).isEqualTo(AlertMapper.RESPONSE_TIME_ALERT);
    final AggregationCondition aggregationCondition = (AggregationCondition) actual.getConditions().get(0);
    assertThat(aggregationCondition.getDuration()).isEqualTo(alertInput.getDuration().longValue());
    assertThat(aggregationCondition.getTimeUnit()).isEqualTo(TimeUnit.MINUTES);
    assertThat(aggregationCondition.getThreshold()).isEqualTo(alertInput.getResponseTime().doubleValue());
}
Also used : AggregationCondition(io.gravitee.alert.api.condition.AggregationCondition) AlertInput(io.gravitee.rest.api.portal.rest.model.AlertInput) NewAlertTriggerEntity(io.gravitee.rest.api.model.alert.NewAlertTriggerEntity) Test(org.junit.Test)

Example 5 with AlertInput

use of io.gravitee.rest.api.portal.rest.model.AlertInput in project gravitee-management-rest-api by gravitee-io.

the class AlertMapperTest method convertAlertInputToNewAlertTriggerEntityStatus2xx.

@Test
public void convertAlertInputToNewAlertTriggerEntityStatus2xx() {
    final AlertInput alertInput = new AlertInput();
    alertInput.setEnabled(true);
    alertInput.setStatusCode("2xx");
    alertInput.setStatusPercent(20);
    alertInput.setDuration(10);
    alertInput.setTimeUnit(AlertTimeUnit.MINUTES);
    alertInput.setType(AlertType.STATUS);
    final NewAlertTriggerEntity actual = alertMapper.convert(alertInput);
    assertThat(actual.isEnabled()).isEqualTo(alertInput.getEnabled());
    assertThat(actual.getType()).isEqualTo(AlertMapper.STATUS_ALERT);
    final RateCondition rateCondition = (RateCondition) actual.getConditions().get(0);
    assertThat(rateCondition.getDuration()).isEqualTo(alertInput.getDuration().longValue());
    assertThat(rateCondition.getTimeUnit()).isEqualTo(TimeUnit.MINUTES);
    assertThat(rateCondition.getThreshold()).isEqualTo(alertInput.getStatusPercent().doubleValue());
    final ThresholdRangeCondition condition = (ThresholdRangeCondition) rateCondition.getComparison();
    assertThat(condition.getProperty()).isEqualTo("response.status");
    assertThat(condition.getThresholdLow()).isEqualTo(200D);
    assertThat(condition.getThresholdHigh()).isEqualTo(299D);
}
Also used : AlertInput(io.gravitee.rest.api.portal.rest.model.AlertInput) NewAlertTriggerEntity(io.gravitee.rest.api.model.alert.NewAlertTriggerEntity) RateCondition(io.gravitee.alert.api.condition.RateCondition) ThresholdRangeCondition(io.gravitee.alert.api.condition.ThresholdRangeCondition) Test(org.junit.Test)

Aggregations

AlertInput (io.gravitee.rest.api.portal.rest.model.AlertInput)6 Test (org.junit.Test)6 RateCondition (io.gravitee.alert.api.condition.RateCondition)4 ThresholdRangeCondition (io.gravitee.alert.api.condition.ThresholdRangeCondition)4 NewAlertTriggerEntity (io.gravitee.rest.api.model.alert.NewAlertTriggerEntity)3 UpdateAlertTriggerEntity (io.gravitee.rest.api.model.alert.UpdateAlertTriggerEntity)3 AggregationCondition (io.gravitee.alert.api.condition.AggregationCondition)2