Search in sources :

Example 1 with Condition

use of io.gravitee.alert.api.condition.Condition in project gravitee-management-rest-api by gravitee-io.

the class ApplicationAlertServiceTest method prepareForCreation.

@NotNull
private void prepareForCreation(NewAlertTriggerEntity newAlert) {
    // recipients
    when(membershipService.getMembershipsByReference(MembershipReferenceType.APPLICATION, APPLICATION_ID)).thenReturn(Collections.emptySet());
    UserEntity user1 = new UserEntity();
    user1.setEmail("user1@mail.gio");
    UserEntity user2 = new UserEntity();
    user2.setEmail("user2@mail.gio");
    Set<UserEntity> users = new HashSet<>();
    users.add(user1);
    users.add(user2);
    when(userService.findByIds(any())).thenReturn(users);
    // body
    List<Condition> conditions = new ArrayList<>();
    conditions.add(RateCondition.of(ThresholdRangeCondition.between("response.status", 200D, 299D).build()).duration(10L, TimeUnit.MINUTES).greaterThan(5D).build());
    newAlert.setConditions(conditions);
}
Also used : RateCondition(io.gravitee.alert.api.condition.RateCondition) Condition(io.gravitee.alert.api.condition.Condition) ThresholdRangeCondition(io.gravitee.alert.api.condition.ThresholdRangeCondition) ArrayList(java.util.ArrayList) UserEntity(io.gravitee.rest.api.model.UserEntity) HashSet(java.util.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Condition (io.gravitee.alert.api.condition.Condition)1 RateCondition (io.gravitee.alert.api.condition.RateCondition)1 ThresholdRangeCondition (io.gravitee.alert.api.condition.ThresholdRangeCondition)1 UserEntity (io.gravitee.rest.api.model.UserEntity)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 NotNull (org.jetbrains.annotations.NotNull)1