test_class.declarator: ID = "test-aggregate-ID"
test_class.modifier: private static final
test_class.original_string: private static final String ID = "test-aggregate-ID";
test_class.type: String
test_class.var_name: ID
test_class.declarator: spec = singleTenant(assumingTestsValue())
test_class.modifier: protected static final
test_class.original_string: protected static final ContextSpec spec = singleTenant(assumingTestsValue());
test_class.type: ContextSpec
test_class.var_name: spec
test_class.declarator: storageFactory = InMemoryStorageFactory.newInstance()
test_class.modifier: private static final
test_class.original_string: private static final StorageFactory storageFactory = InMemoryStorageFactory.newInstance();
test_class.type: StorageFactory
test_class.var_name: storageFactory
test_class.declarator: storage
test_class.modifier: private
test_class.original_string: private AggregateStorage<String> storage;
test_class.type: AggregateStorage<String>
test_class.var_name: storage
test_class.file: server/src/test/java/io/spine/server/aggregate/ReadOperationTest.java
test_class.identifier: ReadOperationTest
test_case.body: @Test
      @DisplayName("read snapshot if present")
      void readSnapshot() {
          fillEventsWithSnapshot(5);
          AggregateReadRequest<String> request = new AggregateReadRequest<>(ID, 100);
          ReadOperation<String> operation = new ReadOperation<>(storage, request);
          Optional<AggregateHistory> record = operation.perform();
          assertTrue(record.isPresent());
          AggregateHistory stateRecord = record.get();
  
          assertTrue(stateRecord.hasSnapshot());
      }
test_case.class_method_signature: ReadOperationTest.readSnapshot()
test_case.full_signature: @Test @DisplayName("read snapshot if present") void readSnapshot()
test_case.identifier: readSnapshot
test_case.invocations: fillEventsWithSnapshot perform assertTrue isPresent get assertTrue hasSnapshot
test_case.modifiers: @Test @DisplayName("read snapshot if present")
test_case.parameters: ()
test_case.return: void
test_case.signature: void readSnapshot()
focal_class.declarator: storage
focal_class.modifier: private final
focal_class.original_string: private final AggregateStorage<I> storage;
focal_class.type: AggregateStorage<I>
focal_class.var_name: storage
focal_class.declarator: request
focal_class.modifier: private final
focal_class.original_string: private final AggregateReadRequest<I> request;
focal_class.type: AggregateReadRequest<I>
focal_class.var_name: request
focal_class.declarator: history
focal_class.modifier: private final
focal_class.original_string: private final Deque<Event> history;
focal_class.type: Deque<Event>
focal_class.var_name: history
focal_class.declarator: snapshot = null
focal_class.modifier: private @MonotonicNonNull
focal_class.original_string: private @MonotonicNonNull Snapshot snapshot = null;
focal_class.type: Snapshot
focal_class.var_name: snapshot
focal_class.file: server/src/main/java/io/spine/server/aggregate/ReadOperation.java
focal_class.identifier: ReadOperation
focal_class.class_method_signature: ReadOperation.ReadOperation(AggregateStorage<I> storage, AggregateReadRequest<I> request)
focal_class.full_signature:   ReadOperation(AggregateStorage<I> storage, AggregateReadRequest<I> request)
focal_class.identifier: ReadOperation
focal_class.parameters: (AggregateStorage<I> storage, AggregateReadRequest<I> request)
focal_class.signature:  ReadOperation(AggregateStorage<I> storage, AggregateReadRequest<I> request)
focal_class.class_method_signature: ReadOperation.perform()
focal_class.full_signature:  Optional<AggregateHistory> perform()
focal_class.identifier: perform
focal_class.parameters: ()
focal_class.return: Optional<AggregateHistory>
focal_class.signature: Optional<AggregateHistory> perform()
focal_class.class_method_signature: ReadOperation.handleRecord(AggregateEventRecord record)
focal_class.full_signature: private void handleRecord(AggregateEventRecord record)
focal_class.identifier: handleRecord
focal_class.modifiers: private
focal_class.parameters: (AggregateEventRecord record)
focal_class.return: void
focal_class.signature: void handleRecord(AggregateEventRecord record)
focal_class.class_method_signature: ReadOperation.buildRecord()
focal_class.full_signature: @SuppressWarnings("CheckReturnValue") // calling builder private AggregateHistory buildRecord()
focal_class.identifier: buildRecord
focal_class.modifiers: @SuppressWarnings("CheckReturnValue") // calling builder private
focal_class.parameters: ()
focal_class.return: AggregateHistory
focal_class.signature: AggregateHistory buildRecord()
focal_class.class_method_signature: ReadOperation.checkRecord(AggregateHistory record)
focal_class.full_signature: private static void checkRecord(AggregateHistory record)
focal_class.identifier: checkRecord
focal_class.modifiers: private static
focal_class.parameters: (AggregateHistory record)
focal_class.return: void
focal_class.signature: void checkRecord(AggregateHistory record)
focal_method.body: Optional<AggregateHistory> perform() {
          Iterator<AggregateEventRecord> historyBackward = storage.historyBackward(request);
          if (!historyBackward.hasNext()) {
              return Optional.empty();
          }
  
          while (historyBackward.hasNext() && snapshot == null) {
              AggregateEventRecord record = historyBackward.next();
              handleRecord(record);
          }
  
          AggregateHistory result = buildRecord();
          return Optional.of(result);
      }
focal_method.class_method_signature: ReadOperation.perform()
focal_method.full_signature:  Optional<AggregateHistory> perform()
focal_method.identifier: perform
focal_method.invocations: historyBackward hasNext empty hasNext next handleRecord buildRecord of
focal_method.parameters: ()
focal_method.return: Optional<AggregateHistory>
focal_method.signature: Optional<AggregateHistory> perform()