}
@Test
public void should_refresh() throws Exception {
// Given
CompleteBean bean = CompleteBeanTestBuilder.builder().id(12L).buid();
when(context.<CompleteBean>getEntityClass()).thenReturn(CompleteBean.class);
when(context.getPrimaryKey()).thenReturn(bean.getId());
when(context.getEntity()).thenReturn(bean);
when(proxifier.getInterceptor(bean)).thenReturn(proxyInterceptor);
when(proxyInterceptor.getTarget()).thenReturn(bean);
when(proxyInterceptor.getDirtyMap()).thenReturn(dirtyMap);
when(proxyInterceptor.getAlreadyLoaded()).thenReturn(alreadyLoaded);
when(context.getEntityMeta()).thenReturn(entityMeta);
when(loader.load(context, CompleteBean.class)).thenReturn(achillesFutureEntity);
when(context.getAllGettersExceptCounters()).thenReturn(allGettersExceptCounters);
when(asyncUtils.transformFuture(eq(achillesFutureEntity), interceptorCaptor.capture(), eq(executorService))).thenReturn(achillesFutureEntity);
when(asyncUtils.buildInterruptible(achillesFutureEntity)).thenReturn(achillesFutureEntity);
// When
final AchillesFuture<CompleteBean> actual = refresher.refresh(bean, context);
// Then
assertThat(actual).isSameAs(achillesFutureEntity);
final CompleteBean actualBean = interceptorCaptor.getValue().apply(bean);
assertThat(actualBean).isSameAs(bean);
verify(dirtyMap).clear();
verify(alreadyLoaded).clear();
verify(alreadyLoaded).addAll(allGettersExceptCounters);