// Given
PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, Long.class).propertyName("id").type(ID).accessors().build();
PropertyMeta nameMeta = PropertyMetaTestBuilder.completeBean(Void.class, String.class).propertyName("name").type(SIMPLE).accessors().build();
EntityMeta meta = buildEntityMeta(idMeta, nameMeta);
RegularStatement statement = select().from("test");
initBuilder(statement, meta, meta.getPropertyMetas(), MANAGED);
when(daoContext.execute(any(AbstractStatementWrapper.class))).thenReturn(futureResultSet);
when(asyncUtils.transformFuture(futureResultSet, RESULTSET_TO_ROWS, executorService)).thenReturn(futureRows);
when(asyncUtils.transformFuture(eq(futureRows), rowsToEntitiesCaptor.capture(), eq(executorService))).thenReturn(futureEntities);
when(asyncUtils.transformFuture(eq(futureEntities), isoEntitiesCaptor.capture(), eq(executorService))).thenReturn(futureEntities);
when(asyncUtils.buildInterruptible(futureEntities)).thenReturn(achillesFuturesEntities);
when(mapper.mapRowToEntityWithPrimaryKey(eq(meta), eq(row), Mockito.<Map<String, PropertyMeta>>any(), eq(MANAGED))).thenReturn(entity);
when(contextFactory.newContext(entity)).thenReturn(context);
when(proxifier.buildProxyWithAllFieldsLoadedExceptCounters(entity, entityFacade)).thenReturn(entity);
// When
final AchillesFuture<List<CompleteBean>> actual = typedQuery.asyncGet(asyncListeners);
// Then
assertThat(actual).isSameAs(achillesFuturesEntities);
verify(asyncUtils).maybeAddAsyncListeners(futureEntities, asyncListeners, executorService);
final Function<List<Row>, List<CompleteBean>> rowsToEntities = rowsToEntitiesCaptor.getValue();
final List<CompleteBean> entities = rowsToEntities.apply(asList(row));
assertThat(entities).containsExactly(entity);
final List<Function<List<CompleteBean>, List<CompleteBean>>> entitiesFunctions = isoEntitiesCaptor.getAllValues();
final List<CompleteBean> entitiesWithTriggers = entitiesFunctions.get(0).apply(asList(entity));
assertThat(entitiesWithTriggers).containsExactly(entity);
verify(meta.forInterception()).intercept(entity, Event.POST_LOAD);
final List<CompleteBean> entitiesWithProxy = entitiesFunctions.get(1).apply(asList(entity));
assertThat(entitiesWithProxy).containsExactly(entity);
}