@Test public void testGetOperationLimitNotNullAndMostRecentIdEqualsLastId() { Long lastId = 1L; when(memcacheService.get(MemcacheKey.DB_OPERATION_COUNTER.getName())).thenReturn(lastId); List<DbOperationRecordDto> results = operationService.getOperations(lastId, 2); verify(memcacheService).get(MemcacheKey.DB_OPERATION_COUNTER.getName()); assertNull(results); }
public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit) { Long mostRecentId = getMostRecentId(); if (mostRecentId == null) { return null; } long beginId = lastId + 1; long endId = limit != null ? Math.min(lastId + limit, mostRecentId) : mostRecentId; if (beginId > endId) { return null; } Map<String, Object> recordsByKey = memcacheService.getAll(getNewOperationRecordKeys(beginId, endId)); List<DbOperationRecordDto> records = new ArrayList<DbOperationRecordDto>(recordsByKey.size()); for (Object recordObject : recordsByKey.values()) { records.add((DbOperationRecordDto) recordObject); } return records; }
OperationServiceImpl implements OperationService { public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit) { Long mostRecentId = getMostRecentId(); if (mostRecentId == null) { return null; } long beginId = lastId + 1; long endId = limit != null ? Math.min(lastId + limit, mostRecentId) : mostRecentId; if (beginId > endId) { return null; } Map<String, Object> recordsByKey = memcacheService.getAll(getNewOperationRecordKeys(beginId, endId)); List<DbOperationRecordDto> records = new ArrayList<DbOperationRecordDto>(recordsByKey.size()); for (Object recordObject : recordsByKey.values()) { records.add((DbOperationRecordDto) recordObject); } return records; } }
OperationServiceImpl implements OperationService { public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit) { Long mostRecentId = getMostRecentId(); if (mostRecentId == null) { return null; } long beginId = lastId + 1; long endId = limit != null ? Math.min(lastId + limit, mostRecentId) : mostRecentId; if (beginId > endId) { return null; } Map<String, Object> recordsByKey = memcacheService.getAll(getNewOperationRecordKeys(beginId, endId)); List<DbOperationRecordDto> records = new ArrayList<DbOperationRecordDto>(recordsByKey.size()); for (Object recordObject : recordsByKey.values()) { records.add((DbOperationRecordDto) recordObject); } return records; } @Inject  OperationServiceImpl(
            MemcacheService memcacheService); }
OperationServiceImpl implements OperationService { public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit) { Long mostRecentId = getMostRecentId(); if (mostRecentId == null) { return null; } long beginId = lastId + 1; long endId = limit != null ? Math.min(lastId + limit, mostRecentId) : mostRecentId; if (beginId > endId) { return null; } Map<String, Object> recordsByKey = memcacheService.getAll(getNewOperationRecordKeys(beginId, endId)); List<DbOperationRecordDto> records = new ArrayList<DbOperationRecordDto>(recordsByKey.size()); for (Object recordObject : recordsByKey.values()) { records.add((DbOperationRecordDto) recordObject); } return records; } @Inject  OperationServiceImpl(
            MemcacheService memcacheService); @Override Long getMostRecentId(); List<DbOperationRecordDto> getOperations(Long lastId, Integer limit); }
OperationServiceImpl implements OperationService { public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit) { Long mostRecentId = getMostRecentId(); if (mostRecentId == null) { return null; } long beginId = lastId + 1; long endId = limit != null ? Math.min(lastId + limit, mostRecentId) : mostRecentId; if (beginId > endId) { return null; } Map<String, Object> recordsByKey = memcacheService.getAll(getNewOperationRecordKeys(beginId, endId)); List<DbOperationRecordDto> records = new ArrayList<DbOperationRecordDto>(recordsByKey.size()); for (Object recordObject : recordsByKey.values()) { records.add((DbOperationRecordDto) recordObject); } return records; } @Inject  OperationServiceImpl(
            MemcacheService memcacheService); @Override Long getMostRecentId(); List<DbOperationRecordDto> getOperations(Long lastId, Integer limit);  }