Search in sources :

Example 1 with ProjectNotificationUserView

use of com.synopsys.integration.blackduck.api.manual.view.ProjectNotificationUserView in project hub-alert by blackducksoftware.

the class BlackDuckNotificationRetrieverTest method retrievePageOfFilteredNotificationsTest.

@Test
public void retrievePageOfFilteredNotificationsTest() throws IntegrationException {
    ProjectNotificationUserView projectNotificationView = new ProjectNotificationUserView();
    BlackDuckPageResponse<NotificationUserView> pageResponse = new BlackDuckPageResponse<>(1, List.of(projectNotificationView));
    UrlMultipleResponses<NotificationUserView> currentUserNotificationsUrl = new UrlMultipleResponses<>(new HttpUrl(THROWAWAY_SERVER), NotificationUserView.class);
    UserView apiUser = Mockito.mock(UserView.class);
    Mockito.doReturn(currentUserNotificationsUrl).when(apiUser).metaNotificationsLink();
    UrlSingleResponse<UserView> currentUserUrl = new UrlSingleResponse<>(new HttpUrl(THROWAWAY_SERVER), UserView.class);
    ApiDiscovery apiDiscovery = Mockito.mock(ApiDiscovery.class);
    Mockito.doReturn(currentUserUrl).when(apiDiscovery).metaCurrentUserLink();
    BlackDuckApiClient blackDuckApiClient = Mockito.mock(BlackDuckApiClient.class);
    Mockito.doReturn(pageResponse).when(blackDuckApiClient).getPageResponse(Mockito.any(BlackDuckMultipleRequest.class));
    Mockito.doReturn(apiUser).when(blackDuckApiClient).getResponse(Mockito.eq(currentUserUrl));
    BlackDuckAccumulatorSearchDateManager dateRangeCreator = createDateRangeCreator();
    BlackDuckNotificationRetriever notificationRetriever = new BlackDuckNotificationRetriever(blackDuckApiClient, apiDiscovery);
    StatefulAlertPage<NotificationUserView, IntegrationException> notificationPage = notificationRetriever.retrievePageOfFilteredNotifications(dateRangeCreator.retrieveNextSearchDateRange(), List.of());
    assertEquals(pageResponse.getItems(), notificationPage.getCurrentModels());
}
Also used : UrlSingleResponse(com.synopsys.integration.blackduck.api.core.response.UrlSingleResponse) IntegrationException(com.synopsys.integration.exception.IntegrationException) BlackDuckMultipleRequest(com.synopsys.integration.blackduck.service.request.BlackDuckMultipleRequest) NotificationUserView(com.synopsys.integration.blackduck.api.manual.view.NotificationUserView) ProjectNotificationUserView(com.synopsys.integration.blackduck.api.manual.view.ProjectNotificationUserView) UserView(com.synopsys.integration.blackduck.api.generated.view.UserView) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) HttpUrl(com.synopsys.integration.rest.HttpUrl) BlackDuckPageResponse(com.synopsys.integration.blackduck.http.BlackDuckPageResponse) UrlMultipleResponses(com.synopsys.integration.blackduck.api.core.response.UrlMultipleResponses) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) ProjectNotificationUserView(com.synopsys.integration.blackduck.api.manual.view.ProjectNotificationUserView) NotificationUserView(com.synopsys.integration.blackduck.api.manual.view.NotificationUserView) ProjectNotificationUserView(com.synopsys.integration.blackduck.api.manual.view.ProjectNotificationUserView) Test(org.junit.jupiter.api.Test)

Aggregations

UrlMultipleResponses (com.synopsys.integration.blackduck.api.core.response.UrlMultipleResponses)1 UrlSingleResponse (com.synopsys.integration.blackduck.api.core.response.UrlSingleResponse)1 ApiDiscovery (com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery)1 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 NotificationUserView (com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)1 ProjectNotificationUserView (com.synopsys.integration.blackduck.api.manual.view.ProjectNotificationUserView)1 BlackDuckPageResponse (com.synopsys.integration.blackduck.http.BlackDuckPageResponse)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 BlackDuckMultipleRequest (com.synopsys.integration.blackduck.service.request.BlackDuckMultipleRequest)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1 Test (org.junit.jupiter.api.Test)1