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);
}
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);
}
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");
}
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");
}
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"));
}
Aggregations