use of org.sonarsource.sonarlint.core.client.api.notifications.LastNotificationTime in project sonarlint-core by SonarSource.
the class NotificationTimerTaskTest method testRepeatedProject.
@Test
public void testRepeatedProject() {
// 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");
NotificationConfiguration project2 = createProject("myproject");
LastNotificationTime notificationTime = mock(LastNotificationTime.class);
when(notificationTime.get()).thenReturn(ZonedDateTime.now().minusHours(2));
when(project2.lastNotificationTime()).thenReturn(notificationTime);
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));
// should use the most recent time
verify(notificationChecker).request(Collections.singletonMap("myproject", time));
verify(listener).handle(notif);
}
use of org.sonarsource.sonarlint.core.client.api.notifications.LastNotificationTime in project sonarlint-core by SonarSource.
the class NotificationConfigurationTest method testGetters.
@Test
public void testGetters() {
SonarQubeNotificationListener listener = mock(SonarQubeNotificationListener.class);
LastNotificationTime lastNotificationTime = mock(LastNotificationTime.class);
String projectKey = "key";
ServerConfiguration serverConfiguration = mock(ServerConfiguration.class);
NotificationConfiguration configuration = new NotificationConfiguration(listener, lastNotificationTime, projectKey, serverConfiguration);
assertThat(configuration.lastNotificationTime()).isEqualTo(lastNotificationTime);
assertThat(configuration.listener()).isEqualTo(listener);
assertThat(configuration.projectKey()).isEqualTo(projectKey);
assertThat(configuration.serverConfiguration()).isEqualTo(serverConfiguration);
}
Aggregations