@Test
public void testGetTriggerFiredDatapointTimeWhenMissingTimeStamps4() {

    UserService userService = system.getServiceFactory().getUserService();
    Alert alert = new Alert(userService.findAdminUser(), userService.findAdminUser(), "alert-name_test", EXPRESSION, "* * * * *");
    Metric metric = new Metric("scope", "metric");
    double thresholdValue = 1;
    long inertia = 5*60*1000;
    Trigger trigger = new Trigger(alert, TriggerType.GREATER_THAN_OR_EQ, "name_test", thresholdValue, inertia);
    Map<Long, Double> datapoints = new HashMap<Long, Double>();
    datapoints.put(0L, 2.0);
    datapoints.put(3*60*1000L, 2.0);
    datapoints.put(6*60*1000L, 2.0);
    datapoints.put(7*60*1000L, 0.0);
    datapoints.put(9*60*1000L, 2.0);
    metric.setDatapoints(datapoints);
    long actualValue = alertService.getTriggerFiredDatapointTime(trigger, metric, alert.getExpression(), 1L);
    long expectedTriggerTime = 6 * 60 * 1000;
    assertEquals(expectedTriggerTime, actualValue);
}