@Test
public void testTemplateNaming() {

    UserService userService = system.getServiceFactory().getUserService();
    Alert alert = new Alert(userService.findAdminUser(), userService.findAdminUser(), "${sCopE}-trigger_name-${MEtriC}-trigger_metric-${tag.tag1}-trigger_tag1-${tag.tag2}-trigger_tag2-${tag.TAg3}-${tag.tAg2}-${device}-${device}", expression, "* * * * *");
    Notification notification = new Notification("notification_name", alert, "notifier_name", new ArrayList<String>(), 23);
    Trigger trigger = new Trigger(alert, Trigger.TriggerType.GREATER_THAN_OR_EQ, "${sCopE}-trigger_name-${MEtriC}-trigger_metric-${tag.tag1}-trigger_tag1-${tag.tag2}-trigger_tag2-${tag.tag3}-${tag.tAg2}", 2D, 5);
    alert.setNotifications(Arrays.asList(new Notification[] { notification }));
    alert.setTriggers(Arrays.asList(new Trigger[] { trigger }));
    alert = system.getServiceFactory().getAlertService().updateAlert(alert);
    Metric m = new Metric("scope", "metric");
    Map<String, String> tags = new HashMap<>();
    tags.put("tag1","val1");
    tags.put("tag2", "val2");
    tags.put("tag3", "val3");
    tags.put("device", "device");
    m.setTags(tags);
    History history = new History(History.JobStatus.SUCCESS.getDescription(), "localhost", BigInteger.ONE, History.JobStatus.SUCCESS);
    DefaultAlertService.NotificationContext context = new DefaultAlertService.NotificationContext(alert, alert.getTriggers().get(0), notification,
            1418319600000L, 0.0, m, history);
    AlertService.Notifier notifier = system.getServiceFactory().getAlertService().getNotifier(AlertService.SupportedNotifier.GOC);
    notifier.sendNotification(context);
    assertEquals("${sCopE}-trigger_name-${MEtriC}-trigger_metric-${tag.tag1}-trigger_tag1-${tag.tag2}-trigger_tag2-${tag.tag3}-${tag.tAg2}", context.getTrigger().getName());
    assertEquals("scope-trigger_name-metric-trigger_metric-val1-trigger_tag1-val2-trigger_tag2-val3-val2-device-device", TemplateReplacer.applyTemplateChanges(context, context.getAlert().getName()));
}