test_class.declarator: operationService
test_class.modifier: @Inject
test_class.original_string: @Inject
      OperationServiceImpl operationService;
test_class.type: OperationServiceImpl
test_class.var_name: operationService
test_class.declarator: memcacheService
test_class.modifier: @Inject
test_class.original_string: @Inject
      MemcacheService memcacheService;
test_class.type: MemcacheService
test_class.var_name: memcacheService
test_class.file: gae-studio/gae-studio-server/src/test/java/com/arcbees/gaestudio/server/service/profiler/OperationServiceImplTest.java
test_class.identifier: OperationServiceImplTest
test_case.body: @Test
      public void testGetOperationLimitNotNullAndMostRecentIdGreaterThanLastIdPlusLimit(
              DbOperationRecordDto dtoFromMemCache1,
              DbOperationRecordDto dtoFromMemCache2, DbOperationRecordDto dtoFromMemCache3) {
          // Given
          Long lastId = 1L;
          when(memcacheService.get(MemcacheKey.DB_OPERATION_COUNTER.getName())).thenReturn(5L);
          Map<String, Object> mapFromMemCache = Maps.newHashMap();
          mapFromMemCache.put("dummyKey1", dtoFromMemCache1);
          mapFromMemCache.put("dummyKey2", dtoFromMemCache2);
          mapFromMemCache.put("dummyKey3", dtoFromMemCache3);
          when(memcacheService.getAll(anyCollection())).thenReturn(mapFromMemCache);
  
          // when
          List<DbOperationRecordDto> results = operationService.getOperations(lastId, 3);
  
          // then
          verify(memcacheService).get(MemcacheKey.DB_OPERATION_COUNTER.getName());
          verify(memcacheService).getAll(Lists.newArrayList(MemcacheKey.DB_OPERATION_RECORD_PREFIX.getName() +
                  2, MemcacheKey.DB_OPERATION_RECORD_PREFIX.getName() + 3,
                  MemcacheKey.DB_OPERATION_RECORD_PREFIX.getName() +
                          4));
          assertEquals(3, results.size());
          assertEquals(dtoFromMemCache1, results.get(0));
          assertEquals(dtoFromMemCache2, results.get(1));
          assertEquals(dtoFromMemCache3, results.get(2));
      }
test_case.class_method_signature: OperationServiceImplTest.testGetOperationLimitNotNullAndMostRecentIdGreaterThanLastIdPlusLimit(
              DbOperationRecordDto dtoFromMemCache1,
              DbOperationRecordDto dtoFromMemCache2, DbOperationRecordDto dtoFromMemCache3)
test_case.full_signature: @Test public void testGetOperationLimitNotNullAndMostRecentIdGreaterThanLastIdPlusLimit(
              DbOperationRecordDto dtoFromMemCache1,
              DbOperationRecordDto dtoFromMemCache2, DbOperationRecordDto dtoFromMemCache3)
test_case.identifier: testGetOperationLimitNotNullAndMostRecentIdGreaterThanLastIdPlusLimit
test_case.invocations: thenReturn when get getName newHashMap put put put thenReturn when getAll anyCollection getOperations get verify getName getAll verify newArrayList getName getName getName assertEquals size assertEquals get assertEquals get assertEquals get
test_case.modifiers: @Test public
test_case.parameters: (
              DbOperationRecordDto dtoFromMemCache1,
              DbOperationRecordDto dtoFromMemCache2, DbOperationRecordDto dtoFromMemCache3)
test_case.return: void
test_case.signature: void testGetOperationLimitNotNullAndMostRecentIdGreaterThanLastIdPlusLimit(
              DbOperationRecordDto dtoFromMemCache1,
              DbOperationRecordDto dtoFromMemCache2, DbOperationRecordDto dtoFromMemCache3)
focal_class.declarator: memcacheService
focal_class.modifier: private final
focal_class.original_string: private final MemcacheService memcacheService;
focal_class.type: MemcacheService
focal_class.var_name: memcacheService
focal_class.file: gae-studio/gae-studio-server/src/main/java/com/arcbees/gaestudio/server/service/profiler/OperationServiceImpl.java
focal_class.identifier: OperationServiceImpl
focal_class.interfaces: implements OperationService
focal_class.class_method_signature: OperationServiceImpl.OperationServiceImpl(
              MemcacheService memcacheService)
focal_class.full_signature: @Inject  OperationServiceImpl(
              MemcacheService memcacheService)
focal_class.identifier: OperationServiceImpl
focal_class.modifiers: @Inject
focal_class.parameters: (
              MemcacheService memcacheService)
focal_class.signature:  OperationServiceImpl(
              MemcacheService memcacheService)
focal_class.class_method_signature: OperationServiceImpl.getMostRecentId()
focal_class.full_signature: @Override public Long getMostRecentId()
focal_class.identifier: getMostRecentId
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Long
focal_class.signature: Long getMostRecentId()
focal_class.class_method_signature: OperationServiceImpl.getOperations(Long lastId, Integer limit)
focal_class.full_signature: public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit)
focal_class.identifier: getOperations
focal_class.modifiers: public
focal_class.parameters: (Long lastId, Integer limit)
focal_class.return: List<DbOperationRecordDto>
focal_class.signature: List<DbOperationRecordDto> getOperations(Long lastId, Integer limit)
focal_class.class_method_signature: OperationServiceImpl.getNewOperationRecordKeys(long beginId, long endId)
focal_class.full_signature: private List<String> getNewOperationRecordKeys(long beginId, long endId)
focal_class.identifier: getNewOperationRecordKeys
focal_class.modifiers: private
focal_class.parameters: (long beginId, long endId)
focal_class.return: List<String>
focal_class.signature: List<String> getNewOperationRecordKeys(long beginId, long endId)
focal_method.body: public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit) {
          Long mostRecentId = getMostRecentId();
  
          if (mostRecentId == null) {
              return null;
          }
  
          long beginId = lastId + 1;
          // TODO if there is a big difference between beginId and the most recent id, binary search for the true start
          long endId = limit != null ? Math.min(lastId + limit, mostRecentId) : mostRecentId;
  
          if (beginId > endId) {
              return null;
          }
  
          Map<String, Object> recordsByKey = memcacheService.getAll(getNewOperationRecordKeys(beginId, endId));
          // TODO trimming missing results only from the end of the range is incorrect, as there are scenarios
          // in which there could be missing records in the middle. We need a better approach to this that
          // always retrieves all missing records.
  
          List<DbOperationRecordDto> records = new ArrayList<DbOperationRecordDto>(recordsByKey.size());
          for (Object recordObject : recordsByKey.values()) {
              records.add((DbOperationRecordDto) recordObject);
          }
  
          return records;
      }
focal_method.class_method_signature: OperationServiceImpl.getOperations(Long lastId, Integer limit)
focal_method.full_signature: public List<DbOperationRecordDto> getOperations(Long lastId, Integer limit)
focal_method.identifier: getOperations
focal_method.invocations: getMostRecentId min getAll getNewOperationRecordKeys size values add
focal_method.modifiers: public
focal_method.parameters: (Long lastId, Integer limit)
focal_method.return: List<DbOperationRecordDto>
focal_method.signature: List<DbOperationRecordDto> getOperations(Long lastId, Integer limit)