private List<TransferLog> getTransferLogs(TransferLogSerialization logSerialization) { PagingState pagingState = null; List<TransferLog> allLogs = new ArrayList<>(); while (true) { Result<TransferLog> result = logSerialization.getAllTransferLogs(pagingState, 100); allLogs.addAll(result.getEntities()); if (result.getPagingState() == null) { break; } pagingState = result.getPagingState(); } return allLogs; }
@Test public void recordTransferLog() throws Exception { TransferLogSerialization logSerialization = getInjector().getInstance(TransferLogSerialization.class); CassandraClient cassandraClient = getInjector().getInstance(CassandraClientImpl.class); String queueName = "tlst_queue_" + RandomStringUtils.randomAlphanumeric(15); String source = RandomStringUtils.randomAlphanumeric(15); String dest = RandomStringUtils.randomAlphanumeric(15); int numLogs = 100; for (int i = 0; i < numLogs; i++) { logSerialization.recordTransferLog(queueName, source, dest, UUIDGen.getTimeUUID()); } int count = 0; int fetchCount = 0; PagingState pagingState = null; while (true) { Result<TransferLog> all = logSerialization.getAllTransferLogs(pagingState, 10); // we only want entities for our queue List<TransferLog> logs = all.getEntities() .stream() .filter(log -> log.getQueueName().equals(queueName)) .collect(Collectors.toList()); count += logs.size(); fetchCount++; if (all.getPagingState() == null) { break; } pagingState = all.getPagingState(); } Assert.assertEquals(numLogs, count); }