### Question:
CDPStructuredEventDBService extends AbstractAccountAwareResourceService<CDPStructuredEventEntity> implements CDPStructuredEventService { @Override public <T extends CDPStructuredEvent> Page<T> getPagedEventsOfResource(List<StructuredEventType> eventTypes, String resourceCrn, Pageable pageable) { LOGGER.debug("Gathering pageable events for types: '{}' and resource CRN: '{}'", eventTypes, resourceCrn); List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes); try { Page<CDPStructuredEventEntity> events = pagingStructuredEventRepository.findByEventTypeInAndResourceCrn(types, resourceCrn, pageable); return (Page<T>) Optional.ofNullable(events).orElse(Page.empty()).map(event -> conversionService.convert(event, CDPStructuredEvent.class)); } catch (Exception ex) { String msg = String.format("Failed get pageable events for types: '%s' and resource CRN: '%s'", types, resourceCrn); LOGGER.warn(msg, ex); throw new CloudbreakServiceException(msg, ex); } }  @Override void create(CDPStructuredEvent structuredEvent); boolean isEnabled(); @Override AccountAwareResourceRepository<CDPStructuredEventEntity, Long> repository(); @Override Page<T> getPagedEventsOfResource(List<StructuredEventType> eventTypes, String resourceCrn, Pageable pageable); @Override List<T> getEventsOfResource(List<StructuredEventType> eventTypes, String resourceCrn);  }### Answer:
@Test public void testGetPagedEventsOfResourceWhenEventTypesEmpty() { ArgumentCaptor<List> eventTypes = ArgumentCaptor.forClass(List.class); Pageable unpaged = Pageable.unpaged(); when(pagingStructuredEventRepository.findByEventTypeInAndResourceCrn(eventTypes.capture(), eq("crn"), eq(unpaged))).thenReturn(Page.empty()); underTest.getPagedEventsOfResource(Collections.emptyList(), "crn", unpaged); List actual = eventTypes.getValue(); Assertions.assertEquals(List.of(NOTIFICATION, REST, FLOW), actual); }
@Test public void testGetPagedEventsOfResourceWhenEventTypesNotEmpty() { ArgumentCaptor<List> eventTypes = ArgumentCaptor.forClass(List.class); Pageable unpaged = Pageable.unpaged(); when(pagingStructuredEventRepository.findByEventTypeInAndResourceCrn(eventTypes.capture(), eq("crn"), eq(unpaged))).thenReturn(Page.empty()); underTest.getPagedEventsOfResource(List.of(NOTIFICATION), "crn", unpaged); List actual = eventTypes.getValue(); Assertions.assertEquals(List.of(NOTIFICATION), actual); }