How to resolve an IllegalStateException: User not found in JUnit test?
<p>for testing I want to create a user object and save it for later reference with:</p>

<pre><code>    User user = userService.createUserInformation("testl", "testpw", "peter", "tester", "test@test.de", "en");
</code></pre>

<p>Inside that, there is a call to save the user:</p>

<pre><code>    public User createUserInformation(...)
       User newUser = new User();
       Authority authority = authorityRepository.findOne("ROLE_USER");
       ...
       newUser.setAuthorities(authorities);
       userRepository.save(newUser);
     }
</code></pre>

<p>But when I try this, I get a:</p>

<pre><code>org.springframework.dao.InvalidDataAccessApiUsageException: User not found!; nested exception is java.lang.IllegalStateException: User not found!
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:381)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:227)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:131)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
    at com.sun.proxy.$Proxy166.save(Unknown Source)
    at app.backend.service.UserService.createUserInformation(UserService.java:111)
    at 
</code></pre>

<p>What does this means (User not found, while I want to save it?) How can I see more details of the User object, or how to fix this problem?</p>

<p>The test configuration is based on an AbstractControllerTest:</p>

<pre><code>  @WebAppConfiguration
  @ContextConfiguration  
  @ActiveProfiles({"dev", "test"})
  public class AbstractControllerTest extends AbstractTest {
</code></pre>

<p>(not sure where to find the exact app configuration for test)</p>

<p>Thanks a lot for your help!</p>