test_class.declarator: gson = new SampleDomainGsonFactory().create()
test_class.modifier: final
test_class.original_string: final Gson gson = new SampleDomainGsonFactory().create();
test_class.type: Gson
test_class.var_name: gson
test_class.file: myeslib-hazelcast/src/test/java/org/myeslib/hazelcast/storage/HzSnapshotReaderTest.java
test_class.identifier: HzSnapshotReaderTest
test_case.body: @SuppressWarnings("unchecked")
  	@Test 
  	public void lastSnapshotNullNoTransactionHistory() {
  
  		Map<UUID, AggregateRootHistory> eventsMap = Mockito.mock(Map.class);
  		Map<UUID, Snapshot<InventoryItemAggregateRoot>> lastSnapshotMap = Mockito.mock(Map.class);
  		Function<Void, InventoryItemAggregateRoot> inventoryItemInstanceFactory = Mockito.mock(Function.class);
  		
  		UUID id = UUID.randomUUID();
  		
  		InventoryItemAggregateRoot freshInstance = new InventoryItemAggregateRoot();
  		
  		HzSnapshotReader<UUID, InventoryItemAggregateRoot> st = new HzSnapshotReader<UUID, InventoryItemAggregateRoot>(eventsMap, lastSnapshotMap, inventoryItemInstanceFactory);
  		
  		when(inventoryItemInstanceFactory.apply(any(Void.class))).thenReturn(freshInstance);
  		when(eventsMap.get(id)).thenReturn(null);
  		when(lastSnapshotMap.get(id)).thenReturn(null);
  
  		assertThat(st.get(id).getAggregateInstance(), sameInstance(freshInstance));
  
  		verify(inventoryItemInstanceFactory).apply(any(Void.class));
  		verify(eventsMap).get(id);
  		verify(lastSnapshotMap).get(id);
  		
  	}
test_case.class_method_signature: HzSnapshotReaderTest.lastSnapshotNullNoTransactionHistory()
test_case.full_signature: @SuppressWarnings("unchecked") @Test public void lastSnapshotNullNoTransactionHistory()
test_case.identifier: lastSnapshotNullNoTransactionHistory
test_case.invocations: mock mock mock randomUUID thenReturn when apply any thenReturn when get thenReturn when get assertThat getAggregateInstance get sameInstance apply verify any get verify get verify
test_case.modifiers: @SuppressWarnings("unchecked") @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void lastSnapshotNullNoTransactionHistory()
focal_class.declarator: aggregateRootHistoryMap
focal_class.modifier: private final
focal_class.original_string: private final Map<K, AggregateRootHistory> aggregateRootHistoryMap ;
focal_class.type: Map<K, AggregateRootHistory>
focal_class.var_name: aggregateRootHistoryMap
focal_class.declarator: lastSnapshotMap
focal_class.modifier: private final
focal_class.original_string: private final Map<K, Snapshot<A>> lastSnapshotMap ;
focal_class.type: Map<K, Snapshot<A>>
focal_class.var_name: lastSnapshotMap
focal_class.declarator: newInstanceFactory
focal_class.modifier: private final
focal_class.original_string: private final Function<Void, A> newInstanceFactory ;
focal_class.type: Function<Void, A>
focal_class.var_name: newInstanceFactory
focal_class.file: myeslib-hazelcast/src/main/java/org/myeslib/hazelcast/storage/HzSnapshotReader.java
focal_class.identifier: HzSnapshotReader
focal_class.interfaces: implements SnapshotReader<K, A>
focal_class.class_method_signature: HzSnapshotReader.HzSnapshotReader(Map<K, AggregateRootHistory> aggregateRootHistoryMap,
  			Map<K, Snapshot<A>> lastSnapshotMap,
  			Function<Void, A> newInstanceFactory)
focal_class.full_signature: @Inject public  HzSnapshotReader(Map<K, AggregateRootHistory> aggregateRootHistoryMap,
  			Map<K, Snapshot<A>> lastSnapshotMap,
  			Function<Void, A> newInstanceFactory)
focal_class.identifier: HzSnapshotReader
focal_class.modifiers: @Inject public
focal_class.parameters: (Map<K, AggregateRootHistory> aggregateRootHistoryMap,
  			Map<K, Snapshot<A>> lastSnapshotMap,
  			Function<Void, A> newInstanceFactory)
focal_class.signature:  HzSnapshotReader(Map<K, AggregateRootHistory> aggregateRootHistoryMap,
  			Map<K, Snapshot<A>> lastSnapshotMap,
  			Function<Void, A> newInstanceFactory)
focal_class.class_method_signature: HzSnapshotReader.get(final K id)
focal_class.full_signature: public Snapshot<A> get(final K id)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (final K id)
focal_class.return: Snapshot<A>
focal_class.signature: Snapshot<A> get(final K id)
focal_class.class_method_signature: HzSnapshotReader.getEventsOrEmptyIfNull(final K id)
focal_class.full_signature: private AggregateRootHistory getEventsOrEmptyIfNull(final K id)
focal_class.identifier: getEventsOrEmptyIfNull
focal_class.modifiers: private
focal_class.parameters: (final K id)
focal_class.return: AggregateRootHistory
focal_class.signature: AggregateRootHistory getEventsOrEmptyIfNull(final K id)
focal_class.class_method_signature: HzSnapshotReader.applyAllEventsOnFreshInstance(final AggregateRootHistory transactionHistory, 
  													  final A aggregateRootFreshInstance)
focal_class.full_signature: private Snapshot<A> applyAllEventsOnFreshInstance(final AggregateRootHistory transactionHistory, 
  													  final A aggregateRootFreshInstance)
focal_class.identifier: applyAllEventsOnFreshInstance
focal_class.modifiers: private
focal_class.parameters: (final AggregateRootHistory transactionHistory, 
  													  final A aggregateRootFreshInstance)
focal_class.return: Snapshot<A>
focal_class.signature: Snapshot<A> applyAllEventsOnFreshInstance(final AggregateRootHistory transactionHistory, 
  													  final A aggregateRootFreshInstance)
focal_class.class_method_signature: HzSnapshotReader.applyEventsSinceLastSnapshot(final AggregateRootHistory transactionHistory,
  													 final Snapshot<A> lastSnapshot)
focal_class.full_signature: private Snapshot<A> applyEventsSinceLastSnapshot(final AggregateRootHistory transactionHistory,
  													 final Snapshot<A> lastSnapshot)
focal_class.identifier: applyEventsSinceLastSnapshot
focal_class.modifiers: private
focal_class.parameters: (final AggregateRootHistory transactionHistory,
  													 final Snapshot<A> lastSnapshot)
focal_class.return: Snapshot<A>
focal_class.signature: Snapshot<A> applyEventsSinceLastSnapshot(final AggregateRootHistory transactionHistory,
  													 final Snapshot<A> lastSnapshot)
focal_method.body: public Snapshot<A> get(final K id) {
  		checkNotNull(id);
  		final A aggregateRootFreshInstance = newInstanceFactory.apply(null);
  		final AggregateRootHistory transactionHistory = getEventsOrEmptyIfNull(id);
  		final Long lastVersion = transactionHistory.getLastVersion();
  		final Snapshot<A> lastSnapshot = lastSnapshotMap.get(id);
  		final Snapshot<A> resultingSnapshot;
  		if (lastSnapshot==null){
  			resultingSnapshot = applyAllEventsOnFreshInstance(transactionHistory, aggregateRootFreshInstance);
  		} else {
  			if (lastSnapshot.getVersion() < lastVersion) {
  				resultingSnapshot = applyEventsSinceLastSnapshot(transactionHistory, lastSnapshot);
  			} else {
  				resultingSnapshot = lastSnapshot;
  			}
  		}
  		return resultingSnapshot;
  	}
focal_method.class_method_signature: HzSnapshotReader.get(final K id)
focal_method.full_signature: public Snapshot<A> get(final K id)
focal_method.identifier: get
focal_method.invocations: checkNotNull apply getEventsOrEmptyIfNull getLastVersion get applyAllEventsOnFreshInstance getVersion applyEventsSinceLastSnapshot
focal_method.modifiers: public
focal_method.parameters: (final K id)
focal_method.return: Snapshot<A>
focal_method.signature: Snapshot<A> get(final K id)