public static Alert getOpenAlert() { List<Set<ConditionEval>> satisfyingEvals = new ArrayList<>(); Data rtBadData1 = Data.forNumeric(firingCondition.getDataId(), System.currentTimeMillis(), 1900d); ThresholdConditionEval eval1 = new ThresholdConditionEval(firingCondition, rtBadData1); Set<ConditionEval> evalSet1 = new HashSet<>(); evalSet1.add(eval1); satisfyingEvals.add(evalSet1); // 5 seconds later Data rtBadData2 = Data.forNumeric(firingCondition.getDataId(), System.currentTimeMillis() + 5000, 1800d); ThresholdConditionEval eval2 = new ThresholdConditionEval(firingCondition, rtBadData2); Set<ConditionEval> evalSet2 = new HashSet<>(); evalSet2.add(eval2); satisfyingEvals.add(evalSet2); Alert openAlert = new Alert(trigger.getTenantId(), trigger, firingDampening, satisfyingEvals); return openAlert; }
public static Alert resolveAlert(Alert unresolvedAlert) { List<Set<ConditionEval>> resolvedEvals = new ArrayList<>(); Data rtGoodData = Data.forNumeric(autoResolveCondition.getDataId(), System.currentTimeMillis() + 20000, 900d); ThresholdConditionEval eval1 = new ThresholdConditionEval(autoResolveCondition, rtGoodData); Set<ConditionEval> evalSet1 = new HashSet<>(); evalSet1.add(eval1); resolvedEvals.add(evalSet1); unresolvedAlert.setResolvedEvalSets(resolvedEvals); unresolvedAlert.setStatus(Alert.Status.RESOLVED); unresolvedAlert.setResolvedBy(RESOLVED_BY); unresolvedAlert.addNote(RESOLVED_BY, RESOLVED_NOTES); unresolvedAlert.setResolvedTime(System.currentTimeMillis()); return unresolvedAlert; }