use of org.sonarsource.sonarlint.core.client.api.common.NotificationConfiguration in project sonarlint-core by SonarSource.
the class NotificationTimerTaskTest method testSingleProjectWithNotifications.
@Test
public void testSingleProjectWithNotifications() {
// return one notification for our project
SonarQubeNotification notif = mock(SonarQubeNotification.class);
when(notif.projectKey()).thenReturn("myproject");
when(notificationChecker.request(Collections.singletonMap("myproject", time))).thenReturn(Collections.singletonList(notif));
// execute with one project
NotificationConfiguration project = createProject("myproject");
timerTask.setProjects(Collections.singleton(project));
timerTask.run();
// verify checker used once and notification was returned through the listener
verify(notificationCheckerFactory, times(1)).create(any(ServerConfiguration.class));
verify(notificationChecker).request(Collections.singletonMap("myproject", time));
verify(listener).handle(notif);
}
use of org.sonarsource.sonarlint.core.client.api.common.NotificationConfiguration in project sonarlint-core by SonarSource.
the class NotificationTimerTaskTest method testLimit24h.
@Test
public void testLimit24h() {
when(notificationTime.get()).thenReturn(ZonedDateTime.now().minusDays(30));
// return one notification for our project
SonarQubeNotification notif = mock(SonarQubeNotification.class);
when(notif.projectKey()).thenReturn("myproject");
when(notificationChecker.request(anyMap())).thenReturn(Collections.singletonList(notif));
// execute with one project
NotificationConfiguration project = createProject("myproject");
timerTask.setProjects(Collections.singleton(project));
timerTask.run();
// verify checker used once and notification was returned through the listener
verify(notificationCheckerFactory, times(1)).create(any(ServerConfiguration.class));
verify(notificationChecker).request(ArgumentMatchers.argThat(map -> {
ZonedDateTime time = map.values().iterator().next();
return time.isAfter(ZonedDateTime.now().minusHours(25)) && time.isBefore(ZonedDateTime.now().minusHours(23));
}));
verify(listener).handle(notif);
}
use of org.sonarsource.sonarlint.core.client.api.common.NotificationConfiguration in project sonarlint-core by SonarSource.
the class NotificationTimerTaskTest method testSingleProjectWithoutNotifications.
@Test
public void testSingleProjectWithoutNotifications() {
NotificationConfiguration project = createProject("myproject");
timerTask.setProjects(Collections.singleton(project));
timerTask.run();
verify(notificationCheckerFactory, times(1)).create(any(ServerConfiguration.class));
verify(notificationChecker).request(Collections.singletonMap("myproject", time));
verifyZeroInteractions(listener);
}
use of org.sonarsource.sonarlint.core.client.api.common.NotificationConfiguration in project sonarlint-intellij by SonarSource.
the class SonarQubeEventNotifications method createConfiguration.
private NotificationConfiguration createConfiguration(SonarLintProjectSettings settings, SonarQubeServer server) {
String projectKey = settings.getProjectKey();
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
return new NotificationConfiguration(eventListener, notificationTime, projectKey, serverConfiguration);
}
Aggregations