@Test
public void generateAccessTokenWithRandomCode() {

     AccessTokenPersist persist = new AccessTokenPersist();
     persist.setApp(new ReferenceIdDTO(10L));
     Plan plan = new Plan();
     plan.setId(1L);
     persist.setPlans(Collections.singletonList(new ReferenceIdDTO(1L)));
     
     App appRecovered = new App();
     appRecovered.setId(10L);
     appRecovered.setPlans(Collections.singletonList(plan));
     
     Mockito.when(accessTokenRepository.findByCode(Mockito.anyString())).thenReturn(null);
     Mockito.when(appRespository.findOne(Mockito.anyLong())).thenReturn(appRecovered);
     
     service.save(persist);
     
     Mockito.verify(accessTokenRepository, Mockito.times(1)).save(Mockito.any(AccessToken.class));
}