Package org.sonar.api.notifications

Examples of org.sonar.api.notifications.Notification


    assertThat(manager.getChannels()).hasSize(0);
  }

  @Test
  public void shouldPersist() throws Exception {
    Notification notification = new Notification("test");
    manager.scheduleForSending(notification);

    verify(notificationQueueDao, only()).insert(any(List.class));
  }
View Full Code Here


    verify(notificationQueueDao, only()).insert(any(List.class));
  }

  @Test
  public void shouldGetFromQueueAndDelete() throws Exception {
    Notification notification = new Notification("test");
    NotificationQueueDto dto = NotificationQueueDto.toNotificationQueueDto(notification);
    List<NotificationQueueDto> dtos = Arrays.asList(dto);
    when(notificationQueueDao.findOldest(1)).thenReturn(dtos);

    assertThat(manager.getFromQueue()).isNotNull();
View Full Code Here

    dao = new NotificationQueueDao(getMyBatis());
  }

  @Test
  public void should_insert_new_notification_queue() throws Exception {
    NotificationQueueDto notificationQueueDto = NotificationQueueDto.toNotificationQueueDto(new Notification("email"));

    dao.insert(Arrays.asList(notificationQueueDto));

    assertThat(dao.count()).isEqualTo(1);
    assertThat(dao.findOldest(1).get(0).toNotification().getType()).isEqualTo("email");
View Full Code Here

    assertThat(dao.findOldest(1).get(0).toNotification().getType()).isEqualTo("email");
  }

  @Test
  public void should_count_notification_queue() {
    NotificationQueueDto notificationQueueDto = NotificationQueueDto.toNotificationQueueDto(new Notification("email"));

    assertThat(dao.count()).isEqualTo(0);

    dao.insert(Arrays.asList(notificationQueueDto));
View Full Code Here

    Date date = DateUtils.parseDateTime("2013-05-18T13:00:03+0200");
    Project project = new Project("struts").setAnalysisDate(date);
    IssuesBySeverity issuesBySeverity = mock(IssuesBySeverity.class);
    when(issuesBySeverity.size()).thenReturn(42);
    when(issuesBySeverity.issues("MINOR")).thenReturn(10);
    Notification notification = issueNotifications.sendNewIssues(project, issuesBySeverity);

    assertThat(notification.getFieldValue("count")).isEqualTo("42");
    assertThat(notification.getFieldValue("count-MINOR")).isEqualTo("10");
    assertThat(DateUtils.parseDateTime(notification.getFieldValue("projectDate"))).isEqualTo(date);
    Mockito.verify(manager).scheduleForSending(notification);
  }
View Full Code Here

      .setFieldChange(context, "assignee", "simon", null)
      .setSendNotifications(true)
      .setComponentKey("struts:Action")
      .setProjectKey("struts");

    Notification notification = issueNotifications.sendChanges(issue, context, null, new Project("struts"), null).get(0);

    assertThat(notification.getFieldValue("message")).isEqualTo("the message");
    assertThat(notification.getFieldValue("key")).isEqualTo("ABCDE");
    assertThat(notification.getFieldValue("componentKey")).isEqualTo("struts:Action");
    assertThat(notification.getFieldValue("componentName")).isNull();
    assertThat(notification.getFieldValue("old.resolution")).isNull();
    assertThat(notification.getFieldValue("new.resolution")).isEqualTo("FIXED");
    assertThat(notification.getFieldValue("old.status")).isEqualTo("OPEN");
    assertThat(notification.getFieldValue("new.status")).isEqualTo("RESOLVED");
    assertThat(notification.getFieldValue("old.assignee")).isEqualTo("simon");
    assertThat(notification.getFieldValue("new.assignee")).isNull();
    Mockito.verify(manager).scheduleForSending(eq(Arrays.asList(notification)));
  }
View Full Code Here

      .setMessage("the message")
      .setKey("ABCDE")
      .setAssignee("freddy")
      .setComponentKey("struts:Action")
      .setProjectKey("struts");
    Notification notification = issueNotifications.sendChanges(issue, context, null, new Project("struts"), null, "I don't know how to fix it?").get(0);

    assertThat(notification.getFieldValue("message")).isEqualTo("the message");
    assertThat(notification.getFieldValue("key")).isEqualTo("ABCDE");
    assertThat(notification.getFieldValue("comment")).isEqualTo("I don't know how to fix it?");
    Mockito.verify(manager).scheduleForSending(eq(Arrays.asList(notification)));
  }
View Full Code Here

      .setAssignee("freddy")
      .setFieldChange(context, "resolution", null, "FIXED")
      .setSendNotifications(true)
      .setComponentKey("struts:Action.java")
      .setProjectKey("struts");
    Notification notification = issueNotifications.sendChanges(issue, context, null, new Project("struts"),
      new ResourceComponent(File.create("Action.java", "Action.java", null, false).setEffectiveKey("struts:Action.java"))).get(0);

    assertThat(notification.getFieldValue("message")).isEqualTo("the message");
    assertThat(notification.getFieldValue("key")).isEqualTo("ABCDE");
    assertThat(notification.getFieldValue("componentKey")).isEqualTo("struts:Action.java");
    assertThat(notification.getFieldValue("componentName")).isEqualTo("Action.java");
    assertThat(notification.getFieldValue("old.resolution")).isNull();
    assertThat(notification.getFieldValue("new.resolution")).isEqualTo("FIXED");
    Mockito.verify(manager).scheduleForSending(eq(Arrays.asList(notification)));
  }
View Full Code Here

  private Notification notification;

  @Before
  public void init() {
    notification = new Notification("alerts").setDefaultMessage("There are new alerts").setFieldValue("alertCount", "42");
  }
View Full Code Here

    assertThat(notification.getDefaultMessage()).isEqualTo("There are new alerts");
  }

  @Test
  public void shouldReturnToStringIfDefaultMessageNotSet() {
    notification = new Notification("alerts").setFieldValue("alertCount", "42");
    System.out.println(notification);
    assertThat(notification.getDefaultMessage()).contains("type=alerts");
    assertThat(notification.getDefaultMessage()).contains("fields={alertCount=42}");
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.notifications.Notification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.