Search in sources :

Example 6 with FREventPolling

use of com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling in project openbanking-aspsp by OpenBankingToolkit.

the class EventPollingServiceTest method fetchNewEvents_longPollingRequest_rejectUnsupported.

@Test
public void fetchNewEvents_longPollingRequest_rejectUnsupported() throws Exception {
    // Given
    FREventPolling pollingRequest = FREventPolling.builder().maxEvents(10).returnImmediately(false).build();
    assertThatThrownBy(() -> eventPollingService.fetchNewEvents(pollingRequest, TPP_ID)).isInstanceOf(OBErrorResponseException.class);
}
Also used : FREventPolling(com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling) Test(org.junit.Test)

Example 7 with FREventPolling

use of com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling in project openbanking-aspsp by OpenBankingToolkit.

the class EventPollingServiceTest method acknowledgeEvents_nullList.

@Test
public void acknowledgeEvents_nullList() {
    // Given
    FREventPolling pollingRequest = FREventPolling.builder().ack(null).build();
    // When
    eventPollingService.acknowledgeEvents(pollingRequest, TPP_ID);
    // Then
    verifyZeroInteractions(mockRepo);
}
Also used : FREventPolling(com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling) Test(org.junit.Test)

Example 8 with FREventPolling

use of com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling in project openbanking-aspsp by OpenBankingToolkit.

the class EventPollingServiceTest method fetchNewEvents_getAll.

@Test
public void fetchNewEvents_getAll() throws Exception {
    // Given
    final FREventNotification existingNotification1 = FREventNotification.builder().id("1").jti("11111").signedJwt("test111").build();
    final FREventNotification existingNotification2 = FREventNotification.builder().id("2").jti("22222").signedJwt("test222").build();
    when(mockRepo.findByTppId(eq(TPP_ID))).thenReturn(ImmutableList.of(existingNotification1, existingNotification2));
    // When
    FREventPolling pollingRequest = FREventPolling.builder().maxEvents(100).returnImmediately(true).build();
    Map<String, String> eventNotifications = eventPollingService.fetchNewEvents(pollingRequest, TPP_ID);
    // Then
    assertThat(eventNotifications.size()).isEqualTo(2);
    assertThat(eventNotifications.get("11111")).isEqualTo("test111");
    assertThat(eventNotifications.get("22222")).isEqualTo("test222");
}
Also used : FREventNotification(com.forgerock.openbanking.common.model.openbanking.persistence.event.FREventNotification) FREventPolling(com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling) Test(org.junit.Test)

Example 9 with FREventPolling

use of com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling in project openbanking-aspsp by OpenBankingToolkit.

the class EventPollingServiceTest method recordTppEventErrors_notificationExists_addError.

@Test
public void recordTppEventErrors_notificationExists_addError() {
    // Given
    final FREventNotification existingNotification = FREventNotification.builder().id("1").jti("11111").errors(null).build();
    FREventPolling pollingRequest = FREventPolling.builder().setErrs(Collections.singletonMap("11111", FREventPollingError.builder().error("err1").description("error msg").build())).build();
    when(mockRepo.findByTppIdAndJti(any(), any())).thenReturn(Optional.of(existingNotification));
    // When
    eventPollingService.recordTppEventErrors(pollingRequest, TPP_ID);
    // Then
    verify(mockRepo, times(1)).save(any());
    assertThat(existingNotification.getErrors().getError()).isEqualTo("err1");
    assertThat(existingNotification.getErrors().getDescription()).isEqualTo("error msg");
}
Also used : FREventNotification(com.forgerock.openbanking.common.model.openbanking.persistence.event.FREventNotification) FREventPolling(com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling) Test(org.junit.Test)

Example 10 with FREventPolling

use of com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling in project openbanking-aspsp by OpenBankingToolkit.

the class EventPollingServiceTest method acknowledgeEvents_findAndDeleteTwoEvents_ignoreEventNotfound.

@Test
public void acknowledgeEvents_findAndDeleteTwoEvents_ignoreEventNotfound() {
    // Given
    FREventPolling pollingRequest = FREventPolling.builder().ack(ImmutableList.of("11111", "22222", "NotFound")).build();
    // When
    eventPollingService.acknowledgeEvents(pollingRequest, TPP_ID);
    // Then
    verify(mockRepo).deleteByTppIdAndJti(eq(TPP_ID), eq("11111"));
    verify(mockRepo).deleteByTppIdAndJti(eq(TPP_ID), eq("11111"));
}
Also used : FREventPolling(com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling) Test(org.junit.Test)

Aggregations

FREventPolling (com.forgerock.openbanking.common.model.openbanking.domain.event.FREventPolling)12 Test (org.junit.Test)10 FREventNotification (com.forgerock.openbanking.common.model.openbanking.persistence.event.FREventNotification)3 FREventPollingConverter.toFREventPolling (com.forgerock.openbanking.common.services.openbanking.converter.event.FREventPollingConverter.toFREventPolling)2 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)2 Tpp (com.forgerock.openbanking.model.Tpp)2 OBEventPollingResponse1 (uk.org.openbanking.datamodel.event.OBEventPollingResponse1)2