@Test public void findEventsByEntityIdAndPageLink() { UUID tenantId = Uuids.timeBased(); UUID entityId1 = Uuids.timeBased(); UUID entityId2 = Uuids.timeBased(); long startTime = System.currentTimeMillis(); long endTime = createEventsTwoEntities(tenantId, entityId1, entityId2, startTime, 20); TimePageLink pageLink1 = new TimePageLink(30); PageData<Event> events1 = eventDao.findEvents(tenantId, new DeviceId(entityId1), pageLink1); assertEquals(10, events1.getData().size()); TimePageLink pageLink2 = new TimePageLink(30, 0, "", null, startTime, null); PageData<Event> events2 = eventDao.findEvents(tenantId, new DeviceId(entityId1), pageLink2); assertEquals(10, events2.getData().size()); TimePageLink pageLink3 = new TimePageLink(30, 0, "", null, startTime, endTime); PageData<Event> events3 = eventDao.findEvents(tenantId, new DeviceId(entityId1), pageLink3); assertEquals(10, events3.getData().size()); TimePageLink pageLink4 = new TimePageLink(5, 0, "", null, startTime, endTime); PageData<Event> events4 = eventDao.findEvents(tenantId, new DeviceId(entityId1), pageLink4); assertEquals(5, events4.getData().size()); pageLink4 = pageLink4.nextPageLink(); PageData<Event> events5 = eventDao.findEvents(tenantId, new DeviceId(entityId1), pageLink4); assertEquals(5, events5.getData().size()); pageLink4 = pageLink4.nextPageLink(); PageData<Event> events6 = eventDao.findEvents(tenantId, new DeviceId(entityId1), pageLink4); assertEquals(0, events6.getData().size()); }
@Override public PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink) { return DaoUtil.toPageData( eventRepository .findEventsByTenantIdAndEntityId( tenantId, entityId.getEntityType(), entityId.getId(), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getStartTime(), pageLink.getEndTime(), DaoUtil.toPageable(pageLink))); }
JpaBaseEventDao extends JpaAbstractDao<EventEntity, Event> implements EventDao { @Override public PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink) { return DaoUtil.toPageData( eventRepository .findEventsByTenantIdAndEntityId( tenantId, entityId.getEntityType(), entityId.getId(), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getStartTime(), pageLink.getEndTime(), DaoUtil.toPageable(pageLink))); } }
JpaBaseEventDao extends JpaAbstractDao<EventEntity, Event> implements EventDao { @Override public PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink) { return DaoUtil.toPageData( eventRepository .findEventsByTenantIdAndEntityId( tenantId, entityId.getEntityType(), entityId.getId(), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getStartTime(), pageLink.getEndTime(), DaoUtil.toPageable(pageLink))); }  }
JpaBaseEventDao extends JpaAbstractDao<EventEntity, Event> implements EventDao { @Override public PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink) { return DaoUtil.toPageData( eventRepository .findEventsByTenantIdAndEntityId( tenantId, entityId.getEntityType(), entityId.getId(), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getStartTime(), pageLink.getEndTime(), DaoUtil.toPageable(pageLink))); }  @Override Event save(TenantId tenantId, Event event); @Override ListenableFuture<Event> saveAsync(Event event); @Override Optional<Event> saveIfNotExists(Event event); @Override Event findEvent(UUID tenantId, EntityId entityId, String eventType, String eventUid); @Override PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink); @Override PageData<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink); @Override List<Event> findLatestEvents(UUID tenantId, EntityId entityId, String eventType, int limit); Optional<Event> save(EventEntity entity, boolean ifNotExists); }
JpaBaseEventDao extends JpaAbstractDao<EventEntity, Event> implements EventDao { @Override public PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink) { return DaoUtil.toPageData( eventRepository .findEventsByTenantIdAndEntityId( tenantId, entityId.getEntityType(), entityId.getId(), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getStartTime(), pageLink.getEndTime(), DaoUtil.toPageable(pageLink))); }  @Override Event save(TenantId tenantId, Event event); @Override ListenableFuture<Event> saveAsync(Event event); @Override Optional<Event> saveIfNotExists(Event event); @Override Event findEvent(UUID tenantId, EntityId entityId, String eventType, String eventUid); @Override PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink); @Override PageData<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink); @Override List<Event> findLatestEvents(UUID tenantId, EntityId entityId, String eventType, int limit); Optional<Event> save(EventEntity entity, boolean ifNotExists);  }