### Question:
JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements AlarmDao { @Override public ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type) { return service.submit(() -> { List<AlarmEntity> latest = alarmRepository.findLatestByOriginatorAndType( UUIDConverter.fromTimeUUID(tenantId.getId()), UUIDConverter.fromTimeUUID(originator.getId()), originator.getEntityType(), type, new PageRequest(0, 1)); return latest.isEmpty() ? null : DaoUtil.getData(latest.get(0)); }); }  @Override Boolean deleteAlarm(TenantId tenantId, Alarm alarm); @Override ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type); @Override ListenableFuture<Alarm> findAlarmByIdAsync(TenantId tenantId, UUID key); @Override ListenableFuture<List<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query);  }### Answer:
@Test public void testFindLatestByOriginatorAndType() throws ExecutionException, InterruptedException { System.out.println(System.currentTimeMillis()); UUID tenantId = UUID.fromString("d4b68f40-3e96-11e7-a884-898080180d6b"); UUID originator1Id = UUID.fromString("d4b68f41-3e96-11e7-a884-898080180d6b"); UUID originator2Id = UUID.fromString("d4b68f42-3e96-11e7-a884-898080180d6b"); UUID alarm1Id = UUID.fromString("d4b68f43-3e96-11e7-a884-898080180d6b"); UUID alarm2Id = UUID.fromString("d4b68f44-3e96-11e7-a884-898080180d6b"); UUID alarm3Id = UUID.fromString("d4b68f45-3e96-11e7-a884-898080180d6b"); saveAlarm(alarm1Id, tenantId, originator1Id, "TEST_ALARM"); saveAlarm(alarm2Id, tenantId, originator1Id, "TEST_ALARM"); saveAlarm(alarm3Id, tenantId, originator2Id, "TEST_ALARM"); assertEquals(3, alarmDao.find(new TenantId(tenantId)).size()); ListenableFuture<Alarm> future = alarmDao .findLatestByOriginatorAndType(new TenantId(tenantId), new DeviceId(originator1Id), "TEST_ALARM"); Alarm alarm = future.get(); assertNotNull(alarm); assertEquals(alarm2Id, alarm.getId().getId()); }